結果
問題 | No.282 おもりと天秤(2) |
ユーザー | Kmcode1 |
提出日時 | 2015-09-18 23:04:51 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 1,443 ms / 5,000 ms |
コード長 | 2,097 bytes |
コンパイル時間 | 3,376 ms |
コンパイル使用メモリ | 113,412 KB |
実行使用メモリ | 31,824 KB |
平均クエリ数 | 267.12 |
最終ジャッジ日時 | 2023-09-23 21:30:43 |
合計ジャッジ時間 | 16,693 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 27 ms
24,072 KB |
testcase_01 | AC | 30 ms
23,712 KB |
testcase_02 | AC | 26 ms
23,592 KB |
testcase_03 | AC | 24 ms
24,060 KB |
testcase_04 | AC | 24 ms
23,676 KB |
testcase_05 | AC | 29 ms
23,424 KB |
testcase_06 | AC | 31 ms
24,312 KB |
testcase_07 | AC | 25 ms
24,096 KB |
testcase_08 | AC | 32 ms
24,396 KB |
testcase_09 | AC | 23 ms
24,336 KB |
testcase_10 | AC | 297 ms
23,700 KB |
testcase_11 | AC | 1,200 ms
29,928 KB |
testcase_12 | AC | 682 ms
23,472 KB |
testcase_13 | AC | 850 ms
24,656 KB |
testcase_14 | AC | 1,058 ms
28,356 KB |
testcase_15 | AC | 1,213 ms
30,504 KB |
testcase_16 | AC | 97 ms
24,060 KB |
testcase_17 | AC | 837 ms
24,644 KB |
testcase_18 | AC | 1,012 ms
27,332 KB |
testcase_19 | AC | 987 ms
27,972 KB |
testcase_20 | AC | 1,267 ms
31,336 KB |
testcase_21 | AC | 1,425 ms
31,536 KB |
testcase_22 | AC | 1,443 ms
31,824 KB |
testcase_23 | AC | 27 ms
24,312 KB |
ソースコード
#include<iostream> #include<cstdio> #include<cstring> #include<string> #include<cctype> #include<cstdlib> #include<algorithm> #include<bitset> #include<vector> #include<list> #include<deque> #include<queue> #include<map> #include<set> #include<stack> #include<cmath> #include<sstream> #include<fstream> #include<iomanip> #include<ctime> #include<complex> #include<functional> #include<climits> #include<cassert> #include<iterator> #include<unordered_map> #include<unordered_set> //#include<quadmath.h> using namespace std; vector<int> v; int n; #define MAX 502 bool cm[MAX][MAX]; set<int> s[MAX]; void output(vector<pair<int,int> > v){ printf("?"); for (int i = 0; i < v.size(); i++){ printf(" %d %d", v[i].first, v[i].second); } for (int i = v.size(); i < n; i++){ printf(" %d %d", 0, 0); } puts(""); fflush(stdout); fflush(stdin); char ss[3]; for (int i = 0; i < v.size(); i++){ scanf("%s", ss); if (ss[0] == '<'){ cm[v[i].first][v[i].second] = true; } else{ cm[v[i].second][v[i].first] = true; } s[v[i].first].erase(v[i].second); s[v[i].second].erase(v[i].first); } for (int i = v.size(); i < n; i++){ scanf("%s", ss); } fflush(stdin); fflush(stdout); } bool cmp(int a, int b){ return cm[a][b]; } int main(){ scanf("%d", &n); for (int i = 1; i <= n; i++){ v.push_back(i); } int summ = 0; for (int i = 1; i <= n; i++){ for (int j = 1; j <= n; j++){ if (i == j){ continue; } s[i].insert(j); summ++; } } int countt = 0; while (countt < summ){ set<int> used; used.clear(); vector<pair<int, int> > v; for (int i = 1; i <= n; i++){ if (used.count(i)){ continue; } set<int>::iterator ite; for (ite = s[i].begin(); ite != s[i].end(); ite++){ if (used.count(*ite)){ } else{ v.push_back(make_pair(i,(*ite))); used.insert(i); used.insert((*ite)); break; } } } countt += v.size() * 2; output(v); } sort(v.begin(), v.end(), cmp); printf("!"); for (int i = 0; i < v.size(); i++){ printf(" %d", v[i]); } puts(""); fflush(stdout); fflush(stdin); return 0; }