Submission #862835

# Submission time Handle Problem Language Result Execution time Memory
862835 2023-10-19T05:41:48 Z maks007 Love Polygon (BOI18_polygon) C++14
0 / 100
195 ms 20304 KB
//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

polygon.cpp: In function 'int main()':
polygon.cpp:14:6: warning: unused variable 'ans' [-Wunused-variable]
   14 |  int ans = 1e9;
      |      ^~~
polygon.cpp:43:6: warning: unused variable 'cnt' [-Wunused-variable]
   43 |  int cnt = 0;
      |      ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 195 ms 20304 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -