Submission #297887

#TimeUsernameProblemLanguageResultExecution timeMemory
297887juggernautSplit the Attractions (IOI19_split)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
#include"split.h"
using namespace std;
vector<int>g[100005];
int ans[100005];
int fir(int v,int p){
    for(int to:g[v])if(to!=p)return fir(to,v);
    return v;
}
vector<int>find_split(int n,int a,int b,int c,vector<int>p1,vector<int>p2){
    int root=0;
    for(int i=0;i<p1.size();i++){
        g[p1[i]].push_back(p2[i]);
        g[p2[i]].push_back(p1[i]);
    }
    if(i!=n)root=fir(root,-1);
    while(a--){
        ans[root]=1;
        for(int to:g[v])if(!ans[to])root=to;
    }
    while(b--){
        ans[root]=2;
        for(int to:g[v])if(!ans[to])root=to;
    }
    while(c--){
        ans[root]=3;
        for(int to:g[v])if(!ans[to])root=to;
    }
    vector<int>res;
    for(int i=0;i<n;i++)res.push_back(ans[i]);
    return res;
}

Compilation message (stderr)

split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:12:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     for(int i=0;i<p1.size();i++){
      |                 ~^~~~~~~~~~
split.cpp:16:8: error: 'i' was not declared in this scope
   16 |     if(i!=n)root=fir(root,-1);
      |        ^
split.cpp:19:22: error: 'v' was not declared in this scope
   19 |         for(int to:g[v])if(!ans[to])root=to;
      |                      ^
split.cpp:23:22: error: 'v' was not declared in this scope
   23 |         for(int to:g[v])if(!ans[to])root=to;
      |                      ^
split.cpp:27:22: error: 'v' was not declared in this scope
   27 |         for(int to:g[v])if(!ans[to])root=to;
      |                      ^