제출 #1053987

#제출 시각아이디문제언어결과실행 시간메모리
1053987huutuanSecret Permutation (RMI19_permutation)C++14
0 / 100
1 ms344 KiB
#include "permutation.h" #include <bits/stdc++.h> using namespace std; mt19937 rng(69420); int rand(int l, int r){ return uniform_int_distribution<int>(l, r)(rng); } void solve(int n) { if (n==3){ if (query({1, 2, 3})==2) answer({1, 2, 3}); if (query({2, 1, 3})==2) answer({2, 1, 3}); answer({3, 1, 2}); } vector<int> ans(n+1, -1); while (1){ int x=rand(1, n); int y=x; while (y==x) y=rand(1, n); if (x>y) swap(x, y); map<int, int> cnt; vector<int> dd(n+1); for (int i=1; i<=n; ++i) if (i!=x && i!=y){ vector<int> v; v.push_back(i); v.push_back(x); for (int j=1; j<=n; ++j) if (j!=i && j!=x && j!=y) v.push_back(j); v.push_back(y); int d=query(v); v.erase(v.begin()); v.push_back(i); d-=query(v); ++cnt[d]; dd[i]=d; } for (auto &j:cnt) if (j.second>=2){ int diff=abs(j.first); ans[x]=cnt[-diff]+1; ans[y]=n-cnt[diff]; int px=y; for (int k=1; k<=n; ++k) if (k!=x && k!=y && abs(dd[k])!=diff){ ans[k]=(dd[k]+ans[x]-ans[y])/2; if (ans[k]==ans[x]+1) px=k; } for (int k=1; k<=n; ++k) if (ans[k]==-1){ vector<int> v; v.push_back(k); v.push_back(y); v.push_back(x); for (int l=1; l<=n; ++l) if (l!=k && l!=x && l!=y) v.push_back(l); int dx=query(v); swap(v[0], v[1]); dx-=query(v); dx=abs(ans[x]-ans[y])-dx; v.clear(); v.push_back(k); v.push_back(x); v.push_back(px); for (int l=1; l<=n; ++l) if (l!=k && l!=px && l!=x) v.push_back(l); int dx1=query(v); swap(v[0], v[1]); dx1-=query(v); dx1=abs(ans[px]-ans[x])-dx1; if (dx<dx1){ ans[k]=ans[x]-dx; }else{ ans[k]=ans[x]+dx; } } ans.erase(ans.begin()); 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...