답안 #790039

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
790039 2023-07-22T09:38:48 Z NothingXD 장난감 기차 (IOI17_train) C++17
0 / 100
545 ms 1656 KB
#include "train.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef complex<ld> point;

void debug_out(){cerr << endl;}

template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T){
	cerr << H << ' ';
	debug_out(T...);
}

#define debug(...) cerr << "(" << #__VA_ARGS__ << "): ", debug_out(__VA_ARGS__)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define MP(x, y) make_pair(x, y)

const int maxn = 1e4 + 10;

int n, m, h[maxn];
vector<pair<pii,int>> edge;
vector<int> g[maxn];
bool vis[maxn];

void dfs(int v){
	//debug(v);
	vis[v] = true;
	for (auto u: g[v]){
		if (!vis[u]) dfs(u);
	}
}

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++){
		v[i] += n;
		edge.push_back({{u[i], v[i]}, 1});
		//debug(u[i], v[i], 1);
		g[v[i]].push_back(u[i]);
	}
	for (int i = 0; i < n; i++){
		if (r[i]){
			edge.push_back({{i+n, i}, -(4*n)});
			//debug(i, i+n, -n-1);
		}
		else{
			edge.push_back({{i+n, i}, 0});
			//debug(i, i+n, 0);
		}
		g[i].push_back(n+i);
	}
	for (int i = 1; i <= 2*n; i++){
		for (auto x: edge){
			if (i >= 2*n && h[x.F.S] > h[x.F.F] + x.S){
				if (!vis[x.F.S]) dfs(x.F.S);
			}
			h[x.F.S] = min(h[x.F.S], h[x.F.F] + x.S);
		}
	}
	vector<int> ans(n);
	for (int i = 0; i < n; i++){
		ans[i] = vis[i];
	}
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 155 ms 1224 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 468 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 545 ms 1656 KB Output is correct
2 Correct 529 ms 1644 KB Output is correct
3 Correct 512 ms 1552 KB Output is correct
4 Incorrect 340 ms 1636 KB 3rd lines differ - on the 879th token, expected: '0', found: '1'
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 256 ms 1440 KB 3rd lines differ - on the 696th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 334 ms 1604 KB 3rd lines differ - on the 2nd token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 155 ms 1224 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -