이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "doll.h"
#include<bits/stdc++.h>
using namespace std;
#define all(aaa) aaa.begin(), aaa.end()
const int N = 8e5 + 5;
vector<int> tot, tosx, tosy, ct, w;
int z = 0, root = -1;
vector<int> ch[N];
int state[N];
int build(int L, int R) {
if (L == R)
return 0;
int v = ++z,
m = (L + R) >> 1;
ch[v] = {build(L, m), build(m + 1, R)};
return -v;
}
void upd(int x, int &v) {
if (v == 0) {
v = x;
}
else {
upd(x, ch[-v][state[-v]]);
state[-v] ^= 1;
}
}
void create_circuit(int m, vector<int> a) {
tot.resize(m + 1);
ct.resize(m + 1);
a.insert(a.begin(), 0);
for (int x : a)
ct[x]++;
a.push_back(0);
int n = a.size();
// for (int x : a)
// cout << x << " ";
// cout << "\n";
for (int i = 0; i < n - 1; i++) {
if (ct[a[i]] == 1) {
tot[a[i]] = a[i + 1];
}
else {
tot[a[i]] = -1;
w.push_back(a[i + 1]);
}
}
// for (int i = 0; i <= m; i++) {
// cout << tot[i] << " ";
// }
// cout << "\n";
if (!w.empty()) {
int k = 1;
while (k < w.size())
k *= 2;
build(0, k - 1);
for (int i = 0; i < k - w.size(); i++)
upd(root, root);
for (int x : w) {
upd(x, root);
}
}
tosx.resize(z);
tosy.resize(z);
for (int i = 1; i <= z; i++) {
tosx[i - 1] = ch[i][0];
tosy[i - 1] = ch[i][1];
}
// for (int x : tot)
// cout << x << " ";
// cout << "\n";
// for (int x : tosx)
// cout << x << " ";
// cout << "\n";
// for (int x : tosy)
// cout << x << " ";
// cout << "\n";
answer(tot, tosx, tosy);
}
컴파일 시 표준 에러 (stderr) 메시지
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:68:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
68 | while (k < w.size())
| ~~^~~~~~~~~~
doll.cpp:73:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
73 | for (int i = 0; i < k - w.size(); i++)
| ~~^~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |