이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "Anyalib.h"
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false); cin.tie(NULL)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace
#define all(v) (v).begin(), (v).end()
#define pre(a) cout<<fixed; cout.precision(a)
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,pii> pipii;
const int inf = 1e9;
const ll INF = 1e18;
static int n;
static int a[555];
static int b[555];
static int p[555];
static vector<int> g[555];
static int sum[555];
static int cost[555];
static int num[555];
static int cnt = 500;
static int dist[555];
static void dfs(int x) {
sum[x] = 1;
for(auto i : g[x]) {
if(i == p[x]) continue;
p[i] = x;
dfs(i);
sum[x] += sum[i];
}
if(sum[x] >= 10) {
sum[x] = 0;
num[x] = cnt;
cnt += 9;
}
}
void InitAnya(int N , int A[] , int B[]) {
n = N;
for(int i=0; i<n-1; i++) {
a[i] = A[i];
b[i] = B[i];
g[a[i]].eb(b[i]);
}
dfs(0);
}
void Anya(int C[]) {
for(int i=0; i<n-1; i++) {
if(p[a[i]] == b[i]) cost[a[i]] = C[i];
else cost[b[i]] = C[i];
Save(i, C[i]);
}
for(int i=1; i<n; i++) {
if(num[i] < n) continue;
dist[i] = 0;
for(int j=i; j; j = p[j]) {
dist[i] += cost[j];
}
for(int j=num[i]; j < num[i] + 9; j++) {
if(dist[i] & (1 << j - num[i])) Save(j, 1);
else Save(j, 0);
}
}
}
#include "Borislib.h"
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false); cin.tie(NULL)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace
#define all(v) (v).begin(), (v).end()
#define pre(a) cout<<fixed; cout.precision(a)
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,pii> pipii;
const int inf = 1e9;
const ll INF = 1e18;
static int n;
static int a[555];
static int b[555];
static int p[555];
static vector<int> g[555];
static int sum[555];
static int num[555];
static int cnt = 500;
static int edge[555];
static void dfs(int x) {
sum[x] = 1;
for(auto i : g[x]) {
if(i == p[x]) continue;
p[i] = x;
dfs(i);
sum[x] += sum[i];
}
if(sum[x] >= 10) {
sum[x] = 0;
num[x] = cnt;
cnt += 9;
}
}
void InitBoris(int N , int A[] , int B[]) {
n = N;
for(int i=0; i<n-1; i++) {
a[i] = A[i], b[i] = B[i];
g[a[i]].eb(b[i]);
}
dfs(0);
for(int i=0; i<n-1; i++) {
if(p[a[i]] == b[i]) edge[a[i]] = i;
else edge[b[i]] = i;
}
}
int Boris(int city) {
int i;
int ans = 0;
for(i = city; i != 0; i = p[i]) {
if(sum[i]) ans += Ask(edge[i]);
else {
for(int j = num[i]; j < num[i] + 9; j++) {
ans += Ask(j) << j - num[i];
}
break;
}
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
Anya.cpp: In function 'void Anya(int*)':
Anya.cpp:82:25: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
if(dist[i] & (1 << j - num[i])) Save(j, 1);
~~^~~~~~~~
Boris.cpp: In function 'int Boris(int)':
Boris.cpp:76:24: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
ans += Ask(j) << j - num[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... |