結果
| 問題 |
No.2085 Directed Complete Graph
|
| ユーザー |
|
| 提出日時 | 2024-10-31 03:32:20 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 159 ms / 2,000 ms |
| コード長 | 1,588 bytes |
| コンパイル時間 | 5,490 ms |
| コンパイル使用メモリ | 315,244 KB |
| 実行使用メモリ | 25,452 KB |
| 平均クエリ数 | 2472.00 |
| 最終ジャッジ日時 | 2024-10-31 03:32:29 |
| 合計ジャッジ時間 | 9,145 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 15 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using mint = atcoder::static_modint<998244353>;
//using mint = atcoder::static_modint<1000000007>;
using namespace std;
using namespace atcoder;
using ld = long double;
using ll = long long;
#define mp(a,b) make_pair(a,b)
#define rep(i,s,n) for(int i=s; i<n; i++)
const vector<int> dx{1,0,-1,0},dy{0,1,0,-1};
deque<int> solve(deque<int>p){
int n=p.size();
if(n==1)return p;
int h=n/2;
deque<int> a,b;
rep(i,0,h)a.push_back(p.front()),p.pop_front();
while(p.size()){
b.push_back(p.front());
p.pop_front();
}
a=solve(a);
b=solve(b);
int t;
// cout << "? " << a.back() << " " << b.front() << "\n";
// cin >> t;
// if(t==1){
// for(auto x:b)a.push_back(x);
// return a;
// }
// cout << "? " << b.back() << " " << a.front() << "\n";
// cin >> t;
// if(t==1){
// for(auto x:a)b.push_back(x);
// return b;
// }
p.clear();
while(a.size()*b.size()){
int u=a.front(),v=b.front();
cout << "? " << u << " " << v << "\n";
cin >> t;
if(t==1){
a.pop_front();
p.push_back(u);
}
else{
b.pop_front();
p.push_back(v);
}
}
while(a.size())p.push_back(a.front()),a.pop_front();
while(b.size())p.push_back(b.front()),b.pop_front();
return p;
}
int main(){
int n;cin >> n;
deque<int> a(n);
iota(a.begin(),a.end(),1);
a=solve(a);
cout << "!\n" << n-1 << "\n";
for(auto x:a)cout << x << " ";
}