Submission #862835

#TimeUsernameProblemLanguageResultExecution timeMemory
862835maks007Love Polygon (BOI18_polygon)C++14
0 / 100
195 ms20304 KiB
//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)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...