結果
| 問題 | No.3400 Nana's Plus Permutation Game (7 + 7) ÷ 7 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-12-12 16:21:20 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,768 bytes |
| 記録 | |
| コンパイル時間 | 3,173 ms |
| コンパイル使用メモリ | 279,024 KB |
| 実行使用メモリ | 105,020 KB |
| 最終ジャッジ日時 | 2025-12-12 16:21:34 |
| 合計ジャッジ時間 | 10,946 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / 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",&res);
| ~~~~~^~~~~~~~~~~~~
main.cpp: In function ‘int main()’:
main.cpp:27:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
27 | scanf("%lld",&t);
| ~~~~~^~~~~~~~~~~
main.cpp:29:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
29 | scanf("%lld",&n);
| ~~~~~^~~~~~~~~~~
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll maxn=20005;
ll p[maxn+5],nxt[maxn+5],deg[maxn+5],ans[maxn+5],bad[maxn+5],pos[maxn+5];
bool ins[maxn+5];
vector<ll> s;
ll ask(ll i,ll j){
printf("1 %lld %lld\n",i,j);
fflush(stdout);
ll res;
scanf("%lld",&res);
return res;
}
void del(ll val){
if(not ins[val])return;
ins[val]=false;
ll idx=pos[val];
ll last=s.back();
s[idx]=last;
pos[last]=idx;
s.pop_back();
}
int main(){
ll t,n,i,j,k,idx1,cur,cnt;
srand(time(0));
scanf("%lld",&t);
while(t--){
scanf("%lld",&n);
s.clear();
for(i=1;i<=n;i++)s.push_back(i),pos[i]=i-1,ins[i]=true,bad[i]=0,nxt[i]=0,deg[i]=0,ans[i]=0;
while(s.size()>1){
i=s[rand()%s.size()];
if(s.size()>2){
j=s[rand()%s.size()];
while(i==j)j=s[rand()%s.size()];
}else{
j=rand()%n+1;
while(i==j)j=rand()%n+1;
}
k=ask(i,j);
if(k==-1){
bad[i]++;
if(ins[j])bad[j]++;
if(bad[i]>=2)del(i);
if(ins[j] and bad[j]>=2)del(j);
}else{
del(k);
}
}
idx1=s[0];
ans[idx1]=1;
for(i=1;i<=n;i++){
if(i==idx1)continue;
k=ask(idx1,i);
if(k!=-1)nxt[i]=k,deg[k]++;
}
cur=-1;
for(i=1;i<=n;i++)if(i!=idx1 and deg[i]==0){cur=i;break;}
cnt=2;
while(cur!=0){
ans[cur]=cnt++;
cur=nxt[cur];
}
printf("2");
for(i=1;i<=n;i++)printf(" %lld",ans[i]);
printf("\n");
fflush(stdout);
}
return 0;
}