#include "Joi.h"
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template<class T> ostream& operator<<(ostream& stream, const vector<T> v){ stream << "[ "; for (int i=0; i<(int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream;}
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
const int N = 1e6 + 5;
static vi e;
static vi g[N];
static void dfs(int node,int prev) {
e.pb(node);
for (auto it : g[node])
if (it != prev) {
dfs(it,node);
}
}
static int f[N];
static int get(int k) {
return k == f[k] ? k : f[k] = get(f[k]);
}
static int n;
void Joi(int N, int M, int A[], int B[], long long X, int T) {
n = N;
for (int i = 0;i < n;++i)
f[i] = i;
for (int i = 0;i < M;++i) {
if (get(A[i]) == get(B[i]))
continue;
g[A[i]].pb(B[i]);
g[B[i]].pb(A[i]);
f[get(A[i])] = get(B[i]);
}
dfs(0,-1);
for (int i = 0;i < n;++i)
MessageBoard(e[i],(X >> (i % 60)) & 1);
}
#include "Ioi.h"
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template<class T> ostream& operator<<(ostream& stream, const vector<T> v){ stream << "[ "; for (int i=0; i<(int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream;}
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
const int N = 1e6 + 5;
static vi e;
static vi g[N];
static void dfs(int node,int prev) {
e.pb(node);
for (auto it : g[node])
if (it != prev) {
dfs(it,node);
}
}
static int f[N];
static int was[N];
static int has[N];
static int get(int k) {
return k == f[k] ? k : f[k] = get(f[k]);
}
static int n;
static int Last;
void DFS(int node,int prev) {
if (Last != node) {
int nxt = Move(node);
if (has[node] == -1)
has[node] = nxt;
Last = node;
}
for (auto it : g[node]) {
if (it == prev || was[it] == -1)
continue;
DFS(it,node);
if (Last != node)
Move(node),Last = node;
}
}
long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
n = N;
for (int i = 0;i < n;++i)
f[i] = i;
for (int i = 0;i < M;++i) {
if (get(A[i]) == get(B[i]))
continue;
g[A[i]].pb(B[i]);
g[B[i]].pb(A[i]);
f[get(A[i])] = get(B[i]);
}
dfs(0,-1);
int pos = -1;
for (int i = 0;i < n;++i)
if (e[i] == P)
pos = i;
int lf = max(0,pos - 59);
int rg = lf + 60;
assert(0 <= lf && lf < rg && rg <= n);
assert(rg - lf + 1 == 60);
assert(lf <= pos && pos < rg);
for (int i = 0;i < n;++i)
was[i] = -1,has[i] = -1;
for (int i = lf;i < rg;++i)
was[e[i]] = (i % 60);
has[P] = V;
Last = P;
DFS(P,-1);
ll answer = 0;
for (int i = 0;i < n;++i)
if (was[i] != -1)
answer += (1ll << was[i]) * has[i];
return answer;
}
Compilation message
In file included from /usr/include/c++/7/cassert:44:0,
from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:33,
from Ioi.cpp:2:
Ioi.cpp: In function 'long long int Ioi(int, int, int*, int*, int, int, int)':
Ioi.cpp:81:25: warning: assuming signed overflow does not occur when assuming that (X + c) >= X is always true [-Wstrict-overflow]
assert(0 <= lf && lf < rg && rg <= n);
~~~^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
66 ms |
71548 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
111 ms |
98592 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
85 ms |
99536 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
107 ms |
99536 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
115 ms |
99728 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |