結果
| 問題 | No.3400 Nana's Plus Permutation Game (7 + 7) ÷ 7 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-12-12 16:26:51 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,809 bytes |
| 記録 | |
| コンパイル時間 | 3,054 ms |
| コンパイル使用メモリ | 283,488 KB |
| 実行使用メモリ | 118,040 KB |
| 最終ジャッジ日時 | 2025-12-12 16:27:02 |
| 合計ジャッジ時間 | 11,381 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | TLE * 1 -- * 76 |
コンパイルメッセージ
main.cpp: In function ‘long long int ask(long long int, long long int)’:
main.cpp:12:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
12 | scanf("%lld",&zc);
| ~~~~~^~~~~~~~~~~~
main.cpp: In function ‘int main()’:
main.cpp:26:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
26 | scanf("%lld",&t);
| ~~~~~^~~~~~~~~~~
main.cpp:28:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
28 | scanf("%lld",&n);
| ~~~~~^~~~~~~~~~~
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll maxn=20005;
ll pos[maxn+5],bad[maxn+5],nxt[maxn+5],ans[maxn+5];
bool ins[maxn+5];
vector<ll> s;set<ll> h;
ll ask(ll i,ll j){
printf("1 %lld %lld\n",i,j);
fflush(stdout);
ll zc;
scanf("%lld",&zc);
return zc;
}
void del(ll v){
if(!ins[v])return;
ins[v]=0;
ll zc1=pos[v],zc2=s.back();
s[zc1]=zc2;
pos[zc2]=zc1;
s.pop_back();
}
int main(){
ll t,n,i,j,k,cnt,zc,cur;
srand(time(0));
scanf("%lld",&t);
while(t--){
scanf("%lld",&n);
s.clear();h.clear();
for(i=1;i<=n;i++)s.push_back(i),pos[i]=i-1,ins[i]=1,bad[i]=0,nxt[i]=0,ans[i]=0;
while(s.size()>1){
cnt=0;
do{
i=s[rand()%s.size()];
j=s[rand()%s.size()];
while(i==j)j=s[rand()%s.size()];
if(i>j)swap(i,j);
zc=i*maxn+j;
cnt++;
}while(h.count(zc)&&cnt<50);
if(h.count(zc))break;
h.insert(zc);
k=ask(i,j);
if(k!=-1)del(k);
else{
bad[i]++;bad[j]++;
if(bad[i]>=2)del(i);
if(bad[j]>=2)del(j);
}
}
if(s.size()==2){
i=s[0];j=s[1];
k=1;while(ins[k])k++;
zc=ask(i,k);
if(zc==-1)cur=j;else cur=i;
}else cur=s[0];
ans[cur]=1;
for(i=1;i<=n;i++){
if(i==cur)continue;
k=ask(cur,i);
if(k!=-1)nxt[i]=k;
}
for(j=1;j<n;j++){
cur=nxt[cur];
ans[cur]=j+1;
}
printf("2");
for(i=1;i<=n;i++)printf(" %lld",ans[i]);
printf("\n");
fflush(stdout);
}
return 0;
}