|
|
вернуться в форумWA7 anybody help me!!! There's my solution #include<iostream> #include<string> #include<stdio.h> #include<stdlib.h> using namespace std; int main() { int b[26],n,i,j;bool t=true; string a[26][3],str,s[26]; cin>>n; for(i=0;i<n;i++) { cin>>a[i][0]; cin>>a[i][1]; cin>>a[i][2]; if(a[i][1]>a[i][2]) { str=a[i][1]; a[i][1]=a[i][2]; a[i][2]=str; }
if(a[i][0]>a[i][1]) { str=a[i][0]; a[i][0]=a[i][1]; a[i][1]=str; }
} /* for(i=0;i<n;i++) {for(j=0;j<3;j++) cout<<a[i][j]<<" "; cout<<endl; } */ for(i=0;i<n;i++) { cin>>b[i]; if(i==0) s[i]=a[b[i]-1][0]; else{j=0; while(a[b[i]-1][j]<=s[i-1]&&j<3) {
j++;} if(a[b[i]-1][j]>s[b[i]-1]) s[i]=a[b[i]-1][j]; else t=false; }
} if(t) for(i=0;i<n;i++) cout<<s[i]<<endl; else cout<<"IMPOSSIBLE";
system("pause"); } |
|
|