Submission #419251

#TimeUsernameProblemLanguageResultExecution timeMemory
419251mat_vUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
4 ms496 KiB
#include <bits/stdc++.h> #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i)) #define pb push_back #include "messy.h" using namespace std; int N; void dodaj(int l, int r){ if(l == r)return; ff(i,0,(r-l+1)/2 - 1){ string x=""; ff(j,0,N - 1){ if(j < l || j > r)x += '1'; else{ if(j == i+l)x += '1'; else x += '0'; } } add_element(x); } int mid = (l + r) / 2; dodaj(l,mid); dodaj(mid + 1, r); } int slika[1005]; bool ima[1005]; int sol[1005]; void resi(int l, int r, vector<int> s){ if(l == r){ slika[l] = s[0]; return; } vector<int> gde; ff(i,0,N-1)ima[i] = 0; for(auto c:s)ima[c] = 1; vector<int> pola; ff(i,0,r-l){ string x = ""; int kol = 0; ff(j,0,N-1){ if(!ima[j])x += '1'; else{ if(j == s[i])x += '1'; else x += '0'; kol++; } } //check(x); if(check_element(x))pola.pb(s[i]); } vector<int> druga; ff(i,0,N-1)ima[i] = 0; for(auto c:pola)ima[c] = 1; for(auto c:s)if(!ima[c])druga.pb(c); int mid = (l + r) / 2; resi(l,mid,pola); resi(mid + 1,r,druga); } std::vector<int> restore_permutation(int n, int w, int r) { N = n; dodaj(0,n - 1); compile_set(); vector<int> v; ff(i,0,n-1)v.pb(i); resi(0,n-1,v); vector<int> ans; ff(i,0,N-1)sol[slika[i]] = i; ff(i,0,N-1)slika[i] = sol[i]; ff(i,0,N-1)ans.pb(slika[i]); return ans; }

Compilation message (stderr)

messy.cpp: In function 'void dodaj(int, int)':
messy.cpp:4:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    4 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
messy.cpp:14:5: note: in expansion of macro 'ff'
   14 |     ff(i,0,(r-l+1)/2 - 1){
      |     ^~
messy.cpp:4:27: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
    4 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
messy.cpp:16:9: note: in expansion of macro 'ff'
   16 |         ff(j,0,N - 1){
      |         ^~
messy.cpp: In function 'void resi(int, int, std::vector<int>)':
messy.cpp:4:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    4 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
messy.cpp:42:5: note: in expansion of macro 'ff'
   42 |     ff(i,0,N-1)ima[i] = 0;
      |     ^~
messy.cpp:4:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    4 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
messy.cpp:45:5: note: in expansion of macro 'ff'
   45 |     ff(i,0,r-l){
      |     ^~
messy.cpp:4:27: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
    4 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
messy.cpp:48:9: note: in expansion of macro 'ff'
   48 |         ff(j,0,N-1){
      |         ^~
messy.cpp:4:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    4 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
messy.cpp:60:5: note: in expansion of macro 'ff'
   60 |     ff(i,0,N-1)ima[i] = 0;
      |     ^~
messy.cpp: In function 'std::vector<int> restore_permutation(int, int, int)':
messy.cpp:4:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    4 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
messy.cpp:73:5: note: in expansion of macro 'ff'
   73 |     ff(i,0,n-1)v.pb(i);
      |     ^~
messy.cpp:4:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    4 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
messy.cpp:77:5: note: in expansion of macro 'ff'
   77 |     ff(i,0,N-1)sol[slika[i]] = i;
      |     ^~
messy.cpp:4:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    4 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
messy.cpp:78:5: note: in expansion of macro 'ff'
   78 |     ff(i,0,N-1)slika[i] = sol[i];
      |     ^~
messy.cpp:4:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    4 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
messy.cpp:79:5: note: in expansion of macro 'ff'
   79 |     ff(i,0,N-1)ans.pb(slika[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...
#Verdict Execution timeMemoryGrader output
Fetching results...