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