답안 #422737

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
422737 2021-06-10T11:23:56 Z schse 장난감 기차 (IOI17_train) C++17
5 / 100
10 ms 1368 KB
#include "train.h"
#ifndef EVAL
#include "grader.cpp"
#endif

#include <bits/stdc++.h>
using namespace std;

struct node
{
	vector<int> edges;
	bool been;
	bool charging = false;
	bool owner;
	bool winningpos = false;
};

vector<node> g;

bool rec(int n)
{
	auto &[edges,
		   been,
		   charging,
		   owner,
		   winningpos] = g[n];
	if (been)
		return winningpos;
	been = true;
	if (edges.size() == 0)
		return winningpos = charging;
	return winningpos = rec(edges[0]);
}

vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v)
{
	std::vector<int> res(a.size());
	g.resize(a.size());
	for (int i = 0; i < a.size(); i++)
	{
		g[i].owner = a[i];
		g[i].charging = r[i];
	}
	for (int i = 0; i < u.size(); i++)
	{
		if (g[u[i]].owner && g[u[i]].charging && u[i] == v[i])
			g[v[i]].winningpos = true,
			g[v[i]].been = true;
		else if (!g[u[i]].owner && !g[u[i]].charging && u[i] == v[i])
			g[v[i]].winningpos = false,
			g[v[i]].been = true;
		else if (u[i] == v[i])
		{
		}
		else
			g[u[i]].edges.push_back(v[i]);
	}

	for (int i = 0; i < (int)a.size(); i++)
		res[i] = rec(i);
	return res;
}

Compilation message

train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:39:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |  for (int i = 0; i < a.size(); i++)
      |                  ~~^~~~~~~~~~
train.cpp:44:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |  for (int i = 0; i < u.size(); i++)
      |                  ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 844 KB Output is correct
2 Correct 6 ms 816 KB Output is correct
3 Correct 4 ms 844 KB Output is correct
4 Correct 4 ms 844 KB Output is correct
5 Correct 4 ms 844 KB Output is correct
6 Correct 4 ms 844 KB Output is correct
7 Correct 4 ms 844 KB Output is correct
8 Correct 4 ms 844 KB Output is correct
9 Correct 4 ms 840 KB Output is correct
10 Correct 4 ms 716 KB Output is correct
11 Correct 3 ms 588 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 1368 KB Output is correct
2 Correct 10 ms 1228 KB Output is correct
3 Correct 7 ms 1228 KB Output is correct
4 Incorrect 7 ms 1196 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 1100 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 1228 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 844 KB Output is correct
2 Correct 6 ms 816 KB Output is correct
3 Correct 4 ms 844 KB Output is correct
4 Correct 4 ms 844 KB Output is correct
5 Correct 4 ms 844 KB Output is correct
6 Correct 4 ms 844 KB Output is correct
7 Correct 4 ms 844 KB Output is correct
8 Correct 4 ms 844 KB Output is correct
9 Correct 4 ms 840 KB Output is correct
10 Correct 4 ms 716 KB Output is correct
11 Correct 3 ms 588 KB Output is correct
12 Incorrect 1 ms 204 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
13 Halted 0 ms 0 KB -