Submission #242473

# Submission time Handle Problem Language Result Execution time Memory
242473 2020-06-27T19:06:55 Z MatesV13 Tenis (COI19_tenis) C++11
30 / 100
500 ms 6920 KB
#include <bits/stdc++.h>
using namespace std;
int n, q, ter[3][100005], rev[3][100005], v[100005], pa, pb, pc;
void provjeri (int idx){
	if (v[idx]) return; v[idx]=1;
	while (pa>rev[0][idx]){pa--; provjeri(ter[0][pa]);}
	while (pb>rev[1][idx]){pb--; provjeri(ter[1][pb]);}
	while (pc>rev[2][idx]){pc--; provjeri(ter[2][pc]);}
	return; 
}
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> q;
for (int i=0; i<3; i++){
	for (int j=0; j<n; j++){
		cin >> ter[i][j];
		rev[i][ter[i][j]]=j;
	}
}
while (q--){
	int tip; cin >> tip;
	if (tip==1){
		int x; cin >> x; pa=pb=pc=n;
		for (int i=1; i<=n; i++) v[i]=0;
		provjeri(x); bool ok=1;
		for (int i=1; i<=n; i++){
			ok = ok and v[i];
				} 
		if (ok) cout << "DA\n";
		else cout << "NE\n";
	}
	else {
		int p, a, b, posa, posb;
		cin >> p >> a >> b;
		for (int i=0; i<n; i++)
			if (ter[p-1][i]==a){
				posa=i; break;
			}
		for (int i=0; i<n; i++)
			if (ter[p-1][i]==b){
				posb=i; break;
			}
		swap(rev[p-1][a], rev[p-1][b]);
		swap(ter[p-1][posa], ter[p-1][posb]);
	}
}
return 0;
}

Compilation message

tenis.cpp: In function 'void provjeri(int)':
tenis.cpp:5:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
  if (v[idx]) return; v[idx]=1;
  ^~
tenis.cpp:5:22: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
  if (v[idx]) return; v[idx]=1;
                      ^
tenis.cpp: In function 'int main()':
tenis.cpp:34:22: warning: 'posb' may be used uninitialized in this function [-Wmaybe-uninitialized]
   int p, a, b, posa, posb;
                      ^~~~
tenis.cpp:34:16: warning: 'posa' may be used uninitialized in this function [-Wmaybe-uninitialized]
   int p, a, b, posa, posb;
                ^~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 49 ms 6136 KB Output is correct
14 Correct 46 ms 6656 KB Output is correct
15 Correct 55 ms 6920 KB Output is correct
16 Correct 55 ms 5240 KB Output is correct
17 Correct 70 ms 4728 KB Output is correct
18 Correct 58 ms 4856 KB Output is correct
19 Correct 62 ms 4728 KB Output is correct
20 Correct 39 ms 4344 KB Output is correct
21 Correct 65 ms 4728 KB Output is correct
22 Correct 54 ms 6268 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1072 ms 6060 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 49 ms 6136 KB Output is correct
14 Correct 46 ms 6656 KB Output is correct
15 Correct 55 ms 6920 KB Output is correct
16 Correct 55 ms 5240 KB Output is correct
17 Correct 70 ms 4728 KB Output is correct
18 Correct 58 ms 4856 KB Output is correct
19 Correct 62 ms 4728 KB Output is correct
20 Correct 39 ms 4344 KB Output is correct
21 Correct 65 ms 4728 KB Output is correct
22 Correct 54 ms 6268 KB Output is correct
23 Execution timed out 1072 ms 6060 KB Time limit exceeded
24 Halted 0 ms 0 KB -