#include <bits/stdc++.h>
#include "doll.h"
using namespace std;
int current = 1;
vector <int> X, Y, C;
bool check_same(vector <int> v){
for (int i = 0; i < v.size()-1; i++)if (v[i] != v[i+1])return 0;
return 1;
}
int solve(vector <int> v){
if (check_same(v))return v[0];
vector <int> v1, v2;
int c = current++;
if (v.size() & 1){
v.push_back(-c);
swap(v[v.size()-1], v[v.size()-2]);
}
for (int i = 0; i < v.size(); i+=2)v1.push_back(v[i]);
for (int i = 1; i < v.size(); i+=2)v2.push_back(v[i]);
int a = solve(v1), b = solve(v2);
X[c-1] = a;
Y[c-1] = b;
return -c;
}
void create_circuit(int M, std::vector<int> A) {
vector <vector <int>> dest(M+1);
const int INF = -100000000;
X.resize(300000, INF);
Y.resize(300000, INF);
A.push_back(0);
dest[0].push_back(A[0]);
for (int i = 0; i < A.size()-1; i++)dest[A[i]].push_back(A[i+1]);
C.resize(M+1);
for (int i = 0; i <= M; i++){
if (dest[i].empty()){
C[i] = i;
continue;
}
C[i] = solve(dest[i]);
}
for (auto x : C)cerr << x << " ";
cerr << "\n";
while (!X.empty() && X.back() == INF)X.pop_back();
while (!Y.empty() && Y.back() == INF)Y.pop_back();
for (int i = 0; i < X.size(); i++)cerr << X[i] << " " << Y[i] << "\n";
answer(C, X, Y);
}
Compilation message
doll.cpp: In function 'bool check_same(std::vector<int>)':
doll.cpp:10:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
10 | for (int i = 0; i < v.size()-1; i++)if (v[i] != v[i+1])return 0;
| ~~^~~~~~~~~~~~
doll.cpp: In function 'int solve(std::vector<int>)':
doll.cpp:22:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
22 | for (int i = 0; i < v.size(); i+=2)v1.push_back(v[i]);
| ~~^~~~~~~~~~
doll.cpp:23:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
23 | for (int i = 1; i < v.size(); i+=2)v2.push_back(v[i]);
| ~~^~~~~~~~~~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:37:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
37 | for (int i = 0; i < A.size()-1; i++)dest[A[i]].push_back(A[i+1]);
| ~~^~~~~~~~~~~~
doll.cpp:50:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
50 | for (int i = 0; i < X.size(); i++)cerr << X[i] << " " << Y[i] << "\n";
| ~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
230 ms |
9236 KB |
Output is correct |
3 |
Correct |
151 ms |
7804 KB |
Output is correct |
4 |
Correct |
2 ms |
2644 KB |
Output is correct |
5 |
Correct |
233 ms |
6732 KB |
Output is correct |
6 |
Correct |
270 ms |
10548 KB |
Output is correct |
7 |
Correct |
2 ms |
2644 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
230 ms |
9236 KB |
Output is correct |
3 |
Correct |
151 ms |
7804 KB |
Output is correct |
4 |
Correct |
2 ms |
2644 KB |
Output is correct |
5 |
Correct |
233 ms |
6732 KB |
Output is correct |
6 |
Correct |
270 ms |
10548 KB |
Output is correct |
7 |
Correct |
2 ms |
2644 KB |
Output is correct |
8 |
Correct |
454 ms |
10188 KB |
Output is correct |
9 |
Correct |
449 ms |
11720 KB |
Output is correct |
10 |
Correct |
673 ms |
14256 KB |
Output is correct |
11 |
Correct |
2 ms |
2644 KB |
Output is correct |
12 |
Correct |
2 ms |
2644 KB |
Output is correct |
13 |
Correct |
2 ms |
2644 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
230 ms |
9236 KB |
Output is correct |
3 |
Correct |
151 ms |
7804 KB |
Output is correct |
4 |
Correct |
2 ms |
2644 KB |
Output is correct |
5 |
Correct |
233 ms |
6732 KB |
Output is correct |
6 |
Correct |
270 ms |
10548 KB |
Output is correct |
7 |
Correct |
2 ms |
2644 KB |
Output is correct |
8 |
Correct |
454 ms |
10188 KB |
Output is correct |
9 |
Correct |
449 ms |
11720 KB |
Output is correct |
10 |
Correct |
673 ms |
14256 KB |
Output is correct |
11 |
Correct |
2 ms |
2644 KB |
Output is correct |
12 |
Correct |
2 ms |
2644 KB |
Output is correct |
13 |
Correct |
2 ms |
2644 KB |
Output is correct |
14 |
Execution timed out |
1067 ms |
15712 KB |
Time limit exceeded |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
2644 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
2 ms |
2644 KB |
Output is partially correct |
2 |
Correct |
13 ms |
6188 KB |
Output is correct |
3 |
Execution timed out |
1074 ms |
9124 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
2 ms |
2644 KB |
Output is partially correct |
2 |
Correct |
13 ms |
6188 KB |
Output is correct |
3 |
Execution timed out |
1074 ms |
9124 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |