답안 #167406

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
167406 2019-12-08T08:45:56 Z GioChkhaidze Simple game (IZhO17_game) C++14
22 / 100
1000 ms 1404 KB
#include <bits/stdc++.h>
#define Tree int h,int l,int r
#define Left 2*h,l,(l+r)/2
#define Right 2*h+1,(l+r)/2+1,r
using namespace std;
const int N=1e6+5;
int n,m,L,R,type,idx,val,dl,res;
int a[N];

main () {
	scanf("%d%d",&n,&m);
	
	for (int i=1; i<=n; i++) 
		scanf("%d",&a[i]);
	
	while (m--) {
		scanf("%d",&type);
		if (type==1) {
			scanf("%d%d",&idx,&val);
			a[idx]=val;
		}
			else {
			scanf("%d",&idx);
			res=0;
			for (int j=2; j<=n; j++)
				if (a[j-1]<idx && idx<a[j] || 
					a[j]<idx && idx<a[j-1]) res++;
			printf("%d\n",res);	
		}
	}
}

Compilation message

game.cpp:10:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main () {
       ^
game.cpp: In function 'int main()':
game.cpp:26:20: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
     if (a[j-1]<idx && idx<a[j] || 
         ~~~~~~~~~~~^~~~~~~~~~~
game.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&m);
  ~~~~~^~~~~~~~~~~~~~
game.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&a[i]);
   ~~~~~^~~~~~~~~~~~
game.cpp:17:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&type);
   ~~~~~^~~~~~~~~~~~
game.cpp:19:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d%d",&idx,&val);
    ~~~~~^~~~~~~~~~~~~~~~~~
game.cpp:23:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d",&idx);
    ~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 4 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 4 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 4 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 4 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 4 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 4 ms 376 KB Output is correct
8 Execution timed out 1075 ms 1404 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 4 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 4 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 4 ms 376 KB Output is correct
8 Execution timed out 1075 ms 1404 KB Time limit exceeded
9 Halted 0 ms 0 KB -