Submission #484552

# Submission time Handle Problem Language Result Execution time Memory
484552 2021-11-04T11:52:02 Z MohamedFaresNebili Easter Eggs (info1cup17_eastereggs) C++14
0 / 100
5 ms 492 KB
#include <bits/stdc++.h>
/// #pragma GCC optimize ("Ofast")
/// #pragma GCC target ("avx2")
 
        using namespace std;
 
        using ll  = long long;
        using vi  = vector<int>;
 
        #define pb push_back
        #define ff first
        #define ss second
        #define lb lower_bound
        #define all(x) (x).begin() , (x).end()
 
        #include "grader.h"
 
        vector<int>adj[555], id; int timer, tin[555], out[555];
        void dfs(int v, int p) {
            tin[v] = timer++; id.pb(v);
            for(auto u: adj[v]) {
                if(u == p) continue;
                dfs(u, v);
            }
            out[v] = timer - 1;
        }
 
        int findEgg (int N, vector < pair < int, int > > bridges)
        {
          	for(int l = 1; l <= N; l++) adj[l].clear(); id.clear();
            for(auto u : bridges) {
                int a = u.ff, b = u.ss;
                adj[a].pb(b); adj[b].pb(a);
            }
 
            timer = 0; dfs(1, 1);
            int lo = 0, hi = N - 1;
            for(;;) {
                vector<int>arr;
                for(int l = tin[id[lo]]; l <= out[id[lo]]; l++) arr.pb(id[l]);
                bool ok = query(arr);
                if(ok) {
                    if(tin[id[lo]] == out[id[lo]]) return id[lo];
                    hi = out[id[lo]], lo++;
                }
                else lo = out[id[lo]] + 1;
            }
        }

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:30:12: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   30 |            for(int l = 1; l <= N; l++) adj[l].clear(); id.clear();
      |            ^~~
eastereggs.cpp:30:56: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   30 |            for(int l = 1; l <= N; l++) adj[l].clear(); id.clear();
      |                                                        ^~
eastereggs.cpp:37:25: warning: variable 'hi' set but not used [-Wunused-but-set-variable]
   37 |             int lo = 0, hi = N - 1;
      |                         ^~
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 456 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 464 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 492 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -