結果
問題 | No.282 おもりと天秤(2) |
ユーザー | pekempey |
提出日時 | 2015-09-19 00:17:02 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 2,001 ms / 5,000 ms |
コード長 | 1,987 bytes |
コンパイル時間 | 1,710 ms |
コンパイル使用メモリ | 154,680 KB |
実行使用メモリ | 24,372 KB |
平均クエリ数 | 267.12 |
最終ジャッジ日時 | 2023-09-23 21:34:21 |
合計ジャッジ時間 | 23,842 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 26 ms
24,288 KB |
testcase_01 | AC | 32 ms
24,084 KB |
testcase_02 | AC | 26 ms
24,372 KB |
testcase_03 | AC | 27 ms
23,448 KB |
testcase_04 | AC | 26 ms
23,448 KB |
testcase_05 | AC | 30 ms
23,868 KB |
testcase_06 | AC | 31 ms
24,036 KB |
testcase_07 | AC | 26 ms
23,412 KB |
testcase_08 | AC | 33 ms
23,652 KB |
testcase_09 | AC | 25 ms
23,484 KB |
testcase_10 | AC | 495 ms
23,904 KB |
testcase_11 | AC | 1,858 ms
24,336 KB |
testcase_12 | AC | 988 ms
23,712 KB |
testcase_13 | AC | 1,292 ms
23,568 KB |
testcase_14 | AC | 1,726 ms
23,484 KB |
testcase_15 | AC | 1,917 ms
23,496 KB |
testcase_16 | AC | 122 ms
24,300 KB |
testcase_17 | AC | 1,190 ms
23,568 KB |
testcase_18 | AC | 1,548 ms
24,024 KB |
testcase_19 | AC | 1,612 ms
23,424 KB |
testcase_20 | AC | 1,967 ms
24,036 KB |
testcase_21 | AC | 1,945 ms
23,856 KB |
testcase_22 | AC | 2,001 ms
24,288 KB |
testcase_23 | AC | 27 ms
23,868 KB |
ソースコード
#include <bits/stdc++.h> #define rep(i, a) rep2 (i, 0, a) #define rep2(i, a, b) for (int i = (a); i < (b); i++) #define repr(i, a) repr2 (i, 0, a) #define repr2(i, a, b) for (int i = (b) - 1; i >= (a); i--) #define chmin(a, b) ((b) < a && (a = (b), true)) #define chmax(a, b) (a < (b) && (a = (b), true)) #define rng(a) (a).begin(), (a).end() using namespace std; typedef long long ll; #include <bits/stdc++.h> #define rep(i, a) rep2 (i, 0, a) #define rep2(i, a, b) for (int i = (a); i < (b); i++) #define repr(i, a) repr2 (i, 0, a) #define repr2(i, a, b) for (int i = (b) - 1; i >= (a); i--) #define chmin(a, b) ((b) < a && (a = (b), true)) #define chmax(a, b) (a < (b) && (a = (b), true)) #define rng(a) (a).begin(), (a).end() using namespace std; typedef long long ll; int n; int C[555][555]; int a[555]; void query(vector<pair<int, int>> v) { v.resize(n, make_pair(-1, -1)); cout << "?"; rep (i, v.size()) cout << " " << v[i].first + 1 << " " << v[i].second + 1; cout << endl; rep (i, n) { string str; cin >> str; if (v[i].first == -1) continue; int a = v[i].first; int b = v[i].second; int c; if (str[0] == '<') { c = -1; } else if (str[0] == '>') { c = 1; } else { c = 0; } C[a][b] = c; C[b][a] = -c; } } bool checked[555][555]; int main() { cin >> n; rep (i, n) a[i] = i; vector<bool> used(n); int num = 0; while (num < n * (n - 1) / 2) { fill(rng(used), false); vector<pair<int, int>> q; rep (i, n) { rep2 (j, i + 1, n) { if (!checked[i][j] && !used[i] && !used[j]) { q.emplace_back(i, j); checked[i][j] = true; num++; used[i] = true; used[j] = true; } if (q.size() == n) break; } if (q.size() == n) break; } query(q); } rep (i, n) { rep2 (j, i, n) { if (C[a[i]][a[j]] > 0) swap(a[i], a[j]); } } cout << "!"; rep (i, n) cout << " " << a[i] + 1; cout << endl; return 0; }