답안 #498724

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
498724 2021-12-26T09:09:11 Z ahmedfouadnew Easter Eggs (info1cup17_eastereggs) C++17
66 / 100
27 ms 368 KB
#include <bits/stdc++.h>
#include "grader.h"
//#include "grader.cpp"
#define pb push_back
#define f first
#define s second
using namespace std;
vector<int>adj[606];
int n;
vector<int>vv;
void dfs(int u,int p)
{
    vv.pb(u);
    for(int v:adj[u])
    {
        if(v==p) continue;
        vv.pb(u);
        dfs(v,u);
    }
    vv.pb(u);
}
int findEgg (int N, vector < pair < int, int > > bridges)
{
    for(int i=0;i<=N;i++)
    {
        adj[i].clear();
    }
    vv.clear();
    n=N;
    for(int i=0;i<bridges.size();i++)
    {
        adj[bridges[i].f].pb(bridges[i].s);
        adj[bridges[i].s].pb(bridges[i].f);
    }
    dfs(1,0);
    int s=0,e=vv.size()-1;
    while(s<e)
    {

        set<int>st;
        for(int ii=s;ii<=e;ii++) st.insert(vv[ii]);
        int sz=st.size()/2;
        st.clear();
        int mid=s;
        while(st.size()!=sz)
        {
            st.insert(vv[mid]);
            mid++;
        }
        mid--;
        vector<int>qr(st.begin(),st.end());
        if(query(qr))
        {
            e=mid;
        }
        else
        {
            s=mid+1;
        }
    }
    return vv[s];
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:30:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for(int i=0;i<bridges.size();i++)
      |                 ~^~~~~~~~~~~~~~~
eastereggs.cpp:45:24: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   45 |         while(st.size()!=sz)
      |               ~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Partially correct 2 ms 200 KB Number of queries: 8
2 Partially correct 2 ms 200 KB Number of queries: 7
3 Partially correct 2 ms 200 KB Number of queries: 8
4 Partially correct 1 ms 200 KB Number of queries: 8
# 결과 실행 시간 메모리 Grader output
1 Partially correct 10 ms 328 KB Number of queries: 13
2 Partially correct 19 ms 328 KB Number of queries: 14
3 Partially correct 23 ms 368 KB Number of queries: 14
4 Partially correct 19 ms 328 KB Number of queries: 14
# 결과 실행 시간 메모리 Grader output
1 Partially correct 22 ms 328 KB Number of queries: 16
2 Partially correct 25 ms 328 KB Number of queries: 14
3 Partially correct 27 ms 368 KB Number of queries: 14
4 Partially correct 23 ms 328 KB Number of queries: 14