# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
48153 | 2018-05-10T10:54:28 Z | antimirage | 도서관 (JOI18_library) | C++14 | 322 ms | 580 KB |
/** Let me ... **/ # include <bits/stdc++.h> # include "library.h" //# include "grader.cpp" #define fr first #define sc second #define mk make_pair #define pb push_back #define sz(s) (int)s.size() #define all(s) s.begin(), s.end() using namespace std; const int N = 1005; pair <int, int> ar[N]; bool used[N]; void Solve(int N) { memset(ar, -1, sizeof(ar)); int n = N; vector <int> vec(n, 0), ans(n, 0); for (int i = 0; i < n; i++) { vec[i] = 1; for (int j = i + 1; j < n; j++) { vec[j] = 1; int res = Query(vec); if (res == 1) { if (ar[i].fr == -1) ar[i].fr = j; else ar[i].sc = j; if (ar[j].fr == -1) ar[j].fr = i; else ar[j].sc = i; } vec[j] = 0; } vec[i] = 0; } for (int i = 0; i < n; i++) { if (ar[i].sc == -1) { ans[0] = i; break; } } used[ ans[0] ] = 1; for (int i = 1; i < n; i++) { if (ar[ ans[i - 1] ].fr && !used[ ar[ ans[i - 1] ].fr ]) { ans[i] = ar[ ans[i - 1] ].fr; used[ ans[i] ] = 1; } else if (ar[ ans[i - 1] ].sc && !used[ ar[ ans[i - 1] ].sc ]) { ans[i] = ar[ ans[i - 1] ].sc; used[ ans[i] ] = 1; } else { // cout << ans[i - 2] << " " << ans[i - 1] << " " << i << endl; // system("pause"); } } for (int i = 0; i < n; i++) ans[i]++; Answer(ans); } /** 9 7 2 1 6 4 8 3 9 5 **/
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 274 ms | 248 KB | Output is correct |
2 | Correct | 255 ms | 436 KB | Output is correct |
3 | Correct | 273 ms | 488 KB | Output is correct |
4 | Correct | 296 ms | 488 KB | Output is correct |
5 | Correct | 301 ms | 504 KB | Output is correct |
6 | Correct | 322 ms | 504 KB | Output is correct |
7 | Correct | 322 ms | 504 KB | Output is correct |
8 | Correct | 299 ms | 504 KB | Output is correct |
9 | Correct | 274 ms | 528 KB | Output is correct |
10 | Correct | 125 ms | 528 KB | Output is correct |
11 | Correct | 1 ms | 528 KB | Output is correct |
12 | Correct | 2 ms | 580 KB | Output is correct |
13 | Incorrect | 2 ms | 580 KB | Wrong Answer [5] |
14 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 274 ms | 248 KB | Output is correct |
2 | Correct | 255 ms | 436 KB | Output is correct |
3 | Correct | 273 ms | 488 KB | Output is correct |
4 | Correct | 296 ms | 488 KB | Output is correct |
5 | Correct | 301 ms | 504 KB | Output is correct |
6 | Correct | 322 ms | 504 KB | Output is correct |
7 | Correct | 322 ms | 504 KB | Output is correct |
8 | Correct | 299 ms | 504 KB | Output is correct |
9 | Correct | 274 ms | 528 KB | Output is correct |
10 | Correct | 125 ms | 528 KB | Output is correct |
11 | Correct | 1 ms | 528 KB | Output is correct |
12 | Correct | 2 ms | 580 KB | Output is correct |
13 | Incorrect | 2 ms | 580 KB | Wrong Answer [5] |
14 | Halted | 0 ms | 0 KB | - |