Submission #342495

#TimeUsernameProblemLanguageResultExecution timeMemory
342495mjhmjh1104The Potion of Great Power (CEOI20_potion)C++14
18 / 100
731 ms29184 KiB
#include <set> #include <map> #include <cmath> #include <vector> #include <algorithm> using namespace std; int n, zero[100006], one[100006]; set<pair<int, int>> m; map<int, vector<pair<int, pair<int, int>>>> s; vector<int> h; void init(int N, int D, int H[]) { n = N; for (int i = 0; i < N; i++) h.push_back(H[i]); } void curseChanges(int U, int A[], int B[]) { for (int i = 0; i < U; i++) { int a = A[i], b = B[i]; if (a > b) swap(a, b); if (m.count({ a, b })) { m.erase({ a, b }); if (h[a] == 0) zero[b]--; else one[b]--; if (h[b] == 0) zero[a]--; else one[a]--; s[a].push_back({ i + 1, { zero[a], one[a] } }); s[b].push_back({ i + 1, { zero[b], one[b] } }); } else { m.insert({ a, b }); if (h[a] == 0) zero[b]++; else one[b]++; if (h[b] == 0) zero[a]++; else one[a]++; s[a].push_back({ i + 1, { zero[a], one[a] } }); s[b].push_back({ i + 1, { zero[b], one[b] } }); } } } int question(int x, int y, int v) { if (s.find(x) == s.end() || s.find(y) == s.end()) return 1e9; auto it1 = upper_bound(s[x].begin(), s[x].end(), pair<int, pair<int, int>>{ v, pair<int, int>{ 1e9, 1e9 } }); if (it1 == s[x].begin()) return 1e9; pair<int, int> first = (it1 - 1)->second; auto it2 = upper_bound(s[y].begin(), s[y].end(), pair<int, pair<int, int>>{ v, pair<int, int>{ 1e9, 1e9 } }); if (it2 == s[y].begin()) return 1e9; pair<int, int> second = (it2 - 1)->second; if (first.first && second.first || first.second && second.second) return 0; else if (first.first && second.second || first.second && second.first) return 1; else return 1e9; }

Compilation message (stderr)

potion.cpp: In function 'int question(int, int, int)':
potion.cpp:50:21: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   50 |     if (first.first && second.first || first.second && second.second) return 0;
      |         ~~~~~~~~~~~~^~~~~~~~~~~~~~~
potion.cpp:51:26: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   51 |     else if (first.first && second.second || first.second && second.first) return 1;
      |              ~~~~~~~~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...