Submission #297140

# Submission time Handle Problem Language Result Execution time Memory
297140 2020-09-11T09:49:23 Z Azimjon Split the Attractions (IOI19_split) C++17
0 / 100
73 ms 8952 KB
#include "split.h"
#include <bits/stdc++.h>
using namespace std;

typedef vector<int> vi;

vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
	int m = p.size();
	vector<vi> g(n, vi());

	for (int i = 0; i < m; i++) {
		g[p[i]].push_back(q[i]);
		g[q[i]].push_back(p[i]);
	}

	vi jv(n, 0);

	int bo, ox;
	for (int i = 0; i < n; i++)
		if (g[i].size() == 1) {
			bo = i;
			break;
		}
	for (int i = 0; i < n; i++)
		if (g[i].size() == 1 && i != bo) {
			ox = i;
			break;
		}
	for (int i = 0; i < a; i++) {
		jv[bo] = 1;
		
		if (g[bo].size() == 2) {
			if (jv[g[bo][0]])
				bo = g[bo][1];
			else
				bo = g[bo][0];
		}
		else
			bo = g[bo][0];
	}

	for (int i = 0; i < b; i++) {
		jv[ox] = 2;
		
		if (g[ox].size() == 2) {
			if (jv[g[ox][0]])
				ox = g[ox][1];
			else
				ox = g[ox][0];
		}
		else
			ox = g[ox][0];
	}

	for (int &i : jv)
		if (i == 0)
			i = 3;

	return jv;
}

Compilation message

split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:25:24: warning: 'bo' may be used uninitialized in this function [-Wmaybe-uninitialized]
   25 |   if (g[i].size() == 1 && i != bo) {
      |       ~~~~~~~~~~~~~~~~~^~~~~~~~~~
split.cpp:43:8: warning: 'ox' may be used uninitialized in this function [-Wmaybe-uninitialized]
   43 |   jv[ox] = 2;
      |        ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 292 KB ok, correct split
2 Runtime error 1 ms 384 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB ok, correct split
2 Runtime error 1 ms 512 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 288 KB ok, correct split
2 Incorrect 73 ms 8952 KB invalid split: #1=3, #2=4, #3=99993
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB invalid split: #1=3, #2=2, #3=4
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 292 KB ok, correct split
2 Runtime error 1 ms 384 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -