# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
862835 | maks007 | Love Polygon (BOI18_polygon) | C++14 | 195 ms | 20304 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//Bismi Allah
#include "bits/stdc++.h"
using namespace std;
signed main () {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n;
cin >> n;
map <string,int> mp;
map <int,set <int>> loved;
vector <int> used(n, 0);
int ans = 1e9;
/*function<void(int)> f=[&](int cnt) {
if(count(used.begin(), used.end(), 1) == used.size()) {
ans = min(ans, cnt);
return;
}
for(int i = 0; i < n; i ++) {
if(used[i]) continue;
for(auto j : loved[i]) {
if(used[j]) continue;
used[j] = 1;
used[i] = 1;
f(cnt + 1);
used[i] = 0;
used[j] = 0;
}
}
};*/
for(int i = 0; i < n; i ++) {
string u, v;
cin >> u >> v;
if(mp.count(u) == 0) mp[u] = mp.size();
if(mp.count(v) == 0) mp[v] = mp.size();
loved[mp[v]].insert(mp[u]);
}
if(n % 2 == 1) {
cout << -1;
return 0;
}
int cnt = 0;
if(*loved[0].begin() == 0) cout << n;
else cout << n / 2;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |