Submission #716462

# Submission time Handle Problem Language Result Execution time Memory
716462 2023-03-30T06:36:03 Z Iliya Love Polygon (BOI18_polygon) C++17
0 / 100
227 ms 14260 KB
#include<bits/stdc++.h>
#define int long long
using namespace std;
typedef long long ll;
const int N = 1e5 + 10;
vector<int> Adj[N];
int n, ts, cnt;
map<string, int> MP;
vector<int> res;
bool Mark[N];
void DFS(int v) {
	cnt++;
	Mark[v] = true;
	for (int u : Adj[v]) 
		if (!Mark[u]) DFS(u);
}
signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		string s, t;
		cin >> s >> t;
		if (!MP[s]) MP[s] = ++ts;
		if (!MP[t]) MP[t] = ++ts;
		Adj[MP[s]].push_back(MP[t]);
	}
	for (int i = 1; i <= n; i++) {
		if (!Mark[i]) {
			cnt = 0;
			DFS(i);
			res.push_back(cnt);
		}
	}
	if (n & 1) 
		return cout << "NO" << '\n', 0;
	int odd = 0;
	int ans = 0;
	for (int x : res) {
		ans += x / 2;
		if (x & 1) odd;
	}
	ans += odd / 2;
	cout << ans << '\n';
	return 0;
}

Compilation message

polygon.cpp: In function 'int main()':
polygon.cpp:41:14: warning: statement has no effect [-Wunused-value]
   41 |   if (x & 1) odd;
      |              ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 227 ms 14260 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -