Submission #786830

# Submission time Handle Problem Language Result Execution time Memory
786830 2023-07-18T13:22:18 Z pavement Mechanical Doll (IOI18_doll) C++17
16 / 100
63 ms 13032 KB
#include "doll.h"
#include <bits/stdc++.h>
using namespace std;

#define pb push_back

void create_circuit(int M, vector<int> A) {
	int N = A.size();
	vector<int> C(M + 1), X, Y, needin, unsure;
	vector<vector<int> > vec(M + 1, vector<int>());
	for (int i = 0; i < N; i++) {
		vec[A[i]].pb(i + 1 < N ? A[i + 1] : 0);
	}
	C[0] = A[0];
	for (int i = 1; i <= M; i++) {
		if (vec[i].empty()) {
			C[i] = 0;
		} else if (vec[i].size() == 1) {
			C[i] = vec[i][0];
		} else if (vec[i].size() == 2) {
			// create new switch
			C[i] = -((int)X.size() + 1);
			X.pb(vec[i][0]);
			Y.pb(vec[i][1]);
		} else if (vec[i].size() == 3) {
			// create 3 new switches
			C[i] = -((int)X.size() + 1);
			X.pb(C[i] - 1);
			Y.pb(C[i] - 2);
			X.pb(vec[i][0]);
			Y.pb(vec[i][2]);
			X.pb(vec[i][1]);
			Y.pb(-(int)1e9);
			needin.pb(C[i]);
			unsure.pb((int)Y.size() - 1);
		} else if (vec[i].size() == 4) {
			// create 3 new switches
			C[i] = -((int)X.size() + 1);
			X.pb(C[i] - 1);
			Y.pb(C[i] - 2);
			X.pb(vec[i][0]);
			Y.pb(vec[i][2]);
			X.pb(vec[i][1]);
			Y.pb(vec[i][3]);
		}
	}
	if (!needin.empty()) {
		for (int &i : C) {
			if (i == 0) {
				i = needin[0];
			}
		}
		for (int &i : X) {
			if (i == 0) {
				i = needin[0];
			}
		}
		for (int &i : Y) {
			if (i == 0) {
				i = needin[0];
			}
		}
		for (int i = 0; i < (int)unsure.size(); i++) {
			Y[unsure[i]] = (i + 1 < (int)unsure.size() ? needin[i + 1] : 0);
		}
	}
	answer(C, X, Y);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 19 ms 6740 KB Output is correct
3 Correct 16 ms 5608 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 8 ms 3796 KB Output is correct
6 Correct 23 ms 8368 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 19 ms 6740 KB Output is correct
3 Correct 16 ms 5608 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 8 ms 3796 KB Output is correct
6 Correct 23 ms 8368 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 32 ms 8104 KB Output is correct
9 Correct 35 ms 9532 KB Output is correct
10 Correct 60 ms 12224 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 296 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 19 ms 6740 KB Output is correct
3 Correct 16 ms 5608 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 8 ms 3796 KB Output is correct
6 Correct 23 ms 8368 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 32 ms 8104 KB Output is correct
9 Correct 35 ms 9532 KB Output is correct
10 Correct 60 ms 12224 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 296 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 62 ms 13032 KB Output is correct
15 Correct 32 ms 6732 KB Output is correct
16 Correct 50 ms 10144 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 63 ms 12512 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB wrong motion
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB wrong motion
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB wrong motion
2 Halted 0 ms 0 KB -