Submission #384477

# Submission time Handle Problem Language Result Execution time Memory
384477 2021-04-01T17:46:35 Z ak2006 Easter Eggs (info1cup17_eastereggs) C++14
0 / 100
2 ms 492 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;

#define pb push_back
using vi = vector<int>;
using vvi = vector<vi>;
vvi adj(513);
vi a;
void dfs(int i,int p)
{
    a.pb(i);
    for (int c:adj[i]){
        if (c != p)
            dfs(c,i);
    }
}
int findEgg(int n,vector<pair<int,int>>b)
{
    for (int i = 0;i<=512;i++)adj[i].clear();
    a.clear();
    for (int i = 0;i<b.size();i++)adj[b[i].first].pb(b[i].second);
    dfs(1,1);
    int l = 0,r = n - 1;
    while (l < r){
        int mid = (l + r + 1)/2;
        if (query(vector<int>(a.begin(),a.begin() + mid))){
            r = mid - 1;
        }
        else l = mid;
    }
    return a[l];
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:22:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for (int i = 0;i<b.size();i++)adj[b[i].first].pb(b[i].second);
      |                    ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 492 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 492 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 492 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -