답안 #129253

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
129253 2019-07-11T22:30:42 Z Shush 자동 인형 (IOI18_doll) C++17
16 / 100
226 ms 17256 KB
#include <bits/stdc++.h>
#include "doll.h"
using namespace std;

struct sw{
	int id, x, y;
};

const int MAXM = 1e5;
const int MAXN = 1e6;

bool p = true;
int n, m, s;
int h[MAXM + 1];
vector<int> x, y, a, t, c (MAXM + 1, 0);
set <int> el;
vector<vector<int>> nxt(MAXM + 1);

void xypush(int ps, int xi, int yi){
	x.push_back(xi); y.push_back(yi);
	s++;
}

void show(vector<int> t){
	for(int i : t) cerr << i << " ";
	cerr << "\n";
}

void sw2(int i){
	int xi = nxt[i][0], yi = nxt[i][1];
	xypush(s, xi, yi);
}
void sw3(int i){
	int xi = (s + 2) * -1, yi = (s + 3) * -1;
	xypush(s, xi, yi);
	xi = nxt[i][0], yi = s * -1;
	xypush(s, xi, yi);
	xi = nxt[i][1], yi = nxt[i][2];
	xypush(s, xi, yi);
}

void sw4(int i){
	int xi = (s + 2) * -1, yi = (s + 3) * -1;
	xypush(s, xi, yi);
	xi = nxt[i][0], yi = nxt[i][2];
	xypush(s, xi, yi);
    xi = nxt[i][1], yi = nxt[i][3];
    xypush(s, xi, yi);
}

void swsys(int i){
	int j = h[i];
	if(j == 2) {
		t[i] = (s + 1) * -1;
//		cerr << c[i] << " " << i << "\n";
		sw2(i);
	}
	if(j == 3) {
		t[i] = (s + 1) * -1;
//		cerr << c[i] << "\n";
		sw3(i);
	}
	if(j == 4) {
		t[i] = (s + 1) * -1;
//		cerr << c[i] << "\n";
		sw4(i);
	}
}

void create_circuit(int M, std::vector<int> A) {
	m = M, n = A.size(); a = A;
	t = vector<int> (m + 1, 0);
	//Hashing
	for(int i = 0; i < n; i++) {
		h[a[i]]++;
		el.insert(a[i]);
		if(i > 0) nxt[a[i - 1]].push_back(a[i]);
		if(i == n - 1) nxt[a[i]].push_back(0);
	}
	t[0] = a[0];
	for(int i = 0; i < n - 1; i++){
		if(h[a[i]] == 1) t[a[i]] = a[i + 1];
		else p = false;
	}
	if(p) { //Subtask 1
		answer(t, x, y);
		return;
	}
//	Creating Switch contraptions
	for(int i : el){
		if(h[i] > 1) swsys(i);
	}
//	for(int i = 0; i < n - 1; i++){
////		cerr << i << " " << c[i] << "\n";
//		if(c[i] != 0) t[i] = c[i];
//	}
//	show(t);
//	for(int i = 0; i < x.size(); i++){
//		cerr << x[i] << " " << (i + 1) * - 1 << " " << y[i] << "\n";
//	}
	answer(t, x, y);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 3020 KB Output is correct
2 Correct 62 ms 10428 KB Output is correct
3 Correct 62 ms 9948 KB Output is correct
4 Correct 3 ms 3020 KB Output is correct
5 Correct 14 ms 4172 KB Output is correct
6 Correct 138 ms 13520 KB Output is correct
7 Correct 4 ms 3020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 3020 KB Output is correct
2 Correct 62 ms 10428 KB Output is correct
3 Correct 62 ms 9948 KB Output is correct
4 Correct 3 ms 3020 KB Output is correct
5 Correct 14 ms 4172 KB Output is correct
6 Correct 138 ms 13520 KB Output is correct
7 Correct 4 ms 3020 KB Output is correct
8 Correct 104 ms 12516 KB Output is correct
9 Correct 165 ms 14064 KB Output is correct
10 Correct 218 ms 17256 KB Output is correct
11 Correct 3 ms 3020 KB Output is correct
12 Correct 3 ms 3020 KB Output is correct
13 Correct 3 ms 3020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 3020 KB Output is correct
2 Correct 62 ms 10428 KB Output is correct
3 Correct 62 ms 9948 KB Output is correct
4 Correct 3 ms 3020 KB Output is correct
5 Correct 14 ms 4172 KB Output is correct
6 Correct 138 ms 13520 KB Output is correct
7 Correct 4 ms 3020 KB Output is correct
8 Correct 104 ms 12516 KB Output is correct
9 Correct 165 ms 14064 KB Output is correct
10 Correct 218 ms 17256 KB Output is correct
11 Correct 3 ms 3020 KB Output is correct
12 Correct 3 ms 3020 KB Output is correct
13 Correct 3 ms 3020 KB Output is correct
14 Correct 194 ms 17072 KB Output is correct
15 Correct 89 ms 10068 KB Output is correct
16 Correct 152 ms 13892 KB Output is correct
17 Correct 3 ms 3020 KB Output is correct
18 Correct 3 ms 3020 KB Output is correct
19 Correct 3 ms 3020 KB Output is correct
20 Correct 226 ms 16812 KB Output is correct
21 Correct 3 ms 3020 KB Output is correct
22 Correct 3 ms 3020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 3020 KB wrong motion
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 3020 KB wrong motion
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 3020 KB wrong motion
2 Halted 0 ms 0 KB -