답안 #704005

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
704005 2023-03-01T10:32:58 Z Abrar_Al_Samit 장난감 기차 (IOI17_train) C++17
11 / 100
2000 ms 1848 KB
#include<bits/stdc++.h>
#include "train.h"
using namespace std;

const int nax = 5000;
int n, m;
vector<int>g[nax], gt[nax];
vector<int>A, R;

vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
	n = a.size(), m = u.size();
	for(int i=0; i<m; ++i) {
		g[u[i]].push_back(v[i]);
		gt[v[i]].push_back(u[i]);
	}

	A = a, R = r;
	vector<int>res(n);

	set<int>nontrap, trap;
	for(int i=0; i<n; ++i) {
		if(R[i]) nontrap.insert(i);
		else trap.insert(i);
	}
	while(1) {
		vector<int>trans;
		for(int x : trap) {
			bool all = true, one = false;
			for(int to : g[x]) {
				all &= nontrap.count(to);
				one |= nontrap.count(to);
			}
			if(A[x] && one) {
				trans.push_back(x);
			} else if(!A[x] && all) {
				trans.push_back(x);
			}
		}
		if(trans.empty()) break;
		for(int x : trans) {
			trap.erase(x);
			nontrap.insert(x);
		}
	}

	while(1) {
		vector<int>trans;
		for(int x : nontrap) {
			bool all = true, one = false;
			for(int to : g[x]) {
				all &= trap.count(to);
				one |= trap.count(to);
			}

			if(A[x] && all) {
				trans.push_back(x);
			} else if(!A[x] && one) {
				trans.push_back(x);
			}
		}
		if(trans.empty()) break;
		for(int x : trans) {
			trap.insert(x);
			nontrap.erase(x);
		}
	}

	for(int x : nontrap) res[x] = 1;

	return res;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 1356 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 540 KB Output is correct
4 Incorrect 1 ms 468 KB 3rd lines differ - on the 4th token, expected: '0', found: '1'
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2070 ms 1840 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 1620 KB Output is correct
2 Correct 66 ms 1704 KB Output is correct
3 Correct 41 ms 1820 KB Output is correct
4 Correct 23 ms 1832 KB Output is correct
5 Correct 977 ms 1820 KB Output is correct
6 Correct 1876 ms 1816 KB Output is correct
7 Correct 801 ms 1812 KB Output is correct
8 Correct 73 ms 1780 KB Output is correct
9 Correct 16 ms 1748 KB Output is correct
10 Correct 10 ms 1744 KB Output is correct
11 Correct 8 ms 1844 KB Output is correct
12 Correct 12 ms 1836 KB Output is correct
13 Correct 69 ms 1840 KB Output is correct
14 Correct 61 ms 1744 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 58 ms 1832 KB Output is correct
2 Correct 17 ms 1848 KB Output is correct
3 Correct 39 ms 1840 KB Output is correct
4 Correct 27 ms 1744 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 4 ms 1320 KB Output is correct
7 Correct 22 ms 1200 KB Output is correct
8 Incorrect 8 ms 1296 KB 3rd lines differ - on the 5th token, expected: '0', found: '1'
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 1356 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -