Submission #142890

#TimeUsernameProblemLanguageResultExecution timeMemory
142890LawlietSimple game (IZhO17_game)C++14
22 / 100
5 ms380 KiB
#include <bits/stdc++.h>

#define MAX 1010

using namespace std;

int n, m;
int n1, n2, n3;

int v[MAX];

int main()
{
	scanf("%d %d",&n,&m);

	for(int g = 1 ; g <= n ; g++)
		scanf("%d",&v[g]);

	for(int g = 0 ; g < m ; g++)
	{
		scanf("%d %d",&n1,&n2);

		if(n1 == 1)
		{
			scanf("%d",&n3);

			v[ n2 ] = n3;
		}
		else
		{
			if(n == 1)
			{
				printf("0\n");
				continue;
			}

			int ans = 0;

			if(v[ 1 ] > n2 && v[ 2 ] < n2) ans++;
			if(v[ n ] > n2 && v[ n - 1 ] < n2) ans++;

			for(int h = 2 ; h < n ; h++)
			{
				if(v[ h ] > n2 && v[h - 1] < n2) ans++;
				if(v[ h ] > n2 && v[h + 1] < n2) ans++;
			}

			printf("%d\n",ans);
		}
	}
}

Compilation message (stderr)

game.cpp: In function 'int main()':
game.cpp:14: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:17:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&v[g]);
   ~~~~~^~~~~~~~~~~~
game.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d",&n1,&n2);
   ~~~~~^~~~~~~~~~~~~~~~~
game.cpp:25:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d",&n3);
    ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...