Submission #959599

#TimeUsernameProblemLanguageResultExecution timeMemory
959599lovrotZagonetka (COI18_zagonetka)C++17
0 / 100
0 ms344 KiB
#include <cstdio> #include <vector> #include <algorithm> #include <cstring> #define PB push_back using namespace std; const int N = 110; int n; vector<int> P; int I[N], BIO[N], ANS[N]; vector<int> IN[N], OUT[N], G[N]; void topo(int u, bool d, int b, vector<int> &T) { // d = 1 : od vecih prema manjim if(BIO[u] || (d == 1 && u < b) || (d == 0 && u > b)) return; BIO[u] = 1; for(int v : G[u]) if((u > v) == d) topo(v, d, b, T); T.PB(u); } bool query(vector<int> &V) { printf("query "); for(int x : V) printf("%d ", x); printf("\n"); fflush(stdout); int x; scanf("%d", &x); return x; } void dfs(int u, vector<int> *D, vector<int> &T) { if(BIO[u]) return; BIO[u] = 1; for(int v : D[u]) dfs(v, D, T); T.PB(u); } void solve(vector<int> *D, vector<int> &F) { memset(BIO, 0, sizeof(BIO)); vector<int> T; for(int i = 0, j = 0; i < n; ++i) { T.clear(); dfs(i, D, T); for(int x : T) ANS[x] = F[j++]; } for(int i = 0; i < n; ++i) printf("%d%c", ANS[i], " \n"[i == n - 1]); } int main() { scanf("%d", &n); for(int i = 0; i < n; ++i) { int x; scanf("%d", &x); P.PB(x); I[x] = i; } // for(int i = 1; i < n; ++i) // for(int j = 1; j + i <= n; ++j) { // memset(BIO, 0, sizeof(BIO)); // vector<int> Q = P, L, R; // // topo(j, 0, j + i, L); reverse(L.begin(), L.end()); // topo(j + i, 1, j, R); // // int l = L.size(), r = R.size(); // if(l == i + 1) continue; // for(int k = 0; k < min(l, r); ++k) { // Q[I[L[l - k - 1]]] = R[r - k - 1]; // Q[I[R[k]]] = L[k]; // } // if(l <= r) { // for(int k = 0; k < r - l; ++k) Q[I[R[k + r - l]]] = R[k]; // } else { // for(int k = 0; k < l - r; ++k) Q[I[L[k]]] = L[k + l - r]; // } // // if(!query(Q)) { // G[j].PB(j + i); // G[j + i].PB(j); // OUT[I[j + i]].PB(I[j]); // IN[I[j]].PB(I[j + i]); // } // } printf("end\n"); for(int i = 0; i < n; ++i) printf("%d ", i + 1); printf("\n"); for(int i = 0; i < n; ++i) printf("%d ", i + 1); printf("\n"); // vector<int> F; // for(int i = 1; i <= n; ++i) F.PB(i); // // solve(OUT, F); // reverse(F.begin(), F.end()); // solve(IN, F); fflush(stdout); return 0; }

Compilation message (stderr)

zagonetka.cpp: In function 'bool query(std::vector<int>&)':
zagonetka.cpp:32:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |  int x; scanf("%d", &x); return x;
      |         ~~~~~^~~~~~~~~~
zagonetka.cpp: In function 'int main()':
zagonetka.cpp:56:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   56 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
zagonetka.cpp:58:15: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   58 |   int x; scanf("%d", &x);
      |          ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...