Submission #520990

#TimeUsernameProblemLanguageResultExecution timeMemory
520990Valaki2Split the Attractions (IOI19_split)C++14
0 / 100
1 ms280 KiB
#include "split.h"

using namespace std;

vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
	vector<int> res(n, 3);
	vector<vector<int> > g(n);
	for(int i = 0; i < p.size(); i++) {
        g[p[i]].push_back(q[i]);
        g[q[i]].push_back(p[i]);
	}
	bool volt = false;
    for(int i = 0; i < n; i++) {
        if(g[i].size() == 1) {
            volt = true;
            int x = i, y = g[x][0];
            for(int j = 0; j < a; j++) {
                res[x] = 1;
                int temp = x;
                if(g[x][0] == y) {
                    x = g[x][1];
                } else {
                    x = g[x][0];
                }
                y = temp;
            }
            for(int j = 0; j < b; j++) {
                res[x] = 2;
                int temp = x;
                if(g[x][0] == y) {
                    x = g[x][1];
                } else {
                    x = g[x][0];
                }
                y = temp;
            }
        }
    }
    if(!volt) {
        int x = 0, y = -1;
            for(int j = 0; j < a; j++) {
                res[x] = 1;
                int temp = x;
                if(g[x][0] == y) {
                    x = g[x][1];
                } else {
                    x = g[x][0];
                }
                y = temp;
            }
            for(int j = 0; j < b; j++) {
                res[x] = 2;
                int temp = x;
                if(g[x][0] == y) {
                    x = g[x][1];
                } else {
                    x = g[x][0];
                }
                y = temp;
            }
    }
	/*if (n == 9) {
		res = {1, 1, 3, 1, 2, 2, 3, 1, 3};
	} else {
		res = {0, 0, 0, 0, 0, 0};
	}*/
	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:8:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |  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...