Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define nl "\n"
- void files(){
- ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
- #endif
- }
- void solve(){
- int n; cin>>n;
- int s; cin>>s;
- vector<bool> vis(n+1, false);
- queue<int> q;
- vis[s] = true;
- int k; cin>>k;
- for(int i = 0; i < k; i++){
- int x; cin>>x;
- }
- q.push(s);
- vis[s] = true;
- while(!q.empty()){
- int x = q.front();
- q.pop();
- cout<<"> "<<x<<endl;
- cout.flush();
- cin>>k;
- if(k <= 0) return;
- for(int i = 0; i < k; i++){
- int y; cin>>y;
- if(!vis[y]){
- vis[y] = true;
- q.push(y);
- }
- }
- }
- }
- int main(){
- files();
- int t = 1;
- // cin>>t;
- while(t--) solve();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement