結果
問題 | No.1959 Prefix MinMax |
ユーザー |
![]() |
提出日時 | 2022-05-27 22:30:51 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 40 ms / 2,000 ms |
コード長 | 940 bytes |
コンパイル時間 | 1,895 ms |
コンパイル使用メモリ | 196,700 KB |
最終ジャッジ日時 | 2025-01-29 16:07:42 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 31 |
ソースコード
#include <bits/stdc++.h>using namespace std;using Int = long long;const char newl = '\n';template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}template<typename T=Int>vector<T> read(size_t n){vector<T> ts(n);for(size_t i=0;i<n;i++) cin>>ts[i];return ts;}//INSERT ABOVE HEREvoid solve(){Int n;cin>>n;vector<Int> ps(n,-1);Int cnt=0;while(true){cout<<"?";for(Int i=1;i<n;i++) cout<<' '<<((i+cnt)&1);cout<<endl;cnt++;auto bs=read(n);ps[0]=bs[0];for(Int i=1;i<n;i++)if(bs[i-1]!=bs[i]) ps[i]=bs[i];if(*min_element(ps.begin(),ps.end())>0) break;}cout<<"!";for(Int i=0;i<n;i++) cout<<' '<<ps[i];cout<<endl;}signed main(){Int T;cin>>T;while(T--) solve();return 0;}