답안 #766102

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
766102 2023-06-25T10:10:55 Z ono_de206 자동 인형 (IOI18_doll) C++14
53 / 100
105 ms 15156 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]);
			}
			int id1 = solve(first), id2 = solve(second);
			X.pb(id1);
			Y.pb(id2);
		}
		return -(int)X.size();
	};

	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, tot = 1;
		while(nxt * 2 < nx[i].size()) nxt *= 2, tot += nxt;
		reverse(all(nx[i]));
		while(nx[i].size() < nxt * 2) nx[i].pb(-(int)X.size() - tot);
		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, tot += nxt;
      |         ~~~~~~~~^~~~~~~~~~~~~~
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(-(int)X.size() - tot);
      |         ~~~~~~~~~~~~~^~~~~~~~~
doll.cpp:30:6: warning: unused variable 'now' [-Wunused-variable]
   30 |  int now = 0, root;
      |      ^~~
doll.cpp:30:15: warning: unused variable 'root' [-Wunused-variable]
   30 |  int now = 0, root;
      |               ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 20 ms 6456 KB Output is correct
3 Correct 16 ms 5276 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 9 ms 3756 KB Output is correct
6 Correct 24 ms 7812 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 20 ms 6456 KB Output is correct
3 Correct 16 ms 5276 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 9 ms 3756 KB Output is correct
6 Correct 24 ms 7812 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 33 ms 7472 KB Output is correct
9 Correct 36 ms 8720 KB Output is correct
10 Correct 58 ms 11472 KB Output is correct
11 Correct 1 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 1 ms 212 KB Output is correct
2 Correct 20 ms 6456 KB Output is correct
3 Correct 16 ms 5276 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 9 ms 3756 KB Output is correct
6 Correct 24 ms 7812 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 33 ms 7472 KB Output is correct
9 Correct 36 ms 8720 KB Output is correct
10 Correct 58 ms 11472 KB Output is correct
11 Correct 1 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 Correct 71 ms 11180 KB Output is correct
15 Correct 36 ms 7020 KB Output is correct
16 Correct 55 ms 10132 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 60 ms 12064 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1 ms 212 KB Output is partially correct
2 Correct 41 ms 7700 KB Output is correct
3 Partially correct 77 ms 11088 KB Output is partially correct
4 Partially correct 75 ms 12180 KB Output is partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1 ms 212 KB Output is partially correct
2 Correct 41 ms 7700 KB Output is correct
3 Partially correct 77 ms 11088 KB Output is partially correct
4 Partially correct 75 ms 12180 KB Output is partially correct
5 Partially correct 86 ms 13544 KB Output is partially correct
6 Partially correct 98 ms 14180 KB Output is partially correct
7 Partially correct 92 ms 13968 KB Output is partially correct
8 Partially correct 98 ms 14268 KB Output is partially correct
9 Partially correct 70 ms 11216 KB Output is partially correct
10 Partially correct 105 ms 15156 KB Output is partially correct
11 Partially correct 105 ms 14616 KB Output is partially correct
12 Partially correct 69 ms 9716 KB Output is partially correct
13 Partially correct 61 ms 9164 KB Output is partially correct
14 Partially correct 58 ms 9036 KB Output is partially correct
15 Partially correct 55 ms 8948 KB Output is partially correct
16 Partially correct 2 ms 596 KB Output is partially correct
17 Partially correct 59 ms 8056 KB Output is partially correct
18 Partially correct 57 ms 8028 KB Output is partially correct
19 Partially correct 59 ms 8416 KB Output is partially correct
20 Partially correct 77 ms 11288 KB Output is partially correct
21 Partially correct 93 ms 13240 KB Output is partially correct
22 Partially correct 72 ms 10788 KB Output is partially correct