Submission #348345

# Submission time Handle Problem Language Result Execution time Memory
348345 2021-01-14T17:06:41 Z Mefarnis Archery (IOI09_archery) C++14
10 / 100
2000 ms 7772 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define maxn 200000
#define pb push_back
using namespace std;
typedef pair<int,int> pi;

int n,k;
int ar[2*maxn];
int ansLast,ansInit;

int main() {
	scanf("%d%d",&n,&k);
	for( int i = 0 ; i < 2*n ; i++ )
		scanf("%d",&ar[i]);
	ansLast = n;
	for( int t = 0 ; t < n ; t++ ) {
		vector<pi> vec;
		for( int i = 0 ; i < n ; i++ )
			vec.pb(pi(0,0));
		vec[t].fi = ar[0];
		for( int i = 1 , idx = 0 ; i < 2*n ; i++ ) {
			if(vec[idx].fi == 0)
				vec[idx].fi = ar[i];
			else
				vec[idx++].se = ar[i];
		}
		for( int r = 1 ; r <= k ; r++ ) {
			vector<pi> last = vec;
			for( int i = 0 ; i < n ; i++ )
				vec[i] = pi(0,0);
			for( int i = 1 ; i < n ; i++ ) {
				vec[i-1].fi = min(last[i].fi,last[i].se);
				vec[i].se = max(last[i].fi,last[i].se);
			}
			vec[0].se = min(last[0].fi,last[0].se);
			vec[n-1].fi = max(last[0].fi,last[0].se);
		}
		for( int i = 0 ; i < n ; i++ )
			if(vec[i].fi == ar[0] || vec[i].se == ar[0]) {
				if(i <= ansLast) {
					ansLast = i;
					ansInit = t;
				}
				break;
			}
	}
	printf("%d\n",ansInit+1);
	return 0;
}

Compilation message

archery.cpp: In function 'int main()':
archery.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   14 |  scanf("%d%d",&n,&k);
      |  ~~~~~^~~~~~~~~~~~~~
archery.cpp:16:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   16 |   scanf("%d",&ar[i]);
      |   ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Execution timed out 2081 ms 512 KB Time limit exceeded
3 Execution timed out 2076 ms 364 KB Time limit exceeded
4 Execution timed out 2025 ms 492 KB Time limit exceeded
5 Correct 1 ms 364 KB Output is correct
6 Execution timed out 2070 ms 364 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Correct 3 ms 364 KB Output is correct
2 Execution timed out 2073 ms 364 KB Time limit exceeded
3 Execution timed out 2060 ms 364 KB Time limit exceeded
4 Execution timed out 2041 ms 936 KB Time limit exceeded
5 Execution timed out 2044 ms 6748 KB Time limit exceeded
6 Execution timed out 2086 ms 364 KB Time limit exceeded
7 Execution timed out 2078 ms 364 KB Time limit exceeded
8 Execution timed out 2090 ms 876 KB Time limit exceeded
9 Execution timed out 2076 ms 1132 KB Time limit exceeded
10 Execution timed out 2082 ms 364 KB Time limit exceeded
11 Execution timed out 2040 ms 1132 KB Time limit exceeded
12 Execution timed out 2076 ms 492 KB Time limit exceeded
13 Execution timed out 2083 ms 4960 KB Time limit exceeded
14 Execution timed out 2072 ms 492 KB Time limit exceeded
15 Execution timed out 2079 ms 1512 KB Time limit exceeded
16 Correct 132 ms 364 KB Output is correct
17 Execution timed out 2079 ms 364 KB Time limit exceeded
18 Execution timed out 2093 ms 364 KB Time limit exceeded
19 Execution timed out 2085 ms 492 KB Time limit exceeded
20 Execution timed out 2037 ms 492 KB Time limit exceeded
21 Execution timed out 2091 ms 1152 KB Time limit exceeded
22 Execution timed out 2089 ms 1512 KB Time limit exceeded
23 Execution timed out 2074 ms 7004 KB Time limit exceeded
24 Correct 77 ms 364 KB Output is correct
25 Execution timed out 2092 ms 364 KB Time limit exceeded
26 Execution timed out 2044 ms 492 KB Time limit exceeded
27 Execution timed out 2090 ms 1132 KB Time limit exceeded
28 Execution timed out 2086 ms 5088 KB Time limit exceeded
29 Execution timed out 2041 ms 364 KB Time limit exceeded
30 Execution timed out 2047 ms 492 KB Time limit exceeded
31 Execution timed out 2089 ms 1132 KB Time limit exceeded
32 Execution timed out 2086 ms 6876 KB Time limit exceeded
33 Correct 103 ms 364 KB Output is correct
34 Execution timed out 2090 ms 364 KB Time limit exceeded
35 Execution timed out 2086 ms 492 KB Time limit exceeded
36 Execution timed out 2090 ms 364 KB Time limit exceeded
37 Execution timed out 2097 ms 1004 KB Time limit exceeded
38 Execution timed out 2069 ms 1256 KB Time limit exceeded
39 Execution timed out 2090 ms 364 KB Time limit exceeded
40 Execution timed out 2086 ms 364 KB Time limit exceeded
41 Execution timed out 2074 ms 364 KB Time limit exceeded
42 Execution timed out 2096 ms 364 KB Time limit exceeded
43 Execution timed out 2094 ms 492 KB Time limit exceeded
44 Execution timed out 2080 ms 748 KB Time limit exceeded
45 Execution timed out 2068 ms 1132 KB Time limit exceeded
46 Execution timed out 2093 ms 1256 KB Time limit exceeded
47 Execution timed out 2092 ms 7772 KB Time limit exceeded