Submission #871345

#TimeUsernameProblemLanguageResultExecution timeMemory
871345rainboySecret Permutation (RMI19_permutation)C++17
62.43 / 100
13 ms600 KiB
#include "permutation.h" #include <vector> using namespace std; typedef vector<int> vi; const int N = 256; int abs_(int a) { return a > 0 ? a : -a; } int min(int a, int b) { return a < b ? a : b; } int dd[N]; void solve(int n) { vi ii(n); for (int i = 0; i < n; i++) { for (int h = 0; h < n; h++) ii[h] = (i + h) % n + 1; dd[i] = query(ii); } int sum = 0; for (int i = 0; i < n; i++) sum += dd[i]; sum /= (n - 1); for (int i = 0; i < n; i++) dd[i] = sum - dd[i]; vi pp(n); pp[0] = 0, pp[1] = dd[1]; for (int i = 2; i < n; i++) { for (int h = 0; h < n; h++) ii[h] = (h < i ? i - 1 - h : h) + 1; pp[i] = query(ii) - (sum - dd[0]) + dd[i]; if (abs_(pp[i] - pp[i - 1]) != dd[i]) pp[i] = -pp[i]; } int p = 0; for (int i = 0; i < n; i++) p = min(p, pp[i]); for (int i = 0; i < n; i++) pp[i] -= p - 1; answer(pp); }

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...