# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
259615 | 2020-08-08T04:23:41 Z | tqbfjotld | Secret Permutation (RMI19_permutation) | C++14 | 3807 ms | 384 KB |
#include "permutation.h" #include <bits/stdc++.h> using namespace std; int arr[300]; int n; vector<int> inv(){ vector<int> ans; for (int x = 0; x<n; x++){ ans.push_back(0); } for (int x = 1; x<=n; x++){ ans[arr[x]-1] = x; } return ans; } void solve(int N) { n = N; for (int x = 1; x<=n; x++){ arr[x] = x; } while (true){ if (query(inv())==n-1){ vector<int> ans; for (int x = 1; x<=n; x++){ ans.push_back(arr[x]); } answer(ans); break; } pair<int,int> best = {-1,-1}; int bestv = 999999999; vector<pair<int,pair<int,int> > >rem; for (int x = 1; x<=n; x++){ for (int y = x+1; y<=n; y++){ rem.push_back({rand(),{x,y}}); } } sort(rem.begin(),rem.end()); int threshold = n*n; for (int x = 0; x<min(threshold,(int)rem.size()); x++){ swap(arr[rem[x].second.first],arr[rem[x].second.second]); int t = query(inv()); if (t<bestv){ best = rem[x].second; bestv = t; } swap(arr[rem[x].second.first],arr[rem[x].second.second]); } swap(arr[best.first],arr[best.second]); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Partially correct | 2 ms | 256 KB | Partially correct |
2 | Partially correct | 0 ms | 256 KB | Partially correct |
3 | Partially correct | 1 ms | 256 KB | Partially correct |
4 | Partially correct | 2 ms | 256 KB | Partially correct |
5 | Partially correct | 1 ms | 256 KB | Partially correct |
6 | Partially correct | 1 ms | 256 KB | Partially correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Partially correct | 2 ms | 256 KB | Partially correct |
2 | Partially correct | 0 ms | 256 KB | Partially correct |
3 | Partially correct | 1 ms | 256 KB | Partially correct |
4 | Partially correct | 2 ms | 256 KB | Partially correct |
5 | Partially correct | 1 ms | 256 KB | Partially correct |
6 | Partially correct | 1 ms | 256 KB | Partially correct |
7 | Execution timed out | 3807 ms | 384 KB | Time limit exceeded (wall clock) |
8 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Partially correct | 2 ms | 256 KB | Partially correct |
2 | Partially correct | 0 ms | 256 KB | Partially correct |
3 | Partially correct | 1 ms | 256 KB | Partially correct |
4 | Partially correct | 2 ms | 256 KB | Partially correct |
5 | Partially correct | 1 ms | 256 KB | Partially correct |
6 | Partially correct | 1 ms | 256 KB | Partially correct |
7 | Execution timed out | 3807 ms | 384 KB | Time limit exceeded (wall clock) |
8 | Halted | 0 ms | 0 KB | - |