이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "doll.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define mp make_pair
#define pub push_back
#define pob pop_back()
#define ss second
#define ff first
#define mt make_tuple
#define pof pop_front()
#define fbo find_by_order
#define ook order_of_key
#define lb lower_bound
#define ub upper_bound
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
using pll = pair <ll, ll>;
using pii = pair <int, int>;
int st[400001], n, k = 1, cnt, cur = 1;
vector<int> X, Y, C;
void solve(int res, int num, int at)
{
if ( num == 1 )
{
Y[-at - 1] = 0;
if ( res == 2 )
X[-at - 1] = 0;
else
X[-at - 1] = -1;
} else {
if ( res <= num )
X[-at - 1] = -1;
else
X[-at - 1] = -(++cur);
Y[-at - 1] = -(++cur);
if ( res > num )
{
solve(res - num, num / 2, X[-at - 1]);
solve(num, num / 2, Y[-at - 1]);
} else{
solve(res, num / 2, Y[-at - 1]);
}
}
}
void dfs(int u, int j )
{
if ( !st[- u - 1] )
{
if ( X[- u - 1] == 0 )
{
X[- u - 1] = j;
st[- u - 1] = 1;
} else {
st[- u - 1] = 1;
dfs(X[- u - 1], j);
}
} else {
if ( Y[- u - 1] == 0 )
{
Y[- u - 1] = j;
st[- u - 1] = 0;
} else {
st[- u - 1] = 0;
dfs(Y[- u - 1], j);
}
}
}
void create_circuit(int M, vector<int> A) {
n = A.size();
X.resize(n + log2(n));
Y.resize(n + log2(n));
while ( k < n )
k *= 2;
C.pub(A[0]);
for (int i = 1; i <= M; i++)
C.pub(-1);
solve(n, k / 2, -1);
for (int i = 1; i < A.size(); i++)
dfs(-1, A[i]);
answer(C, X, Y);
}
컴파일 시 표준 에러 (stderr) 메시지
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:98:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
98 | for (int i = 1; i < A.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... |