Submission #117620

# Submission time Handle Problem Language Result Execution time Memory
117620 2019-06-16T19:27:53 Z Bruteforceman Tenis (COI19_tenis) C++11
30 / 100
500 ms 3224 KB
#include "bits/stdc++.h"
using namespace std;
int N, Q;
int A[4][100010];
const int mod = 1000000000 + 7;

int opt() {
	long long a = 1, b = 1, c = 1;
	long long aa = 0, bb = 0, cc = 0;
	for(int i = 1; i <= N; i++) {
		aa += A[1][i]; a = (a * A[1][i]) % mod;
		bb += A[2][i]; b = (b * A[2][i]) % mod;
		cc += A[3][i]; c = (c * A[3][i]) % mod;
		if(aa == bb && bb == cc && a == b && b == c) {
			return i;
		}
	}
	return N + 1;
}
 
int pos(int x, int y) {
	for(int i = 1; i <= N; i++) {
		if(A[x][i] == y) return i;
	}
	return 0;
}
 
int main(int argc, char const *argv[])
{
	scanf("%d %d", &N, &Q);
	for(int i = 1; i <= N; i++) {
		scanf("%d", &A[1][i]);
	}
	for(int i = 1; i <= N; i++) {
		scanf("%d", &A[2][i]);
	}
	for(int i = 1; i <= N; i++) {
		scanf("%d", &A[3][i]);
	}
	int first = opt();
	for(int i = 1; i <= Q; i++) {
		int c;
		scanf("%d", &c);
		if(c == 1) {
			int X;
			scanf("%d", &X);
			int id = N + 1;
			bool ans = false;
			for(int j = 1; j <= first; j++) {
				if(A[1][j] == X) {
					ans = true;
					break;
				}
			}
			if(ans) printf("DA\n");
			else printf("NE\n");
		} else {
			int p, x, y;
			scanf("%d %d %d", &p, &x, &y);
			swap(A[p][pos(p, x)], A[p][pos(p, y)]);
			first = opt();
		}
	}	
	return 0;
}

Compilation message

tenis.cpp: In function 'int main(int, const char**)':
tenis.cpp:47:8: warning: unused variable 'id' [-Wunused-variable]
    int id = N + 1;
        ^~
tenis.cpp:30:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &N, &Q);
  ~~~~~^~~~~~~~~~~~~~~~~
tenis.cpp:32:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &A[1][i]);
   ~~~~~^~~~~~~~~~~~~~~~
tenis.cpp:35:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &A[2][i]);
   ~~~~~^~~~~~~~~~~~~~~~
tenis.cpp:38:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &A[3][i]);
   ~~~~~^~~~~~~~~~~~~~~~
tenis.cpp:43:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &c);
   ~~~~~^~~~~~~~~~
tenis.cpp:46:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &X);
    ~~~~~^~~~~~~~~~
tenis.cpp:59:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d %d %d", &p, &x, &y);
    ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 41 ms 2812 KB Output is correct
14 Correct 41 ms 2552 KB Output is correct
15 Correct 39 ms 2556 KB Output is correct
16 Correct 38 ms 2680 KB Output is correct
17 Correct 40 ms 2508 KB Output is correct
18 Correct 40 ms 2552 KB Output is correct
19 Correct 37 ms 3208 KB Output is correct
20 Correct 38 ms 3224 KB Output is correct
21 Correct 36 ms 3192 KB Output is correct
22 Correct 37 ms 3192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1070 ms 3072 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 41 ms 2812 KB Output is correct
14 Correct 41 ms 2552 KB Output is correct
15 Correct 39 ms 2556 KB Output is correct
16 Correct 38 ms 2680 KB Output is correct
17 Correct 40 ms 2508 KB Output is correct
18 Correct 40 ms 2552 KB Output is correct
19 Correct 37 ms 3208 KB Output is correct
20 Correct 38 ms 3224 KB Output is correct
21 Correct 36 ms 3192 KB Output is correct
22 Correct 37 ms 3192 KB Output is correct
23 Execution timed out 1070 ms 3072 KB Time limit exceeded
24 Halted 0 ms 0 KB -