답안 #768722

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
768722 2023-06-28T13:58:26 Z ono_de206 자동 인형 (IOI18_doll) C++14
9 / 100
480 ms 16620 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) {
	a.pb(0);
	int n = a.size();
	vector<int> C(m + 1, 0), X, Y;
	const int inf = 1e9 + 10;

	while(n & (n - 1)) {
		n++;
	}

	auto get = [&](int k) -> vector<int> {
		vector<int> vec(k);
		iota(all(vec), 0);
		vector<int> pos(k);
		int l = 0;
		function<void(vector<int>&)> dfs = [&](vector<int> &vec) {
			if(vec.size() == 1) {
				pos[vec[0]] = l++;
				return;
			}
			vector<int> L, R;
			for(int i = 0; i < vec.size(); i += 2) {
				L.pb(vec[i]);
				R.pb(vec[i + 1]);
			}
			dfs(L);
			dfs(R);
		};
		dfs(vec);
		return pos;
	};

	vector<int> pos = get(n), nwa(n, inf);
	vector<pair<int, int>> tmp;
	for(int i = n - a.size(); i < n; i++) {
		tmp.eb(pos[i], i);
	}
	sort(all(tmp));
	int l = 0;
	for(auto it : tmp) {
		nwa[it.ss] = a[l++];
	}
	swap(nwa, a);

	function<int(vector<int>&)> solve = [&](vector<int>& vec) {
		if(set<int>(all(vec)).size() == 1) return vec[0];
		vector<int> first, second;
		for(int i = 0; i < (int)vec.size(); i += 2) {
			first.pb(vec[i]);
			second.pb(vec[i + 1]);
		}
		int id1 = solve(first), id2 = solve(second);
		X.pb(id1);
		Y.pb(id2);
		return -(int)X.size();
	};
	C[0] = solve(a);
	for(int i = 1; i < C.size(); i++) {
		C[i] = C[0];
	}
	for(int i = 0; i < X.size(); i++) {
		if(X[i] == inf) X[i] = C[0];
		if(Y[i] == inf) Y[i] = C[0];
	}
	answer(C, X, Y);
}

Compilation message

doll.cpp: In lambda function:
doll.cpp:42:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |    for(int i = 0; i < vec.size(); i += 2) {
      |                   ~~^~~~~~~~~~~~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:78:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   78 |  for(int i = 1; i < C.size(); i++) {
      |                 ~~^~~~~~~~~~
doll.cpp:81:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   81 |  for(int i = 0; i < X.size(); i++) {
      |                 ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB wrong motion
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB wrong motion
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB wrong motion
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB wrong motion
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1 ms 212 KB Output is partially correct
2 Partially correct 167 ms 13556 KB Output is partially correct
3 Partially correct 164 ms 13568 KB Output is partially correct
4 Correct 164 ms 12600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1 ms 212 KB Output is partially correct
2 Partially correct 167 ms 13556 KB Output is partially correct
3 Partially correct 164 ms 13568 KB Output is partially correct
4 Correct 164 ms 12600 KB Output is correct
5 Incorrect 480 ms 16620 KB wrong motion
6 Halted 0 ms 0 KB -