Submission #117582

# Submission time Handle Problem Language Result Execution time Memory
117582 2019-06-16T16:54:24 Z Bruteforceman Izlet (COI19_izlet) C++11
0 / 100
5 ms 512 KB
#include "bits/stdc++.h"
using namespace std;
int N, Q;
int A[4][100010];

int opt() {
	set <int> a, b, c;
	for(int i = 1; i <= N; i++) {
		a.insert(A[1][i]);
		b.insert(A[2][i]);
		c.insert(A[3][i]);
		if(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

izlet.cpp: In function 'int main(int, const char**)':
izlet.cpp:45:8: warning: unused variable 'id' [-Wunused-variable]
    int id = N + 1;
        ^~
izlet.cpp:28:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &N, &Q);
  ~~~~~^~~~~~~~~~~~~~~~~
izlet.cpp:30:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &A[1][i]);
   ~~~~~^~~~~~~~~~~~~~~~
izlet.cpp:33:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &A[2][i]);
   ~~~~~^~~~~~~~~~~~~~~~
izlet.cpp:36:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &A[3][i]);
   ~~~~~^~~~~~~~~~~~~~~~
izlet.cpp:41:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &c);
   ~~~~~^~~~~~~~~~
izlet.cpp:44:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &X);
    ~~~~~^~~~~~~~~~
izlet.cpp:57: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 Incorrect 2 ms 384 KB Expected integer, but "NE" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Expected integer, but "NE" found
2 Halted 0 ms 0 KB -