結果
| 問題 | No.282 おもりと天秤(2) |
| コンテスト | |
| ユーザー |
小指が強い人
|
| 提出日時 | 2016-01-20 05:24:54 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2,672 ms / 5,000 ms |
| コード長 | 1,709 bytes |
| 記録 | |
| コンパイル時間 | 701 ms |
| コンパイル使用メモリ | 62,052 KB |
| 実行使用メモリ | 25,452 KB |
| 平均クエリ数 | 326.96 |
| 最終ジャッジ日時 | 2024-07-16 22:53:05 |
| 合計ジャッジ時間 | 24,856 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 24 |
ソースコード
#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";
cout << str << endl;
cout.flush();
//continue;
for(int i = 0; i < sc; i++) {
string s;
cin >> s;
if(s[0] == '<')
c[buf[i * 2 + 1]]++;
else
c[buf[i * 2]]++;
}
for(int i = sc; i < n; i++) {
string tmp;
cin >> tmp;
}
}
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;
}
小指が強い人