제출 #685400

#제출 시각아이디문제언어결과실행 시간메모리
685400annie2018Secret Permutation (RMI19_permutation)C++17
0 / 100
0 ms208 KiB
#include <bits/stdc++.h> #include "permutation.h" using namespace std; vector <int> ans; void get(vector<int> &q, int n) { vector <int> a(n); for (int i = 1; i <= n; i++) a[i - 1] = i; bool f = 1; do { f = 1; for (int i = 0; i < n - 1; i++) if (abs(a[i + 1] - a[i]) != q[i]) f = 0; if (abs(a[0] - a[n - 1]) != q[n - 1]) f = 0; if (f){ /*for (int i = 0; i < n; i++) cout << a[i] << ' '; cout << "\n";*/ ans = a; return; } } while (next_permutation(a.begin(), a.end())); } void solve(int n) { srand(chrono::steady_clock::now().time_since_epoch().count()); vector <int> v; for (int i = 1; i <= n; i++) v.push_back(i); random_shuffle(v.begin(), v.end()); vector <int> q(n); for(int i = 0; i < n; i++) { q[i] = query(v); rotate(v.begin(),v.begin()+1,v.end()); } int sum = 0; for(int i = 0; i < n; i++) sum += q[i]; sum /= (n - 1); for(int i = 0; i < n; i++) q[i] = (sum - q[i]); rotate(q.begin(), q.begin() + 1, q.end()); /*for (int i = 0; i < n; i++) cout << q[i] << ' '; cout << "\n";*/ //ans.assign(n, 0); get(q, n); answer(ans); }

컴파일 시 표준 에러 (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...