답안 #1102937

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1102937 2024-10-19T09:07:19 Z KasymK Simple game (IZhO17_game) C++17
22 / 100
1000 ms 1352 KB
#include "bits/stdc++.h"
using namespace std;
#define ff first
#define ss secox
#define all(v) v.begin(), v.ex()
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define tr(i, c) for(auto i = c.begin(); i != c.end(); ++i)
#define wr puts("----------------")
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const int N = 1e5+5;
int v[N];

int main(){
    int n, q;
    scanf("%d%d", &n, &q);
    for(int i = 1; i <= n; ++i){
        int x;
        scanf("%d", &x);
        v[i] = x;
    }
    while(q--){
        int op;
        scanf("%d", &op);
        if(op==1){
            int k, u;
            scanf("%d%d", &k, &u);
            v[k] = u;
            continue;
        }
        int x, answer = 0;
        scanf("%d", &x);
        for(int i = 2; i <= n; ++i)
            answer += ((v[i]<x and x<v[i-1]) or (v[i]>x and x>v[i-1]));
        printf("%d\n", answer);
    }
    return 0;
}

Compilation message

game.cpp: In function 'int main()':
game.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |     scanf("%d%d", &n, &q);
      |     ~~~~~^~~~~~~~~~~~~~~~
game.cpp:23:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         scanf("%d", &x);
      |         ~~~~~^~~~~~~~~~
game.cpp:28:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |         scanf("%d", &op);
      |         ~~~~~^~~~~~~~~~~
game.cpp:31:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |             scanf("%d%d", &k, &u);
      |             ~~~~~^~~~~~~~~~~~~~~~
game.cpp:36:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |         scanf("%d", &x);
      |         ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 2 ms 336 KB Output is correct
3 Correct 2 ms 336 KB Output is correct
4 Correct 2 ms 336 KB Output is correct
5 Correct 2 ms 336 KB Output is correct
6 Correct 2 ms 336 KB Output is correct
7 Correct 2 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 2 ms 336 KB Output is correct
3 Correct 2 ms 336 KB Output is correct
4 Correct 2 ms 336 KB Output is correct
5 Correct 2 ms 336 KB Output is correct
6 Correct 2 ms 336 KB Output is correct
7 Correct 2 ms 468 KB Output is correct
8 Execution timed out 1055 ms 1352 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 2 ms 336 KB Output is correct
3 Correct 2 ms 336 KB Output is correct
4 Correct 2 ms 336 KB Output is correct
5 Correct 2 ms 336 KB Output is correct
6 Correct 2 ms 336 KB Output is correct
7 Correct 2 ms 468 KB Output is correct
8 Execution timed out 1055 ms 1352 KB Time limit exceeded
9 Halted 0 ms 0 KB -