【火腿賽區現場賽Problem J】媽媽說阿迪王比耐克牛-Dressing

來源:互聯網
上載者:User

FROM:2012-10-28 ACM/ICPC ASIA JinHua Area,Problem J. 點擊開啟連結

這個題看著虎,其實還是很水。。。。但因為閱讀理解,坑了一些時間。難得這麼大的比賽有兩道不用腦子的水題。。。

描述上亮點頗多:

1、Mom thinks that pants-shoes pair is disharmonious because
Adiwang is much better than Nike.
(囧RZ)

2、Next
P lines each line will be one of the two forms“clothes x pants y”
or “pants y shoes z”.(這說明只有兩種情況 沒有clothes和shoes一起不和諧的情況)

3、For
each case, the first line contains 3 integers N,M,K(1≤N,M,K≤1000) indicating the number of clothes, pants and shoes.Second line contains only one integer P(0≤P≤2000000)
indicating the number of pairs which mom thinks disharmonious.(注意200000,這說明不用按部就班的類比,否則TLE)

明白了這些,AC便指日可待了……

1TLE(200000純屬坑爹的) 1WA(數組初始化開錯了) 1AC:

#include <iostream>#include <string>#include <cstring>using namespace std;const int INF=1005;int clothes[INF],pants[INF],shoes[INF];int main(){int yi,ku,xie;while(cin>>yi>>ku>>xie && (yi!=0 || ku!=0 || xie!=0)){for(int i=0;i<=INF;i++){clothes[i]=0;pants[i]=0;shoes[i]=0;}int hexienum,result=0;cin>>hexienum;if(hexienum==0){cout<<yi*ku*xie<<endl;continue;}else{for(int i=0;i<hexienum;i++){string opa,opb;int buhexie1,buhexie2;cin>>opa>>buhexie1>>opb>>buhexie2;if(opa=="clothes" || opb=="clothes"){clothes[buhexie2]++;}if(opb=="shoes" || opa== "shoes"){shoes[buhexie1]++;}}for(int i=1;i<=ku;i++){result+=(xie-shoes[i])*(yi-clothes[i]);}cout<<result<<endl;}}return 0;}


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.