Submission #878408

# Submission time Handle Problem Language Result Execution time Memory
878408 2023-11-24T10:18:16 Z prince Simple game (IZhO17_game) C++17
22 / 100
1000 ms 1252 KB
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
/*void dfs(int u){
    vis[u]=true;
    cout<<u<<" ";
    for(int v:g[u]){
        if(vis[v])continue;
        dfs(v);
    }
}*/
void solve(){
    int n,q;cin>>n>>q;
    vector<pair<int,int>>pr(n);
    for(int i=0;i<n;i++){
        cin>>pr[i].second;
        pr[i].first=i+1;
    }
    while(q--){
        int r;cin>>r;
        if(r==1){
            int a,b;cin>>a>>b;
            pr[a-1].second=b;
        }
        else{
            int cnt=0;
            int c;cin>>c;
            for(int i=0;i<pr.size()-1;i++){
                if(min(pr[i].second,pr[i+1].second)<=c&&max(pr[i].second,pr[i+1].second)>=c)cnt++;
            }
            cout<<cnt<<endl;
        }
    }
}
signed 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:29:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |             for(int i=0;i<pr.size()-1;i++){
      |                         ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 2 ms 412 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 3 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 2 ms 412 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 3 ms 348 KB Output is correct
8 Execution timed out 1092 ms 1252 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 2 ms 412 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 3 ms 348 KB Output is correct
8 Execution timed out 1092 ms 1252 KB Time limit exceeded
9 Halted 0 ms 0 KB -