답안 #67649

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
67649 2018-08-15T07:38:41 Z yusufake Easter Eggs (info1cup17_eastereggs) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
#include "grader.h"

using namespace std;
/*
static int N, X, cntQ;
static vector < int > v[1009];

int query (vector < int > h)
{
    cntQ ++;
    int ap[1009];
    if (h.empty ()) return 0;
    for (int i=1; i<=N; i++)
        ap[i] = 0;
    for (auto it = h.begin (); it != h.end (); it ++)
        ap[*it] = 1;
    queue < int > cc;
    cc.push (h[0]), ap[h[0]] = 2;
    while (!cc.empty ())
    {
        int nod = cc.front ();
        cc.pop ();
        for (auto it = v[nod].begin (); it != v[nod].end (); it ++)
            if (ap[*it] == 1)
                ap[*it] = 2, cc.push (*it);
    }
    for (int i=1; i<=N; i++)
        if (ap[i] == 1) return -1;
    for (auto it = h.begin (); it != h.end (); it ++)
        if (*it == X) return 1;
    return 0;
}
*/
#define st first
#define nd second
#define pb push_back
int H[550];
int findEgg(int n, vector < pair < int, int > > edge){
    vector < int > V[550],vv;
    int i,j,x,l,m,r;
    //for(i=0;i<n-1;i++){
      //  V[ edge[i].st ].pb(edge[i].nd);
       // V[ edge[i].nd ].pb(edge[i].st);
    //}    
    queue < int > Q;
    Q.push(1);
    memset(H,0,sizeof H);
    for(; Q.size() ; ){
        x = Q.front();
        Q.pop();
        if(H[x]) continue;
        H[x] = 1;
        vv.pb(x);
        for(auto y : v[x])
            Q.push(y);
    }
    l=0; r = n;
    for(; l+1 < r ;){
        m = l+r >> 1;
        vector < int > tt; 
        for(j=0;j<m;j++) tt.pb(vv[j]);
        if(query(tt)) r = m;
        else l = m;
    }
    //cout << vv[l] << " ss\n";
    return vv[l];
}        
/*
int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d", &N);
int Queries;
vector < pair < int, int > > param;
for (int i=1; i<N; i++)
{
    int x, y;
    scanf ("%d %d", &x, &y);
    v[x].push_back (y);
    v[y].push_back (x);
    param.push_back ({x, y});
}
scanf ("%d", &Queries);
while (Queries --)
{
    scanf ("%d", &X), cntQ = 0;
    int Y = findEgg (N, param);
    if (X != Y)
    {
        printf ("WA %d instead of %d\n", Y, X);
        return 0;
    }
    printf ("OK %d\n", cntQ);
}
return 0;
}
*/

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:55:22: error: 'v' was not declared in this scope
         for(auto y : v[x])
                      ^
eastereggs.cpp:60:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
         m = l+r >> 1;
             ~^~
eastereggs.cpp:41:9: warning: unused variable 'i' [-Wunused-variable]
     int i,j,x,l,m,r;
         ^