답안 #766077

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
766077 2023-06-25T09:52:10 Z ono_de206 자동 인형 (IOI18_doll) C++14
6 / 100
69 ms 11232 KB
#include "doll.h"
#include<bits/stdc++.h>
using namespace std;

#define in insert
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// #define int long long
 
typedef long long ll;
typedef vector<int> vi;
typedef set<int> si;
typedef multiset<int> msi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

void create_circuit(int m, std::vector<int> a) {
	int n = a.size();
	a.pb(0);
	vector<int> C(m + 1, 0), X, Y;
	vector<vector<int>> nx(m + 1);
	nx[0].pb(a[0]);
	for(int i = 0; i < n; i++) {
		nx[a[i]].pb(a[i + 1]);
	}
	int now = 0, root;

	function<int(vector<int>&)> solve = [&](vector<int>& vec) {
		if(vec.size() == 2) {
			X.pb(vec[0]);
			Y.pb(vec[1]);
		} else {
			vector<int> first, second;
			for(int i = 0; i < (int)vec.size(); i += 2) {
				first.pb(vec[i]);
				second.pb(vec[i + 1]);
			}
			X.pb(solve(first));
			Y.pb(solve(second));
		}
		now++;
		return -now;
	};

	for(int i = 0; i <= m; i++) {
		if(nx[i].size() == 0) continue;
		if(nx[i].size() == 1) {
			C[i] = nx[i][0];
			continue;
		}
		int nxt = 1;
		while(nxt * 2 < nx[i].size()) nxt *= 2;
		reverse(all(nx[i]));
		while(nx[i].size() < nxt * 2) nx[i].pb(i);
		reverse(all(nx[i]));
		C[i] = solve(nx[i]);
	}
	answer(C, X, Y);
}

Compilation message

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:56:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |   while(nxt * 2 < nx[i].size()) nxt *= 2;
      |         ~~~~~~~~^~~~~~~~~~~~~~
doll.cpp:58:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   58 |   while(nx[i].size() < nxt * 2) nx[i].pb(i);
      |         ~~~~~~~~~~~~~^~~~~~~~~
doll.cpp:30:15: warning: unused variable 'root' [-Wunused-variable]
   30 |  int now = 0, root;
      |               ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 19 ms 6352 KB Output is correct
3 Correct 16 ms 5120 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 11 ms 3816 KB Output is correct
6 Correct 23 ms 7736 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 19 ms 6352 KB Output is correct
3 Correct 16 ms 5120 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 11 ms 3816 KB Output is correct
6 Correct 23 ms 7736 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 33 ms 7248 KB Output is correct
9 Correct 35 ms 8528 KB Output is correct
10 Correct 50 ms 11232 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 19 ms 6352 KB Output is correct
3 Correct 16 ms 5120 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 11 ms 3816 KB Output is correct
6 Correct 23 ms 7736 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 33 ms 7248 KB Output is correct
9 Correct 35 ms 8528 KB Output is correct
10 Correct 50 ms 11232 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Incorrect 69 ms 10948 KB wrong motion
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB wrong motion
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB wrong motion
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB wrong motion
2 Halted 0 ms 0 KB -