Submission #232717

#TimeUsernameProblemLanguageResultExecution timeMemory
232717UserIsUndefinedSplit the Attractions (IOI19_split)C++14
0 / 100
6 ms2816 KiB
#include <bits/stdc++.h>
#include "split.h"

using namespace std;


vector<int> adj[100005];
int ok;
map<int,int> visited;

map<int,int> good;
int sz;
int now;

void dfs(int v){
    visited[v] = true;
    sz--;
    good[v] = now;

    if (sz <= 0){
       if (sz < 0){visited[v] = false; good[v] = 0;}
        return ;
    }

    for (int i : adj[v]){
        if (visited[i] == false){
            dfs(i);
        }
    }

}




vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
	vector<int> res(n, 0);


    for (int i = 0 ; i < p.size() ; i++){
        int x = p[i];
        int y = q[i];
        adj[x].push_back(y);
        adj[y].push_back(x);
    }




    sz = b;
    now = 2;

    dfs(0);
    bool ok = false;

    for (int i = 0 ; i < n ; i++){
        if ((good[i] == 0)&&(ok == false))res[i] = 1;
        else res[i] = (good[i] == 0 ? 3 : good[i]);
    }



//    for (int i = 0 ; i < res.size() ; i++){
//        cout << res[i] << endl;
//    }

    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:40:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0 ; i < p.size() ; i++){
                      ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...