답안 #762028

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
762028 2023-06-20T15:14:45 Z siewjh Planinarenje (COCI18_planinarenje) C++17
160 / 160
26 ms 960 KB
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 10005;
vector<int> adj[MAXN];
bool vis[MAXN];
int match[MAXN];
bool aug(int x){
	if (vis[x]) return 0;
	vis[x] = 1;
	for (int nxt : adj[x])
		if (match[nxt] == -1 || aug(match[nxt])){
			match[nxt] = x; match[x] = nxt;
			return 1;
		}
	return 0;
}
bool alt(int x){
	if (vis[x]) return 0;
	vis[x] = 1;
	for (int nxt : adj[x]){
		if (match[nxt] == -1 || alt(match[nxt]))
			return 1;
	}
	return 0;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int nums, nodes, edges; cin >> nums >> edges;
	nodes = 2 * nums;
	for (int i = 0; i < edges; i++){
		int p, v; cin >> p >> v; v += nums;
		adj[p].push_back(v);
		adj[v].push_back(p);
	}
	for (int i = 1; i <= nodes; i++) match[i] = -1;
	for (int i = 1; i <= nodes; i++)
		if (match[i] == -1){
			for (int j = 1; j <= nodes; j++) vis[j] = 0;
			aug(i);
		}
	for (int i = 1; i <= nums; i++){
		if (match[i] == -1) cout << "Mirko\n";
		else{
			for (int j = 1; j <= nodes; j++) vis[j] = 0;
			cout << (alt(match[i]) ? "Mirko" : "Slavko") << '\n';
		}
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 560 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 560 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 596 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 904 KB Output is correct
2 Correct 23 ms 960 KB Output is correct
3 Correct 23 ms 880 KB Output is correct
4 Correct 23 ms 916 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 596 KB Output is correct
2 Correct 10 ms 744 KB Output is correct
3 Correct 5 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 572 KB Output is correct
2 Correct 3 ms 596 KB Output is correct
3 Correct 5 ms 596 KB Output is correct
4 Correct 7 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 652 KB Output is correct
2 Correct 24 ms 848 KB Output is correct
3 Correct 7 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 768 KB Output is correct
2 Correct 13 ms 828 KB Output is correct
3 Correct 6 ms 720 KB Output is correct
4 Correct 20 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 792 KB Output is correct
2 Correct 7 ms 640 KB Output is correct
3 Correct 16 ms 852 KB Output is correct
4 Correct 17 ms 760 KB Output is correct