제출 #614409

#제출 시각아이디문제언어결과실행 시간메모리
614409bruceccccccUnscrambling a Messy Bug (IOI16_messy)C++14
38 / 100
2 ms340 KiB
#include <bits/stdc++.h> #include "messy.h" using namespace std; vector<int> restore_permutation(int n, int w, int r) { srand(102938); set<int> pos; for (int i = 0; i < n; i++) pos.insert(i); set<int> k = pos; vector<int> val(n); string x(n, '0'); for (int i = 0; i < n; i++) { auto g = next(k.begin(), rand() % k.size()); x[*g] = '1'; val[i] = *g; k.erase(g); add_element(x); } compile_set(); x = string(n, '0'); int count = 0; vector<int> ans(n); for (int i = 0; i < n; i++) { set<int> guess = pos; while (!guess.empty()) { auto g = next(guess.begin(), rand() % guess.size()); string t = x; int ind = *g; t[ind] = '1'; guess.erase(g); // cout << t << ' ' << x << endl; // count++; if (guess.empty() || check_element(t)) { ans[ind] = val[i]; x[ind] = '1'; pos.erase(ind); break; } } } // cout << count << endl; return ans; }

컴파일 시 표준 에러 (stderr) 메시지

messy.cpp: In function 'std::vector<int> restore_permutation(int, int, int)':
messy.cpp:23:7: warning: unused variable 'count' [-Wunused-variable]
   23 |   int count = 0;
      |       ^~~~~
#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...