# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
878402 | prince | Simple game (IZhO17_game) | C++17 | 1059 ms | 2020 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
void solve(){
int N, M;
cin >> N >> M;
vector<pair<int, int>> chain(N);
for (int i = 0; i < N; ++i) {
cin >> chain[i].second;
chain[i].first = i + 1;
}
vector<int> output;
for (int i = 0; i < M; ++i) {
int type;
cin >> type;
if (type == 1) {
int pos, val;
cin >> pos >> val;
chain[pos - 1].second = val;
} else if (type == 2) {
int h;
cin >> h;
int intersections = 0;
for (int i = 0; i < chain.size() - 1; ++i) {
if (min(chain[i].second, chain[i + 1].second) <= h && h <= max(chain[i].second, chain[i + 1].second)) {
intersections++;
}
}
output.push_back(intersections);
}
}
for (int ans : output) {
cout << ans << endl;
}
}
int main() {
cin.tie(0)->sync_with_stdio(false);
#ifdef prince
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int q = 1;
// cin >> q;
while (q--) {
solve();
cout << '\n';
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |