Submission #284886

# Submission time Handle Problem Language Result Execution time Memory
284886 2020-08-28T07:42:11 Z arnold518 Ruka (COI15_ruka) C++14
0 / 100
145 ms 60408 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 2e5;
const int MOD = 1e9+7;

int N, A[MAXN+10], Q;
map<pii, int> dp;

int solve(int l, int r)
{
	if(l>r) return 0;
	if(l==0 && r==N+1) return 1;
	if(dp.find({l, r})!=dp.end()) return dp[{l, r}];
	int &ret=dp[{l, r}];

	if(A[l]<A[r]) return ret=solve(l, r+1);
	if(A[l]>A[r]) return ret=solve(l-1, r);
	return ret=(solve(l-1, r)+solve(l, r+1))%MOD;
}

int main()
{
	scanf("%d%d", &N, &Q);
	for(int i=1; i<=N; i++) scanf("%d", &A[i]);

	while(Q--)
	{
		int k;
		scanf("%d", &k);
		printf("%d\n", solve(k-1, k+1));
	}
}

Compilation message

ruka.cpp: In function 'int main()':
ruka.cpp:28:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   28 |  scanf("%d%d", &N, &Q);
      |  ~~~~~^~~~~~~~~~~~~~~~
ruka.cpp:29:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   29 |  for(int i=1; i<=N; i++) scanf("%d", &A[i]);
      |                          ~~~~~^~~~~~~~~~~~~
ruka.cpp:34:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   34 |   scanf("%d", &k);
      |   ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 145 ms 60408 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 145 ms 60408 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 145 ms 60408 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -