QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#797033#8056. Travel 2kircoRE 0ms0kbC++231.8kb2024-12-02 14:45:132024-12-02 14:45:14

Judging History

你现在查看的是最新测评结果

  • [2024-12-02 14:45:14]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-12-02 14:45:13]
  • 提交

answer

#include<bits/stdc++.h>
#define iosy ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define int long long
using namespace std;
const int N = 3000;
bool vis[N];
int n,g[N][N],e[N][N];

void dfs(int u,int du){
    n=max(n,u);
    for(int i=1;i<=du;i++){
        if(!g[u][i]){
            cout<<"> "<<i<<endl;
            int v,dv;cin>>v>>dv;
            g[u][i]=v;
            e[u][v]=i;
            dfs(v,dv);
        }
    }
    // if(!vis[u]){
    //     vis[u]=1;
    //     for(int i=1;i<=du;i++){
    //         if(!vis[g[u][i]]){
    //             cout<<"> "<<i<<endl;
    //             int v,dv;cin>>v>>dv;    
    //             dfs(v,dv);
    //             cout<<"> "<<e[v][u]<<endl;
    //             int sb,da_sb;cin>>sb>>da_sb;
    //         }
    //     }
    // }
}

void dfs2(int u,int du){
    if(!vis[u]){
        vis[u]=1;
        for(int i=1;i<=du;i++){
            if(!vis[g[u][i]]){
                cout<<"> "<<i<<endl;
                int v,dv;cin>>v>>dv;    
                dfs(v,dv);
                cout<<"> "<<e[v][u]<<endl;
                int sb,da_sb;cin>>sb>>da_sb;
            }
        }
    }
}

void solve(){
	int x,dx;cin>>x>>dx;
    n=0;
    dfs(x,dx);
    dfs2(x,dx);
    vector<pair<int,int>> ans;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(e[i][j])ans.emplace_back(i,j);
        }
    }
    cout<<"!";
    for(int i=0;i<ans.size();i++){
        cout<<" "<<ans[i].first<<" "<<ans[i].second;
    }
    cout<<endl;
    string s;cin>>s;
    for(int i=0;i<=n+5;i++){
        vis[i]=0;
        for(int j=0;j<=n+5;j++){
            g[i][j]=0;
            e[i][j]=0;
        }
    }
}

signed main(){ 
	iosy;int _=1;
	cin>>_;
	while(_--){solve();}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

2
1 1
2 1
1 1
2 1
1 1
Correct
1 3
2 2
1 3
3 1
1 3
4 2
1 3
3 1

output:

> 1
> 1
> 1
> 1
! 1 2
> 1
> 1
> 2
> 1
> 3
> 1
> 2
> 2

result: