結果
問題 | No.282 おもりと天秤(2) |
ユーザー | pekempey |
提出日時 | 2015-09-19 09:56:48 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 3,571 ms / 5,000 ms |
コード長 | 1,190 bytes |
コンパイル時間 | 1,355 ms |
コンパイル使用メモリ | 148,792 KB |
実行使用メモリ | 24,324 KB |
平均クエリ数 | 440.67 |
最終ジャッジ日時 | 2023-09-23 21:41:17 |
合計ジャッジ時間 | 15,937 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 29 ms
24,048 KB |
testcase_01 | AC | 38 ms
23,460 KB |
testcase_02 | AC | 28 ms
23,892 KB |
testcase_03 | AC | 26 ms
23,964 KB |
testcase_04 | AC | 25 ms
23,328 KB |
testcase_05 | AC | 28 ms
23,640 KB |
testcase_06 | AC | 43 ms
24,240 KB |
testcase_07 | AC | 26 ms
23,328 KB |
testcase_08 | AC | 44 ms
24,288 KB |
testcase_09 | AC | 26 ms
23,604 KB |
testcase_10 | AC | 886 ms
8,164 KB |
testcase_11 | AC | 3,086 ms
24,324 KB |
testcase_12 | AC | 1,007 ms
24,264 KB |
testcase_13 | AC | 1,494 ms
23,352 KB |
testcase_14 | AC | 2,633 ms
23,568 KB |
testcase_15 | AC | 3,156 ms
23,328 KB |
testcase_16 | AC | 210 ms
23,592 KB |
testcase_17 | AC | 1,391 ms
23,364 KB |
testcase_18 | AC | 2,271 ms
23,772 KB |
testcase_19 | AC | 2,403 ms
23,352 KB |
testcase_20 | AC | 3,460 ms
24,252 KB |
testcase_21 | AC | 3,392 ms
23,580 KB |
testcase_22 | AC | 3,571 ms
23,364 KB |
testcase_23 | AC | 23 ms
23,772 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; vector<int> query(vector<int> a, bool odd) { int n = a.size(); cout << "?"; rep (i, n - 1) { if (i % 2 == odd) { cout << " " << a[i] << " " << a[i + 1]; } else { cout << " 0 0"; } } cout << " 0 0" << endl; vector<int> res; rep (i, n) { string s; cin >> s; if (s[0] == '=') res.push_back(0); else if (s[0] == '<') res.push_back(-1); else res.push_back(1); } return res; } int main() { int n; cin >> n; vector<int> a(n); rep (i, n) a[i] = i + 1; rep (i, n) { auto even = query(a, false); for (int i = 0; i + 1 < n; i += 2) { if (even[i] > 0) swap(a[i], a[i + 1]); } auto odd = query(a, true); for (int i = 1; i + 1 < n; i += 2) { if (odd[i] > 0) swap(a[i], a[i + 1]); } } cout << "!"; rep (i, n) cout << " " << a[i]; cout << endl; return 0; }