結果
問題 |
No.282 おもりと天秤(2)
|
ユーザー |
![]() |
提出日時 | 2016-01-20 04:51:25 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,609 bytes |
コンパイル時間 | 682 ms |
コンパイル使用メモリ | 61,612 KB |
実行使用メモリ | 25,604 KB |
平均クエリ数 | 32.25 |
最終ジャッジ日時 | 2024-07-16 08:32:22 |
合計ジャッジ時間 | 9,865 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 1 WA * 10 TLE * 1 -- * 12 |
ソースコード
#include <iostream> #include <string> using namespace std; int main(void) { int a[500]; bool b[500][500] = {0}; int c[500] = {0}; int buf[500]; int n; cin >> n; for(int i = 0; i < n; i++) a[i] = i + 1; int offset = 0; int count = 0; int nn = n * (n - 1) / 2; while(count < nn) { bool t[500] = {0}; string str = "?"; int sc = 0; for(int i = 0; i < n; i++) { int j = (i + offset + 1) % n; if(t[i] || t[j] || b[i][j] || b[j][i]) continue; str += " " + to_string(i + 1) + " " + to_string(j + 1); buf[sc * 2] = i; buf[sc * 2 + 1] = j; count++; sc++; t[i] = t[j] = b[i][j] = b[j][i] = true; } offset = (offset + 1) % (n - 1); if(sc == 0) continue; for(int i = sc; i < n; i++) str += " 0 0"; //continue; cout << str << endl; cout.flush(); string s; cin >> s; for(int i = 0; i < sc; i++) { if(s[i * 2] == '<') c[buf[i * 2 + 1]]++; else c[buf[i * 2]]++; } } string res = "!"; for(int i = 0; i < n; i++) { int m = c[i]; int k = i; for(int j = i + 1; j < n; j++) { if(c[j] < m) { m = c[j]; k = j; } } res += " " + to_string(a[k]); swap(c[i], c[k]); swap(a[i], a[k]); } cout << res << endl; cout.flush(); return 0; }