이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
pair<int, int> first = (upper_bound(s[x].begin(), s[x].end(), pair<int, pair<int, int>>{ v, pair<int, int>{ 1e9, 1e9 } }) - 1)->second;
pair<int, int> second = (upper_bound(s[y].begin(), s[y].end(), pair<int, pair<int, int>>{ v, pair<int, int>{ 1e9, 1e9 } }) -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;
}
컴파일 시 표준 에러 (stderr) 메시지
potion.cpp: In function 'int question(int, int, int)':
potion.cpp:46:21: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
46 | if (first.first && second.first || first.second && second.second) return 0;
| ~~~~~~~~~~~~^~~~~~~~~~~~~~~
potion.cpp:47:26: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
47 | else if (first.first && second.second || first.second && second.first) return 1;
| ~~~~~~~~~~~~^~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |