Submission #333897

# Submission time Handle Problem Language Result Execution time Memory
333897 2020-12-08T02:35:16 Z beksultan04 Simple game (IZhO17_game) C++14
49 / 100
71 ms 9580 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define OK puts("OK");
#define fr first
#define sc second
#define ret return
#define scan1(a) scanf("%lld",&a);
#define scan2(a,b) scanf("%lld %lld",&a, &b);
#define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define pb push_back
#define endi puts("");
const int N = 1e6+12,INF=1e9+7;
int a[N],b[N],q[N],dp[N],n,sum;

void fun1(int x){
    int y;
    scan1(y)
    q[x]=y;
}

int fun2(int x){
    int i,p=q[1],ans=0;
    for (i=2;i<=n;++i){
        if (p < x && x < q[i] ||
            p > x && x > q[i])ans++;
        p=q[i];
    }
    ret ans;

}

main(){
    int m,i,j,k,b=0;
    scan2(n,m)
    if (n>1000)b=1;
    for (i=1;i<=n;++i){
        scan1(q[i])
        if (i!=1){
            dp[min(q[i-1],q[i])]++;
            dp[max(q[i-1],q[i])+1]--;
        }
    }
    for (i=0;i<=1000000;++i){
        dp[i]+=dp[i-1];
    }
    while (m--){
        int t,z;
        scan2(t,z)
        if (t==1)fun1(z);
        if (t==2 && b == 1)cout <<dp[z]<<'\n';
        if (t==2 && b == 0)cout <<fun2(z)<<'\n';
    }
}




Compilation message

game.cpp: In function 'long long int fun2(long long int)':
game.cpp:27:19: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   27 |         if (p < x && x < q[i] ||
      |             ~~~~~~^~~~~~~~~~~
game.cpp: At global scope:
game.cpp:35:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   35 | main(){
      |      ^
game.cpp: In function 'int main()':
game.cpp:36:13: warning: unused variable 'j' [-Wunused-variable]
   36 |     int m,i,j,k,b=0;
      |             ^
game.cpp:36:15: warning: unused variable 'k' [-Wunused-variable]
   36 |     int m,i,j,k,b=0;
      |               ^
game.cpp: In function 'void fun1(long long int)':
game.cpp:9:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 | #define scan1(a) scanf("%lld",&a);
      |                  ~~~~~^~~~~~~~~~~
game.cpp:20:5: note: in expansion of macro 'scan1'
   20 |     scan1(y)
      |     ^~~~~
game.cpp: In function 'int main()':
game.cpp:10:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 | #define scan2(a,b) scanf("%lld %lld",&a, &b);
      |                    ~~~~~^~~~~~~~~~~~~~~~~~~~
game.cpp:37:5: note: in expansion of macro 'scan2'
   37 |     scan2(n,m)
      |     ^~~~~
game.cpp:9:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 | #define scan1(a) scanf("%lld",&a);
      |                  ~~~~~^~~~~~~~~~~
game.cpp:40:9: note: in expansion of macro 'scan1'
   40 |         scan1(q[i])
      |         ^~~~~
game.cpp:10:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 | #define scan2(a,b) scanf("%lld %lld",&a, &b);
      |                    ~~~~~^~~~~~~~~~~~~~~~~~~~
game.cpp:51:9: note: in expansion of macro 'scan2'
   51 |         scan2(t,z)
      |         ^~~~~
# Verdict Execution time Memory Grader output
1 Correct 9 ms 8172 KB Output is correct
2 Correct 9 ms 8172 KB Output is correct
3 Correct 9 ms 8172 KB Output is correct
4 Correct 9 ms 8172 KB Output is correct
5 Correct 9 ms 8172 KB Output is correct
6 Correct 9 ms 8204 KB Output is correct
7 Correct 8 ms 8172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 8172 KB Output is correct
2 Correct 9 ms 8172 KB Output is correct
3 Correct 9 ms 8172 KB Output is correct
4 Correct 9 ms 8172 KB Output is correct
5 Correct 9 ms 8172 KB Output is correct
6 Correct 9 ms 8204 KB Output is correct
7 Correct 8 ms 8172 KB Output is correct
8 Correct 52 ms 9068 KB Output is correct
9 Correct 71 ms 9580 KB Output is correct
10 Correct 67 ms 9580 KB Output is correct
11 Correct 42 ms 9068 KB Output is correct
12 Correct 50 ms 9580 KB Output is correct
13 Correct 58 ms 9580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 8172 KB Output is correct
2 Correct 9 ms 8172 KB Output is correct
3 Correct 9 ms 8172 KB Output is correct
4 Correct 9 ms 8172 KB Output is correct
5 Correct 9 ms 8172 KB Output is correct
6 Correct 9 ms 8204 KB Output is correct
7 Correct 8 ms 8172 KB Output is correct
8 Correct 52 ms 9068 KB Output is correct
9 Correct 71 ms 9580 KB Output is correct
10 Correct 67 ms 9580 KB Output is correct
11 Correct 42 ms 9068 KB Output is correct
12 Correct 50 ms 9580 KB Output is correct
13 Correct 58 ms 9580 KB Output is correct
14 Incorrect 63 ms 9196 KB Output isn't correct
15 Halted 0 ms 0 KB -