제출 #592922

#제출 시각아이디문제언어결과실행 시간메모리
592922hyakupSimple game (IZhO17_game)C++17
0 / 100
1097 ms244 KiB
/****************************************************************************** Welcome to GDB Online. GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby, C#, OCaml, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS Code, Compile, Run and Debug online from anywhere in world. *******************************************************************************/ #include <bits/stdc++.h> using namespace std; const int maxn = 1000010; int bit[maxn], height[maxn]; int n, m; void update( int i, int v){ for( int j = i; j <= n; j += j&-j) bit[j] += v; } int query( int i ){ int soma = 0; for (int j = i; j > 0; j -= j&-j) soma += bit[j]; return soma; } int main() { scanf("%d %d", &n, &m); for( int i = 1; i <= n; i++){ scanf("%d", &height[i]); } for( int i = 1; i < n; i++){ int top = max( height[i], height[i + 1]), bot = min( height[i], height[i + 1]); update( bot, 1 ); update( top + 1, -1); } for( int i = 0; i < m; i++){ int type; scanf("%d", &type); if( type == 1 ){ int pos, val; scanf("%d %d", &pos, &val); int top, bot; if( pos < n ){ top = max( height[i], height[i + 1]), bot = min( height[i], height[i + 1]); update( bot, -1 ); update( top + 1, 1); top = max( val, height[i + 1]), bot = min( val, height[i + 1]); update( bot, 1 ); update( top + 1, -1); } if( pos > 1 ){ top = max( height[i], height[i - 1]), bot = min( height[i], height[i - 1]); update( bot, -1 ); update( top + 1, 1); top = max( val, height[i - 1]), bot = min( val, height[i - 1]); update( bot, 1 ); update( top + 1, -1); } height[pos] = val; } else{ int h; scanf("%d", &h); printf("%d\n", query(h)); } } }

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

game.cpp: In function 'int main()':
game.cpp:36:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |     scanf("%d %d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~
game.cpp:40:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |         scanf("%d", &height[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~
game.cpp:52:24: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |         int type; scanf("%d", &type);
      |                   ~~~~~^~~~~~~~~~~~~
game.cpp:56:32: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   56 |             int pos, val; scanf("%d %d", &pos, &val);
      |                           ~~~~~^~~~~~~~~~~~~~~~~~~~~
game.cpp:91:25: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   91 |             int h; scanf("%d", &h);
      |                    ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...