Submission #1036749

# Submission time Handle Problem Language Result Execution time Memory
1036749 2024-07-27T16:19:10 Z ALeonidou Simurgh (IOI17_simurgh) C++17
Compilation error
0 ms 0 KB
#include "simurgh.h"

#include <cstdio>
#include <cassert>
#include <vector>
#include <cstdlib>
#include <string>

using namespace std;

static int MAXQ = 30000;

static int n, m, q = 0;
static vector<int> u, v;
static vector<bool> goal;

static void wrong_answer() {
	printf("NO\n");
	exit(0);
}

static bool is_valid(const vector<int>& r) {
	if(int(r.size()) != n - 1)
		return false;

	for(int i = 0; i < n - 1; i++)
		if (r[i] < 0 || r[i] >= m)
			return false;

	return true;
}

static int _count_common_roads_internal(const vector<int>& r) {
	if(!is_valid(r))
		wrong_answer();

	int common = 0;
	for(int i = 0; i < n - 1; i++) {
		bool is_common = goal[r[i]];
		if (is_common)
			common++;
	}

	return common;	
}

int count_common_roads(const vector<int>& r) {
	q++;
	if(q > MAXQ)
		wrong_answer();

	return _count_common_roads_internal(r);
}

int main() {
	assert(2 == scanf("%d %d", &n, &m));

	u.resize(m);
	v.resize(m);

	for(int i = 0; i < m; i++)
		assert(2 == scanf("%d %d", &u[i], &v[i]));

	goal.resize(m, false);

	for(int i = 0; i < n - 1; i++) {
		int id;
		assert(1 == scanf("%d", &id));
		goal[id] = true;
	}

	vector<int> res = find_roads(n, u, v);

	if(_count_common_roads_internal(res) != n - 1)
		wrong_answer();

	printf("YES\n");

	return 0;
}

Compilation message

/usr/bin/ld: /tmp/ccJZfYW9.o: in function `count_common_roads(std::vector<int, std::allocator<int> > const&)':
grader.cpp:(.text+0x350): multiple definition of `count_common_roads(std::vector<int, std::allocator<int> > const&)'; /tmp/ccf8LwE9.o:simurgh.cpp:(.text+0xe0): first defined here
/usr/bin/ld: /tmp/ccJZfYW9.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccf8LwE9.o:simurgh.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccf8LwE9.o: in function `main':
simurgh.cpp:(.text.startup+0x16d): undefined reference to `find_roads(int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
/usr/bin/ld: /tmp/ccJZfYW9.o: in function `main':
grader.cpp:(.text.startup+0x2ef): undefined reference to `find_roads(int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status