結果
問題 | No.282 おもりと天秤(2) |
ユーザー | t98slider |
提出日時 | 2023-02-23 19:25:18 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 3,061 ms / 5,000 ms |
コード長 | 2,153 bytes |
コンパイル時間 | 2,151 ms |
コンパイル使用メモリ | 186,272 KB |
実行使用メモリ | 24,336 KB |
平均クエリ数 | 455.46 |
最終ジャッジ日時 | 2023-09-30 19:55:16 |
合計ジャッジ時間 | 32,082 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 22 ms
23,976 KB |
testcase_01 | AC | 38 ms
23,640 KB |
testcase_02 | AC | 27 ms
23,532 KB |
testcase_03 | AC | 25 ms
24,000 KB |
testcase_04 | AC | 24 ms
24,264 KB |
testcase_05 | AC | 34 ms
23,712 KB |
testcase_06 | AC | 39 ms
23,424 KB |
testcase_07 | AC | 24 ms
23,976 KB |
testcase_08 | AC | 41 ms
23,640 KB |
testcase_09 | AC | 22 ms
23,820 KB |
testcase_10 | AC | 791 ms
24,276 KB |
testcase_11 | AC | 2,894 ms
23,400 KB |
testcase_12 | AC | 1,284 ms
23,544 KB |
testcase_13 | AC | 1,665 ms
23,616 KB |
testcase_14 | AC | 2,495 ms
23,376 KB |
testcase_15 | AC | 2,935 ms
24,036 KB |
testcase_16 | AC | 196 ms
23,376 KB |
testcase_17 | AC | 1,611 ms
23,376 KB |
testcase_18 | AC | 2,296 ms
24,336 KB |
testcase_19 | AC | 2,280 ms
24,024 KB |
testcase_20 | AC | 3,021 ms
23,532 KB |
testcase_21 | AC | 3,061 ms
23,628 KB |
testcase_22 | AC | 1,556 ms
23,808 KB |
testcase_23 | AC | 22 ms
23,628 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<deque<int>> tb(n); for(int i = 0; i < n; i++) tb[i].push_back(i); while(tb.size() >= 2){ vector<deque<int>> nxt((tb.size() + 1) / 2); if(tb.size() & 1) nxt.back() = tb.back(); bool flag = true; while(flag){ flag = false; vector<int> query(2 * n); for(int i = 0; i + 1 < tb.size(); i += 2){ if(tb[i].empty() || tb[i + 1].empty()){ int to = i / 2; nxt[to].insert(nxt[to].end(), tb[i].begin(), tb[i].end()); nxt[to].insert(nxt[to].end(), tb[i + 1].begin(), tb[i + 1].end()); tb[i].clear(); tb[i + 1].clear(); continue; } flag = true; query[i] = tb[i].front() + 1; query[i + 1] = tb[i + 1].front() + 1; } if(!flag) break; cout << "?"; for(int i = 0; i < 2 * n; i++) cout << " " << query[i]; cout << endl; char c; int cnt = n; for(int i = 0; i + 1 < tb.size(); i += 2){ cin >> c; cnt--; if(tb[i].empty() || tb[i + 1].empty())continue; int to = i / 2; if(c == '='){ nxt[to].push_back(tb[i].front()); nxt[to].push_back(tb[i + 1].front()); tb[i].pop_front(); tb[i + 1].pop_front(); }else if(c == '<'){ nxt[to].push_back(tb[i].front()); tb[i].pop_front(); }else{ nxt[to].push_back(tb[i + 1].front()); tb[i + 1].pop_front(); } } while(cnt--) cin >> c; } swap(tb, nxt); } cout << "!"; for(int i = 0; i < tb[0].size(); i++){ cout << " " << tb[0][i] + 1; } cout << endl; }