답안 #878402

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
878402 2023-11-24T10:07:08 Z prince Simple game (IZhO17_game) C++17
22 / 100
1000 ms 2020 KB
#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

game.cpp: In function 'void solve()':
game.cpp:30:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |             for (int i = 0; i < chain.size() - 1; ++i) {
      |                             ~~^~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 3 ms 480 KB Output is correct
5 Correct 3 ms 348 KB Output is correct
6 Correct 3 ms 484 KB Output is correct
7 Correct 3 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 3 ms 480 KB Output is correct
5 Correct 3 ms 348 KB Output is correct
6 Correct 3 ms 484 KB Output is correct
7 Correct 3 ms 348 KB Output is correct
8 Execution timed out 1059 ms 2020 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 3 ms 480 KB Output is correct
5 Correct 3 ms 348 KB Output is correct
6 Correct 3 ms 484 KB Output is correct
7 Correct 3 ms 348 KB Output is correct
8 Execution timed out 1059 ms 2020 KB Time limit exceeded
9 Halted 0 ms 0 KB -