codeforces #71 B. Colorful Field 二分

http://www.codeforces.com/contest/79/problem/B

#include<iostream> using namespace std; __int64 pos[1010]; #include<algorithm> int main() { //freopen("a.txt","r",stdin); int n,m,k,t; while(scanf("%d%d%d%d",&n,&m,&k,&t)!=EOF) { int i,j; int a,b; for(i=0;i<k;i++) { scanf("%d%d",&a,&b); pos[i]=(a-1)*m+b; } sort(pos,pos+k); while(t--) { scanf("%d%d",&a,&b); int ans=lower_bound(pos,pos+k,(a-1)*m+b)-pos;//返回地址! if(pos[ans]==(a-1)*m+b) { printf("Waste/n"); continue; } ans=(a-1)*m+b-ans; ans=ans%3; if(ans==0) { printf("Grapes/n"); continue; } if(ans==1) { printf("Carrots/n"); continue; } if(ans==2) { printf("Kiwis/n"); continue; } } } return 0; }

你可能感兴趣的:(codeforces #71 B. Colorful Field 二分)