# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
525622 | 2022-02-12T06:57:43 Z | tudor | Easter Eggs (info1cup17_eastereggs) | C++17 | 20 ms | 356 KB |
#include <iostream> #include <vector> #include "grader.h" using namespace std; const int nmax = 512; int n; vector < pair < int, int > > bridges; vector < int > g[nmax + 1]; vector < int > ord; vector < int > q; void dfs ( int node, int parent ) { ord.push_back ( node ); for ( int i = 0; i < g[node].size (); i++ ) if ( g[node][i] != parent ) dfs ( g[node][i], node ); } /** int query ( vector < int > islands ) { int r; cin >> r; return r; } **/ int findEgg ( int n, vector < pair < int, int > > bridges ) { ord.clear (); for ( int i = 1; i <= n; i++ ) g[i].clear (); for ( int i = 0; i < n - 1; i++ ) { g[bridges[i].first].push_back ( bridges[i].second ); g[bridges[i].second].push_back ( bridges[i].first ); } dfs ( 1, 0 ); int st = 0, dr = n - 2, mij, poz = n - 1; while ( st <= dr ) { int mij = st + ( dr - st ) / 2; q.clear (); for ( int i = 0; i <= mij; i++ ) q.push_back ( ord[i] ); if ( query ( q ) == 1 ) dr = mij - 1, poz = mij; else st = mij + 1; } return ord[poz]; } /* int main() { cin >> n; bridges.resize ( n ); for ( int i = 0; i < n - 1; i++ ) cin >> bridges[i].first >> bridges[i].second; cout << findEgg ( n, bridges ); return 0; } */
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 200 KB | Number of queries: 4 |
2 | Correct | 1 ms | 200 KB | Number of queries: 4 |
3 | Correct | 1 ms | 200 KB | Number of queries: 4 |
4 | Correct | 1 ms | 200 KB | Number of queries: 4 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 336 KB | Number of queries: 8 |
2 | Correct | 12 ms | 344 KB | Number of queries: 9 |
3 | Correct | 18 ms | 348 KB | Number of queries: 9 |
4 | Correct | 20 ms | 340 KB | Number of queries: 9 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 356 KB | Number of queries: 9 |
2 | Correct | 17 ms | 336 KB | Number of queries: 9 |
3 | Correct | 16 ms | 340 KB | Number of queries: 9 |
4 | Correct | 17 ms | 348 KB | Number of queries: 9 |