답안 #877250

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
877250 2023-11-23T04:55:46 Z _unknown_2010 Simple game (IZhO17_game) C++17
22 / 100
1000 ms 1760 KB
//#ifndef LOCAL
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#endif

#include <bits/stdc++.h>
using namespace std;
using vecp = vector<pair<int,int>>;
#define vecm(a,n,m) vector<vector<int>>a(n,vector<int>(m,0));
#define int int64_t
#define pb  push_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mpii map<int,int>
#define lb lower_bound
#define ub upper_bound
#define foor(i,a,b) for(int i=a;i<b; i++)
#define foor(i,a) foor(i,0,a)
#define ins insert
#define ss second
#define ff first
#define until(x, a) for (auto x : a)
#define ln(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define seea(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define seev(v,n) for(int i=0;i<n;i++){int x; cin>>x; v.push_back(x);}
const int mod = 1E9+7;
void solution(){
    int n,m;
    cin >> n >> m;
    vector<int> a(n+1);
    for(int i=1; i<=n; i++){
        int x;
        cin >> x;
        a[i]=x;
    }
    while(m--){
        int t;
        cin >> t;
        if(t==1){
            int x,y;
            cin >> x >> y;
            a[x]=y;
        }
        else {
            int x;
            cin >> x;
            int cnt=0;
            for(int i=1; i<n; i++){
                if((a[i]>x && a[i+1]<x) || (a[i]<x && a[i+1]>x))cnt++;
            }
            cout << cnt << endl;
        }
    }
}
int32_t main(){
    clock_t tStart = clock();
    std::ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int q = 1; // cin >> q;
    while(q--) {
        solution();
        cout << '\n';
    }
    cerr<<fixed<<setprecision(3)<<"\nTime Taken: "<<(double)(clock()- tStart)/CLOCKS_PER_SEC<<endl;
}
/*

██╗  ██╗ █████╗  ██████╗     ██╗██╗   ██╗ ██████╗████████╗
██║░░██║██╔══██╗██╔════╝░░░░░██║██║░░░██║██╔════╝╚══██╔══╝
███████║██║░░██║╚█████╗░░░░░░██║██║░░░██║╚█████╗░░░░██║░░░
██╔══██║██║░░██║░╚═══██╗██╗░░██║██║░░░██║░╚═══██╗░░░██║░░░
██║░░██║╚█████╔╝██████╔╝╚█████╔╝╚██████╔╝██████╔╝░░░██║░░░
╚═╝░░╚═╝░╚════╝░╚═════╝░░╚════╝░░╚═════╝░╚═════╝░░░░╚═╝░░░
*/

Compilation message

game.cpp:19: warning: "foor" redefined
   19 | #define foor(i,a) foor(i,0,a)
      | 
game.cpp:18: note: this is the location of the previous definition
   18 | #define foor(i,a,b) for(int i=a;i<b; i++)
      |
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 3 ms 500 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 2 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 3 ms 500 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 2 ms 344 KB Output is correct
8 Execution timed out 1033 ms 1760 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 3 ms 500 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 2 ms 344 KB Output is correct
8 Execution timed out 1033 ms 1760 KB Time limit exceeded
9 Halted 0 ms 0 KB -