답안 #299130

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
299130 2020-09-14T13:53:14 Z jovan_b Planinarenje (COCI18_planinarenje) C++17
160 / 160
38 ms 1272 KB
#include <bits/stdc++.h>
using namespace std;

vector <int> rgraf[10005];
vector <int> graf[10005];
int mt[10005];
bool used[10005];
int ime[10005];

bool bp(int v) {
	if (used[v])  return false;
	used[v] = true;
	for (auto c : graf[v]) {
		if(!mt[c] || bp(mt[c])) {
			mt[c] = v;
			ime[v] = c;
			return true;
		}
	}
	return false;
}

bool bio[10005];

bool good(int v) {
    if(used[v]) return true;
    used[v] = true;
    for (auto c : rgraf[v]) {
        if (!ime[c] || !good(ime[c])) return false;
    }
    return true;
}

int main()
{
    int n, m;
    cin >> n >> m;
    for(int i=1; i<=m; i++){
        int a, b;
        cin >> a >> b;
        graf[a].push_back(b);
        rgraf[b].push_back(a);
    }
    int mxm = 0;
    for(int i=1; i<=n; i++){
        for(int j=1; j<=n; j++) used[j] = 0;
        mxm += bp(i);
    }
    for(int i=1; i<=n; i++){
        if(!ime[i]){
            cout << "Mirko\n";
            continue;
        }
        for(int j=1; j<=n; j++){
            used[j] = 0;
        }
        if(good(ime[i])) cout << "Slavko\n";
        else cout << "Mirko\n";
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 768 KB Output is correct
2 Correct 1 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 768 KB Output is correct
2 Correct 1 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 768 KB Output is correct
2 Correct 1 ms 768 KB Output is correct
3 Correct 1 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 768 KB Output is correct
2 Correct 1 ms 768 KB Output is correct
3 Correct 1 ms 768 KB Output is correct
4 Correct 2 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 1144 KB Output is correct
2 Correct 27 ms 1152 KB Output is correct
3 Correct 26 ms 1144 KB Output is correct
4 Correct 28 ms 1272 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 896 KB Output is correct
2 Correct 20 ms 896 KB Output is correct
3 Correct 13 ms 896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 896 KB Output is correct
2 Correct 5 ms 896 KB Output is correct
3 Correct 13 ms 896 KB Output is correct
4 Correct 16 ms 896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 896 KB Output is correct
2 Correct 27 ms 1024 KB Output is correct
3 Correct 12 ms 1024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 896 KB Output is correct
2 Correct 17 ms 1024 KB Output is correct
3 Correct 8 ms 896 KB Output is correct
4 Correct 38 ms 896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 1024 KB Output is correct
2 Correct 9 ms 896 KB Output is correct
3 Correct 17 ms 1024 KB Output is correct
4 Correct 27 ms 896 KB Output is correct