結果
問題 | No.2577 Simple Permutation Guess |
ユーザー |
|
提出日時 | 2023-12-05 00:32:09 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 847 bytes |
コンパイル時間 | 2,284 ms |
コンパイル使用メモリ | 196,472 KB |
最終ジャッジ日時 | 2025-02-18 07:30:56 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | TLE * 1 |
other | -- * 111 |
ソースコード
#include <bits/stdc++.h>using namespace std;template<class T> ostream& operator << (ostream& os, const vector<T>& vec) {if(vec.empty()) return os;os << vec[0];for(auto it = vec.begin(); ++it != vec.end(); ) os << ' ' << *it;return os;}int main(){ios::sync_with_stdio(false);cin.tie(0);int n;cin >> n;vector<int> ans, S(n);ans.reserve(n);iota(S.begin(), S.end(), 1);for(int i = 0; i < n; i++){int ok = 0, ng = S.size(), mid, v;while(ok + 1 < ng){mid = (ok + ng) / 2;cout << "? " << ans << ' ' << S[mid] << endl;cin >> v;(v ? ok : ng) = mid;}ans.push_back(S[ok]);for(int j = ok; j + 1 < S.size(); j++) swap(S[j], S[j + 1]);S.pop_back();}cout << "! " << ans << endl;}