Submission #649856

#TimeUsernameProblemLanguageResultExecution timeMemory
649856boris_mihovSecret Permutation (RMI19_permutation)C++17
3 / 100
3393 ms208 KiB
#include "permutation.h" #include <algorithm> #include <iostream> #include <iomanip> #include <numeric> #include <cassert> #include <vector> #include <cmath> #include <set> const int MAXN = 256 + 10; const int INF = 1e9; // int p[MAXN]; // int query(std::vector <int> v) // { // int sum = 0; // for (int i = 0 ; i < v.size() - 1 ; ++i) // { // sum += abs(p[v[i + 1]] - p[v[i]]); // } // return sum; // } // void answer(std::vector <int> v) // { // int cnt = 1; // bool res = true; // for (const int &i : v) // { // std::cout << i << ' '; // res &= (i == p[cnt++]); // } // std::cout << '\n'; // if (res) std::cout << "OK\n"; // else std::cout << "WA\n"; // exit(0); // } std::vector <int> perm; std::vector <int> ans; void solve(int n) { perm.resize(n); ans.resize(n); std::iota(perm.begin(), perm.end(), 1); do { if (query(perm) == n-1) { int cnt = 1; for (int i : perm) ans[i-1] = cnt++; answer(ans); return; } } while(std::next_permutation(perm.begin(), perm.end())); } // int n; // int main() // { // std::cin >> n; // for (int i = 1 ; i <= n ; ++i) // { // std::cin >> p[i]; // } // solve(n); // return 0; // }

Compilation message (stderr)

stub.cpp: In function 'int query(int*)':
stub.cpp:15:9: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |   fscanf(stdin, "%d", &x);
      |   ~~~~~~^~~~~~~~~~~~~~~~~
stub.cpp: In function 'int main(int, char**)':
stub.cpp:48:9: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |   fscanf(stdin, "%d", &N);
      |   ~~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...