标签:
Time Limit: 1500/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 1108 Accepted Submission(s): 587
1 #include <cstdio> 2 #include <cstring> 3 #include <string> 4 #include <iostream> 5 #include <algorithm> 6 using namespace std; 7 8 int main() 9 { 10 int T; 11 int n,q; 12 int a[1005],c[1005]; 13 int i,j,k; 14 string b[1005]; 15 scanf("%d",&T); 16 while(T--) 17 { 18 scanf("%d",&n); 19 for(i=1;i<=n;i++) 20 { 21 scanf("%d",&a[i]); 22 b[a[i]]=""; 23 } 24 scanf("%d",&q); 25 for(i=1;i<=q;i++) 26 scanf("%d",&c[i]); 27 28 for(i=2;i<=n;i++) 29 { 30 int mx=9999,mi=0,mxnum=0,minum=0; 31 for(j=1;j<i;j++) 32 { 33 if(a[j]>a[i] && a[j]<mx) 34 { 35 mx=a[j],mxnum=j; 36 } 37 if(a[j]<a[i] && a[j]>mi) 38 { 39 mi=a[j],minum=j; 40 } 41 } 42 //printf("$#$ %d %d %d %d #$\n",mx,mxnum,mi,minum); 43 if(mxnum>minum) 44 { 45 b[a[i]]=b[a[mxnum]]+‘E‘; 46 } 47 else 48 { 49 b[a[i]]=b[a[minum]]+‘W‘; 50 } 51 } 52 53 for(i=1;i<=q;i++) 54 cout << b[c[i]] << endl; 55 } 56 return 0; 57 }
标签:
原文地址:http://www.cnblogs.com/cyd308/p/4820257.html