답안 #744318

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
744318 2023-05-18T12:07:03 Z MON Easter Eggs (info1cup17_eastereggs) C++14
컴파일 오류
0 ms 0 KB
#include <vector>
#include "grader.h"
using namespace std;

vector<int> e,vecini[513];

void dfs(int a = 1,int p = -1)
{
    e.emplace_back(a);
    for(auto &it : vecini[a])
        if(it != p) dfs(it);
}

int findEgg (int N, vector < pair < int, int > > bridges)
{
    e = {1}; for(int i = 1; i <= N ; i++) vecini[i].clear();
    for(auto &it : bridges)
        {
            vecini[it.first].emplace_back(it.second);
            vecini[it.second].emplace_back(it.first);
        }

    dfs(); int ans = 0,pas = 1; while(pas <= N) pas <<= 1;
    for(; pas ; pas >>= 1)
        {
            if(ans + pas >= N) continue;
            if(!query(vector<int>(e.begin() + 1,e.begin() + 1 + (ans + pas))) ans += pas;
        }

    return ans + 1;
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:27:16: warning: init-statement in selection statements only available with '-std=c++17' or '-std=gnu++17'
   27 |             if(!query(vector<int>(e.begin() + 1,e.begin() + 1 + (ans + pas))) ans += pas;
      |                ^
eastereggs.cpp:27:78: error: expected ';' before 'ans'
   27 |             if(!query(vector<int>(e.begin() + 1,e.begin() + 1 + (ans + pas))) ans += pas;
      |                                                                              ^~~~
      |                                                                              ;
eastereggs.cpp:27:16: warning: value computed is not used [-Wunused-value]
   27 |             if(!query(vector<int>(e.begin() + 1,e.begin() + 1 + (ans + pas))) ans += pas;
      |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
eastereggs.cpp:28:9: error: expected primary-expression before '}' token
   28 |         }
      |         ^
eastereggs.cpp:27:90: error: expected ')' before '}' token
   27 |             if(!query(vector<int>(e.begin() + 1,e.begin() + 1 + (ans + pas))) ans += pas;
      |               ~                                                                          ^
      |                                                                                          )
   28 |         }
      |         ~                                                                                 
eastereggs.cpp:28:9: error: expected primary-expression before '}' token
   28 |         }
      |         ^