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;}