# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
878402 | prince | Simple game (IZhO17_game) | C++17 | 1059 ms | 2020 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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';
}
}
컴파일 시 표준 에러 (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... |