結果
| 問題 | No.282 おもりと天秤(2) |
| コンテスト | |
| ユーザー |
Shibuyap
|
| 提出日時 | 2020-07-04 17:29:54 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4,152 ms / 5,000 ms |
| コード長 | 2,088 bytes |
| コンパイル時間 | 2,201 ms |
| コンパイル使用メモリ | 203,596 KB |
| 最終ジャッジ日時 | 2025-01-11 15:40:47 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 24 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005
int main() {
int n;
cin >> n;
if(n == 1){
cout << "! 1" << endl;
return 0;
}
if(n == 2){
cout << "? 1 2 0 0" << endl;
fflush(stdout);
char c;
cin >> c;
if(c == '>'){
cin >> c;
cout << "! 2 1" << endl;
}else{
cin >> c;
cout << "! 1 2" << endl;
}
return 0;
}
int nn = n;
int odd = 0;
if(n % 2 == 1){
odd = 1;
n++;
}
int f[n+1][n+1];
rep(i,n+1){
rep(j,n+1){
f[i][j] = 0;
}
}
int a[1000] = {}, b[1000] = {};
rep(i,n/2){
a[i] = i+1;
b[i] = n-i;
}
rep(_,1000){
int x[2000] = {};
rep(i,n/2){
x[i*2] = a[i];
x[i*2+1] = b[i];
if(x[i*2] == n && odd == 1) x[i*2] = 0;
if(x[i*2+1] == n && odd == 1) x[i*2+1] = 0;
}
cout << '?';
rep(i,nn*2)cout << ' ' << x[i];
cout << endl;
fflush(stdout);
rep(i,nn){
char c;
cin >> c;
if(c == '<'){
f[x[i*2]][x[i*2+1]] = 1;
}
if(c == '>'){
f[x[i*2+1]][x[i*2]] = 1;
}
}
int keep = a[n/2-1];
drep(i,n/2){
if(i == 0)break;
a[i] = a[i-1];
}
a[1] = b[0];
rep(i,n/2){
b[i] = b[i+1];
}
b[n/2-1] = keep;
}
vector<P> v;
srep(i,1,nn+1){
int cnt = 0;
srep(j,1,nn+1)cnt += f[i][j];
v.push_back(P(-cnt,i));
}
sort(v.begin(), v.end());
cout << '!';
rep(i,v.size()){
cout << ' ' << v[i].second;
}
cout << endl;
return 0;
}
Shibuyap