답안 #886022

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
886022 2023-12-11T11:42:57 Z waldi 장난감 기차 (IOI17_train) C++17
16 / 100
1738 ms 1620 KB
#include "train.h"
#include <bits/stdc++.h>
#define FOR(i,p,k) for(int i=(p);i<=(k);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define ssize(x) (int((x).size()))
#define all(x) (x).begin(),(x).end()
using namespace std;

vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v){
	int n = ssize(a);
	int m = ssize(u);
	vector<int> ret(n);
	
	vector<vector<int>> g(n);
	REP(i, m) g[u[i]].emplace_back(v[i]);
	
	bool sciezka = 1;
	REP(i, m) if(u[i] != v[i] && v[i] != u[i]+1) sciezka = 0;
	if(sciezka){
		for(int i = n; ~--i;){
			bool petla = 0, dalej = 0;
			for(int j : g[i]){
				if(j == i) petla = 1;
				if(j == i+1) dalej = 1;
			}
			
			if(a[i]){
				ret[i] = 0;
				if(petla && r[i]) ret[i] |= 1;
				if(dalej) ret[i] |= ret[i+1];
			}
			else{
				ret[i] = 1;
				if(petla && !r[i]) ret[i] &= 0;
				if(dalej) ret[i] &= ret[i+1];
			}
		}
		return ret;
	}
	
	bool wszystkie_a = 1;
	REP(i, n) if(!a[i]) wszystkie_a = 0;
	if(wszystkie_a){
		vector<int> czy_cykl(n, 0);
		REP(start, n){
			vector<bool> odw(n, 0);
			function<void(int)> dfs = [&](int w){
				odw[w] = 1;
				for(int i : g[w]){
					if(i == start) czy_cykl[start] = 1;
					if(!odw[i]) dfs(i);
				}
			};
			dfs(start);
		}
		
		REP(start, n){
			vector<bool> odw(n, 0);
			function<void(int)> dfs = [&](int w){
				odw[w] = 1;
				if(r[w] && czy_cykl[w]) ret[start] = 1;
				for(int i : g[w]) if(!odw[i]) dfs(i);
			};
			dfs(start);
		}
		
		return ret;
	}
	
	REP(i, n){
		
	}
	return ret;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 860 KB Output is correct
2 Correct 3 ms 860 KB Output is correct
3 Correct 3 ms 860 KB Output is correct
4 Correct 3 ms 860 KB Output is correct
5 Correct 3 ms 860 KB Output is correct
6 Correct 4 ms 780 KB Output is correct
7 Correct 3 ms 860 KB Output is correct
8 Correct 3 ms 856 KB Output is correct
9 Correct 2 ms 860 KB Output is correct
10 Correct 3 ms 776 KB Output is correct
11 Correct 2 ms 860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 275 ms 1372 KB Output is correct
2 Correct 273 ms 1368 KB Output is correct
3 Correct 270 ms 1372 KB Output is correct
4 Correct 1717 ms 1360 KB Output is correct
5 Correct 1326 ms 1504 KB Output is correct
6 Correct 905 ms 1416 KB Output is correct
7 Correct 800 ms 1616 KB Output is correct
8 Correct 459 ms 1616 KB Output is correct
9 Correct 369 ms 1388 KB Output is correct
10 Correct 576 ms 1364 KB Output is correct
11 Correct 486 ms 1324 KB Output is correct
12 Correct 37 ms 1116 KB Output is correct
13 Correct 1687 ms 1576 KB Output is correct
14 Correct 1709 ms 1608 KB Output is correct
15 Correct 1738 ms 1620 KB Output is correct
16 Correct 1707 ms 1600 KB Output is correct
17 Correct 1677 ms 1576 KB Output is correct
18 Correct 397 ms 1112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 856 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 1112 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 860 KB Output is correct
2 Correct 3 ms 860 KB Output is correct
3 Correct 3 ms 860 KB Output is correct
4 Correct 3 ms 860 KB Output is correct
5 Correct 3 ms 860 KB Output is correct
6 Correct 4 ms 780 KB Output is correct
7 Correct 3 ms 860 KB Output is correct
8 Correct 3 ms 856 KB Output is correct
9 Correct 2 ms 860 KB Output is correct
10 Correct 3 ms 776 KB Output is correct
11 Correct 2 ms 860 KB Output is correct
12 Incorrect 0 ms 348 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
13 Halted 0 ms 0 KB -