# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
571360 | 2022-06-02T00:50:29 Z | Deepesson | Easter Eggs (info1cup17_eastereggs) | C++17 | 46 ms | 464 KB |
#include<bits/stdc++.h> #include "grader.h" #define MAX 600 using namespace std; int findEgg(int N, vector < pair < int, int > > bridges); int query(vector < int > islands); std::vector<int> con[MAX]; std::map<int,bool> candidatos; std::vector<int> buscar; int counta=0,obj; void dfs(int pos,int prev){ // std::cout<<"Explora "<<pos<<" "<<prev<<" "<<obj<<"\n"; buscar.push_back(pos); if(candidatos.find(pos)!=candidatos.end()){ ++counta; } if(counta==obj)return; for(auto&x:con[pos]){ if(x==prev)continue; if(counta==obj)return; dfs(x,pos); } } int findEgg (int N, vector < pair < int, int > > bridges) { for(int i=0;i!=N+20;++i)con[i].clear(); // std::cout<<"Lesgo\n"; for(int i=1;i!=N+1;++i){ candidatos[i]=1; if(i!=1){ // std::cout<<bridges[i-2].first<<" "<<bridges[i-2].second<<"\n"; con[bridges[i-2].first].push_back(bridges[i-2].second); con[bridges[i-2].second].push_back(bridges[i-2].first); } } // std::cout<<"key\n"; while(candidatos.size()!=1){ obj=candidatos.size()/2; buscar.clear();counta=0; dfs(1,-1); // std::cout<<"busca "<<buscar.size()<<"\n"; //for(auto&x:buscar)std::cout<<x<<" ";std::cout<<"\n"; bool val = query(buscar); if(!val){ for(auto&x:buscar){ auto tem = candidatos.find(x); if(tem!=candidatos.end())candidatos.erase(tem); } }else { std::map<int,bool> obrigatorio; for(auto&x:buscar)obrigatorio[x]=true; std::vector<int> fora; for(auto&x:candidatos)if(!obrigatorio[x.first])fora.push_back(x.first); for(auto&x:fora){ auto tem = candidatos.find(x); if(tem!=candidatos.end())candidatos.erase(tem); } } } int val; for(auto&x:candidatos)val=x.first; return val; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 208 KB | Number of queries: 4 |
2 | Correct | 1 ms | 208 KB | Number of queries: 4 |
3 | Correct | 1 ms | 208 KB | Number of queries: 4 |
4 | Correct | 1 ms | 208 KB | Number of queries: 4 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 464 KB | Number of queries: 8 |
2 | Correct | 24 ms | 392 KB | Number of queries: 9 |
3 | Correct | 39 ms | 404 KB | Number of queries: 9 |
4 | Correct | 34 ms | 400 KB | Number of queries: 9 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 46 ms | 408 KB | Number of queries: 9 |
2 | Correct | 42 ms | 396 KB | Number of queries: 9 |
3 | Correct | 36 ms | 400 KB | Number of queries: 9 |
4 | Correct | 33 ms | 392 KB | Number of queries: 9 |