답안 #480522

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
480522 2021-10-16T19:19:45 Z Haidara Easter Eggs (info1cup17_eastereggs) C++17
컴파일 오류
0 ms 0 KB
/** * * * * * * * * * * * * * **\
 *                             *
 *   Author: Haidara Nassour   *
 * Coded in: YYYY\M\D HH:MM:SS *
 *          Lang: C++          *
 *                             *
\** * * * * * * * * * * * * * **/
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define itn int
#define rep(i,x,n) for(int i=(x);i<(n);i++)
#define FOR(i,n) rep(i,0,n)
#define per(i,x,n) for(int i=(x);i>(n);i--)
#define ROF(i,x) for(int i=x;i>=0;i--)
#define v(i) vector< i >
#define p(i,j) pair< i , j >
#define pii pair<int,int>
#define m(i,j) map< i , j >
#define um(i,j) unordered_map< i , j >
#define max_heap(i) priority_queue< i >
#define min_heap(i) priority_queue< i , vector< i > ,greater< i > >
#define ff first
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define ss second
#define pp push_back
#define mini(x,y) x=min(x,y)
#define maxi(x,y) x=max(x,y)
#define debug(x) cout<<#x<<" ";
using namespace std;
using namespace __gnu_pbds;
void SIO(string name="")
{
    if(name!="")
    {
        freopen((name+".in").c_str(),"r",stdin);
        freopen((name+".out").c_str(),"w",stdout);
    }
}
template <class T> using o_set = tree<T, null_type, less<T>,rb_tree_tag, tree_order_statistics_node_update>;
///order_of_key = find index of element x ( returned val is integer )
///find_by_order = find value at index x ( returned val is pointer )
const double pi=2.0*acos(0.0);
const int inf=1LL<<60LL;
const int mod=1e9+7;
const int maxn=555;
set<int>graph[maxn];
int dp[maxn];
set<int>s[maxn];
int n;
void dfs(int st=1,int par=-1)
{
    dp[st]=1;
    s[st].insert(st);
    for(auto i:graph[st])
    {
        if(i==par)
            continue;
        dfs(i,st);
        dp[st]+=dp[i];
        s[st].insert(all(s[i]));
    }
}
int find_centroid(int st)
{
    for(auto i:graph[st])
        if(dp[i]>n/2)
        {
            dp[st]-=dp[i];
            dp[i]=n;
            for(auto j:s[i])
                s[st].erase(j);
            s[i].insert(all(s[st]));
            return find_centroid(i);
        }
    return st;
}
int findEgg(int N,v(pii)edges)
{
    n=N;
    for(auto i:edges)
    {
        graph[i.ff].insert(i.ss);
        graph[i.ss].insert(i.ff);
    }
    dfs();
    int sz=n,st=1;
    while(sz-1)
    {
        st=find_centroid(st);
        v(int)nodes;
        int mx=0,node;
        for(auto i:graph[st])
            if(dp[i]>mx)
                mx=dp[i],node=i;
        for(auto i:graph[st])
            if(i==node)
                continue;
            else
                for(auto j:s[i])
                    nodes.pp(j);
        bool q=query(vector<int>(nodes.begin(),nodes.end()));
        if(q)
        {
            sz=dp[st]-dp[node];
            dp[st]-=dp[node];
            for(auto i:s[node])
                s[st].erase(i),graph[st].erase(i);
        }
        else
        {
            sz=dp[node];
            graph[node].erase(st);
            st=node;
        }
    }
    return st;
}

Compilation message

eastereggs.cpp: In function 'long long int findEgg(long long int, std::vector<std::pair<long long int, long long int> >)':
eastereggs.cpp:105:16: error: 'query' was not declared in this scope
  105 |         bool q=query(vector<int>(nodes.begin(),nodes.end()));
      |                ^~~~~
eastereggs.cpp: In function 'void SIO(std::string)':
eastereggs.cpp:39:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |         freopen((name+".in").c_str(),"r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
eastereggs.cpp:40:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |         freopen((name+".out").c_str(),"w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~