Submission #716462

#TimeUsernameProblemLanguageResultExecution timeMemory
716462IliyaLove Polygon (BOI18_polygon)C++17
0 / 100
227 ms14260 KiB
#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 (stderr)

polygon.cpp: In function 'int main()':
polygon.cpp:41:14: warning: statement has no effect [-Wunused-value]
   41 |   if (x & 1) odd;
      |              ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...