제출 #333925

#제출 시각아이디문제언어결과실행 시간메모리
333925beksultan04Simple game (IZhO17_game)C++14
100 / 100
261 ms18548 KiB
#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 q[N],t[N],der[N*4];

void update(int v,int l,int r,int ql,int qr,int x){
    if (l > qr || r < ql)ret;
    if (ql <= l && r <= qr){
        der[v] += x;
        ret ;
    }
    int m = l+r>>1;
    update(v<<1,l,m,ql,qr,x);
    update((v<<1)+1,m+1,r,ql,qr,x);
}

int get_sum (int v, int l, int r, int pos) {
	if (l == r)ret der[v];
	int m = l+r>>1;
	if (m < pos)
        ret der[v]+get_sum((v<<1)+1,m+1,r,pos);
    else
        ret der[v]+get_sum(v<<1,l,m,pos);

}



main(){
    int m,i,j,k,b,n;
    scan2(n,m)
    for (i=1;i<=n;++i){
        scan1(q[i])
        if (i!=1)
            update(1,1,1000000,min(q[i-1],q[i]),max(q[i-1],q[i]),1);

    }
    while (m--){
        int t,z;
        scan2(t,z)
        if (t == 1){
            if (z != 1)
                update(1,1,1000000,min(q[z-1],q[z]),max(q[z-1],q[z]),-1);
            if (z != n)
                update(1,1,1000000,min(q[z+1],q[z]),max(q[z+1],q[z]),-1);
            int x;
            scan1(x)
            q[z] = x;
            if (z != 1)
                update(1,1,1000000,min(q[z-1],q[z]),max(q[z-1],q[z]),1);
            if (z != n)
                update(1,1,1000000,min(q[z+1],q[z]),max(q[z+1],q[z]),1);

        }
        else
            cout <<get_sum(1,1,1000000,z)<<'\n';
    }
}




컴파일 시 표준 에러 (stderr) 메시지

game.cpp: In function 'void update(long long int, long long int, long long int, long long int, long long int, long long int)':
game.cpp:24:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   24 |     int m = l+r>>1;
      |             ~^~
game.cpp: In function 'long long int get_sum(long long int, long long int, long long int, long long int)':
game.cpp:31:11: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   31 |  int m = l+r>>1;
      |          ~^~
game.cpp: At global scope:
game.cpp:41:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   41 | main(){
      |      ^
game.cpp: In function 'int main()':
game.cpp:42:13: warning: unused variable 'j' [-Wunused-variable]
   42 |     int m,i,j,k,b,n;
      |             ^
game.cpp:42:15: warning: unused variable 'k' [-Wunused-variable]
   42 |     int m,i,j,k,b,n;
      |               ^
game.cpp:42:17: warning: unused variable 'b' [-Wunused-variable]
   42 |     int m,i,j,k,b,n;
      |                 ^
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:43:5: note: in expansion of macro 'scan2'
   43 |     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:45:9: note: in expansion of macro 'scan1'
   45 |         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:52:9: note: in expansion of macro 'scan2'
   52 |         scan2(t,z)
      |         ^~~~~
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:59:13: note: in expansion of macro 'scan1'
   59 |             scan1(x)
      |             ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...