Submission #370630

#TimeUsernameProblemLanguageResultExecution timeMemory
370630arnold518Zagonetka (COI18_zagonetka)C++14
0 / 100
2 ms364 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 100; int N, A[MAXN+10], P[MAXN+10]; int query() { printf("query "); for(int i=1; i<=N; i++) printf("%d ", P[i]); printf("\n"); fflush(stdout); int t; scanf("%d", &t); return t; } int main() { scanf("%d", &N); for(int i=1; i<=N; i++) scanf("%d", &A[i]); int a=-1, b=-1; for(int i=1; i<=N; i++) { for(int j=i+1; j<=N; j++) { for(int k=1; k<=N; k++) P[k]=A[k]; swap(P[i], P[j]); if(!query()) { a=i; b=j; break; } if(a!=-1) break; } if(a!=-1) break; } printf("end\n"); fflush(stdout); if(A[a]<A[b]) { for(int i=1; i<=N; i++) printf("%d ", i); printf("\n"); } else { for(int i=1; i<=N; i++) { if(i<a || b<i) printf("%d ", i); else if(i==a) printf("%d ", a+1); else if(i==b) printf("%d ", a); else printf("%d ", i+1); } printf("\n"); } fflush(stdout); if(A[a]>A[b]) { for(int i=1; i<=N; i++) printf("%d ", N-i+1); printf("\n"); } else { for(int i=1; i<=N; i++) { if(i<a || b<i) printf("%d ", N-i+1); else if(i==a) printf("%d ", N-a); else if(i==b) printf("%d ", N-a+1); else printf("%d ", N-i); } printf("\n"); } fflush(stdout); }

Compilation message (stderr)

zagonetka.cpp: In function 'int query()':
zagonetka.cpp:19:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   19 |     scanf("%d", &t);
      |     ~~~~~^~~~~~~~~~
zagonetka.cpp: In function 'int main()':
zagonetka.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   25 |     scanf("%d", &N);
      |     ~~~~~^~~~~~~~~~
zagonetka.cpp:26:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   26 |     for(int i=1; i<=N; i++) scanf("%d", &A[i]);
      |                             ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...