답안 #333895

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
333895 2020-12-08T02:33:12 Z beksultan04 Simple game (IZhO17_game) C++14
0 / 100
8 ms 8172 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 n,m,i,j,k;
    scan2(n,m)
    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)cout <<dp[z]<<' ';
    }
}




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:15: warning: unused variable 'j' [-Wunused-variable]
   36 |     int n,m,i,j,k;
      |               ^
game.cpp:36:17: warning: unused variable 'k' [-Wunused-variable]
   36 |     int n,m,i,j,k;
      |                 ^
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:39:9: note: in expansion of macro 'scan1'
   39 |         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:50:9: note: in expansion of macro 'scan2'
   50 |         scan2(t,z)
      |         ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 8172 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 8172 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 8172 KB Output isn't correct
2 Halted 0 ms 0 KB -