#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
#include "Joi.h"
vector<int>E[20000];
vector<int>vs;
bool used[20000];
void dfs(int v,int p){
used[v]=true;
vs.push_back(v);
for(int u:E[v]){
if(used[u])continue;
dfs(u,v);
vs.push_back(v);
}
}
void Joi(int N, int M, int A[], int B[], long long X, int T) {
rep(i,M){
E[A[i]].push_back(B[i]);
E[B[i]].push_back(A[i]);
}
dfs(0,-1);
set<int>se1,se2;
mt19937 mt(123456789);
vector<int>V;
rep(i,60)V.push_back(i);
int MP[60]{};
for(int v:vs){
if(!se1.count(v)){
se2.insert(v);
}
if(se2.size()==60){
int cnt=0;
shuffle(V.begin(),V.end(),mt);
for(int i:se2){
MP[V[cnt]]++;
MessageBoard(i,X>>V[cnt]&1);
cnt++;
}
for(int i:se2){
se1.insert(i);
}
se2.clear();
}
}
shuffle(V.begin(),V.end(),mt);
int cnt=0;
for(int i:se2){
MP[V[cnt]]++;
MessageBoard(i,X>>V[cnt]&1);
cnt++;
}
}
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
#include "Ioi.h"
static vector<int>E[20000];
static vector<int>vs;
static int vid[20000];
static bool used[20000];
static void dfs(int v,int p){
used[v]=true;
vid[v]=vs.size();
vs.push_back(v);
for(int u:E[v]){
if(used[u])continue;
dfs(u,v);
vs.push_back(v);
}
}
long long Ioi(int N, int M, int A[], int B[], int Pos, int V, int T) {
rep(i,M){
E[A[i]].push_back(B[i]);
E[B[i]].push_back(A[i]);
}
dfs(0,-1);
set<int>se1,se2;
map<int,int>id;
mt19937 mt(123456789);
vector<int>R;
rep(i,60)R.push_back(i);
for(int v:vs){
if(!se1.count(v)){
se2.insert(v);
}
if(se2.size()==60){
shuffle(R.begin(),R.end(),mt);
int cnt=0;
for(int i:se2){
id[i]=R[cnt];
cnt++;
}
for(int i:se2){
se1.insert(i);
}
se2.clear();
}
}
int cnt=0;
shuffle(R.begin(),R.end(),mt);
for(int i:se2){
id[i]=R[cnt];
cnt++;
}
int x=vid[Pos];
set<int>se;
int r;
for(r=x;r<vs.size();r++){
se.insert(id[vs[r]]);
if(se.size()==60)break;
}
if(r==vs.size())r=vs.size()-1;
int l;
for(l=x;l>=0;l--){
se.insert(id[vs[l]]);
if(se.size()==60)break;
}
if(l==-1)l=0;
set<int>Se;
int l2;
for(l2=x;l2>=0;l2--){
Se.insert(id[vs[l2]]);
if(Se.size()==60)break;
}
if(l2==-1)l2=0;
int r2;
for(r2=x;r2<vs.size();r2++){
Se.insert(id[vs[r2]]);
if(Se.size()==60)break;
}
if(r2==vs.size())r2=vs.size()-1;
if(r2-l2+min(r2-x,x-l2)<r-l+min(r-x,x-l)){
swap(l,l2);
swap(r,r2);
}
set<int>SE;
int l3=x,r3=x;
while(1){
if(l3>0){
SE.insert(id[vs[--l3]]);
}
if(r3<vs.size()-1){
SE.insert(id[vs[++r3]]);
}
if(SE.size()==60)break;
}
if(r3-l3+min(r3-x,x-l3)<r-l+min(r-x,x-l)){
swap(l,l3);
swap(r,r3);
}
map<int,vector<int>>MP;
rep(i,vs.size()){
MP[id[vs[i]]].push_back(i);
}
int l4=x,r4=x;
rep(i,60){
int Min=INT_MAX;
int t=-1;
auto it=lower_bound(MP[i].begin(),MP[i].end(),x);
if(it!=MP[i].end()){
Min=*it-x;
t=*it;
}
if(it!=MP[i].begin()){
it--;
if(Min>x-*it){
Min=x-*it;
t=*it;
}
}
if(Min>900){
abort();
}
l4=min(l4,*it);
r4=max(r4,*it);
}
if(r4-l4+min(r4-x,x-l4)<r-l+min(r-x,x-l)){
swap(l,l4);
swap(r,r4);
}
ll ans=0;
ans|=ll(V)<<id[Pos];
if(abs(x-l)<abs(x-r)){
//left
for(int i=x-1;i>=l;i--){
ans|=ll(Move(vs[i]))<<id[vs[i]];
}
for(int i=l+1;i<=r;i++){
ans|=ll(Move(vs[i]))<<id[vs[i]];
}
}
else{
//right
for(int i=x+1;i<=r;i++){
ans|=ll(Move(vs[i]))<<id[vs[i]];
}
for(int i=r-1;i>=l;i--){
ans|=ll(Move(vs[i]))<<id[vs[i]];
}
}
return ans;
}
Compilation message
Ioi.cpp: In function 'long long int Ioi(int, int, int*, int*, int, int, int)':
Ioi.cpp:63:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(r=x;r<vs.size();r++){
~^~~~~~~~~~
Ioi.cpp:67:6: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(r==vs.size())r=vs.size()-1;
~^~~~~~~~~~~
Ioi.cpp:83:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(r2=x;r2<vs.size();r2++){
~~^~~~~~~~~~
Ioi.cpp:87:7: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(r2==vs.size())r2=vs.size()-1;
~~^~~~~~~~~~~
Ioi.cpp:99:8: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(r3<vs.size()-1){
~~^~~~~~~~~~~~
Ioi.cpp:2:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
#define rep(i,n)for(int i=0;i<(n);i++)
^
Ioi.cpp:111:2: note: in expansion of macro 'rep'
rep(i,vs.size()){
^~~
Ioi.cpp:117:7: warning: variable 't' set but not used [-Wunused-but-set-variable]
int t=-1;
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
1928 KB |
Output is correct |
2 |
Correct |
7 ms |
1928 KB |
Output is correct |
3 |
Correct |
7 ms |
1932 KB |
Output is correct |
4 |
Correct |
6 ms |
1812 KB |
Output is correct |
5 |
Correct |
6 ms |
1908 KB |
Output is correct |
6 |
Correct |
5 ms |
1792 KB |
Output is correct |
7 |
Correct |
8 ms |
2016 KB |
Output is correct |
8 |
Correct |
5 ms |
1932 KB |
Output is correct |
9 |
Correct |
4 ms |
1924 KB |
Output is correct |
10 |
Correct |
6 ms |
1792 KB |
Output is correct |
11 |
Correct |
11 ms |
2096 KB |
Output is correct |
12 |
Correct |
5 ms |
1924 KB |
Output is correct |
13 |
Correct |
6 ms |
1804 KB |
Output is correct |
14 |
Correct |
7 ms |
1804 KB |
Output is correct |
15 |
Correct |
6 ms |
2012 KB |
Output is correct |
16 |
Correct |
7 ms |
1932 KB |
Output is correct |
17 |
Correct |
8 ms |
1880 KB |
Output is correct |
18 |
Correct |
8 ms |
1932 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
62 ms |
6212 KB |
Output is correct |
2 |
Correct |
60 ms |
6456 KB |
Output is correct |
3 |
Correct |
71 ms |
6212 KB |
Output is correct |
4 |
Correct |
42 ms |
4928 KB |
Output is correct |
5 |
Correct |
55 ms |
5432 KB |
Output is correct |
6 |
Correct |
49 ms |
5176 KB |
Output is correct |
7 |
Correct |
60 ms |
5176 KB |
Output is correct |
8 |
Correct |
41 ms |
5304 KB |
Output is correct |
9 |
Correct |
46 ms |
5304 KB |
Output is correct |
10 |
Correct |
46 ms |
5104 KB |
Output is correct |
11 |
Correct |
41 ms |
5152 KB |
Output is correct |
12 |
Correct |
43 ms |
4656 KB |
Output is correct |
13 |
Correct |
41 ms |
4528 KB |
Output is correct |
14 |
Correct |
41 ms |
4792 KB |
Output is correct |
15 |
Correct |
46 ms |
5108 KB |
Output is correct |
16 |
Correct |
39 ms |
4920 KB |
Output is correct |
17 |
Correct |
51 ms |
4920 KB |
Output is correct |
18 |
Correct |
40 ms |
4800 KB |
Output is correct |
19 |
Correct |
55 ms |
4956 KB |
Output is correct |
20 |
Correct |
31 ms |
5344 KB |
Output is correct |
21 |
Correct |
34 ms |
5312 KB |
Output is correct |
22 |
Correct |
53 ms |
5120 KB |
Output is correct |
23 |
Correct |
57 ms |
5304 KB |
Output is correct |
24 |
Correct |
41 ms |
5184 KB |
Output is correct |
25 |
Correct |
56 ms |
5284 KB |
Output is correct |
26 |
Correct |
39 ms |
5308 KB |
Output is correct |
27 |
Correct |
39 ms |
5312 KB |
Output is correct |
28 |
Correct |
45 ms |
5372 KB |
Output is correct |
29 |
Correct |
49 ms |
4992 KB |
Output is correct |
30 |
Correct |
47 ms |
5208 KB |
Output is correct |
31 |
Correct |
5 ms |
1664 KB |
Output is correct |
32 |
Correct |
5 ms |
2036 KB |
Output is correct |
33 |
Correct |
6 ms |
1804 KB |
Output is correct |
34 |
Correct |
6 ms |
1928 KB |
Output is correct |
35 |
Correct |
6 ms |
1928 KB |
Output is correct |
36 |
Correct |
5 ms |
1792 KB |
Output is correct |
37 |
Correct |
6 ms |
1696 KB |
Output is correct |
38 |
Correct |
6 ms |
1916 KB |
Output is correct |
39 |
Correct |
7 ms |
1664 KB |
Output is correct |
40 |
Correct |
6 ms |
1796 KB |
Output is correct |
41 |
Correct |
6 ms |
1956 KB |
Output is correct |
42 |
Correct |
6 ms |
1928 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
1928 KB |
Output is correct |
2 |
Correct |
6 ms |
1908 KB |
Output is correct |
3 |
Correct |
7 ms |
1664 KB |
Output is correct |
4 |
Correct |
12 ms |
2588 KB |
Output is correct |
5 |
Correct |
10 ms |
2388 KB |
Output is correct |
6 |
Correct |
11 ms |
2468 KB |
Output is correct |
7 |
Correct |
11 ms |
2468 KB |
Output is correct |
8 |
Correct |
9 ms |
2468 KB |
Output is correct |
9 |
Correct |
31 ms |
5832 KB |
Output is correct |
10 |
Correct |
31 ms |
5832 KB |
Output is correct |
11 |
Correct |
30 ms |
5896 KB |
Output is correct |
12 |
Correct |
7 ms |
1916 KB |
Output is correct |
13 |
Correct |
3 ms |
1572 KB |
Output is correct |
14 |
Correct |
6 ms |
1928 KB |
Output is correct |
15 |
Correct |
5 ms |
1920 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
54 ms |
6220 KB |
Output is correct |
2 |
Partially correct |
65 ms |
6328 KB |
Partially correct |
3 |
Partially correct |
66 ms |
6092 KB |
Partially correct |
4 |
Partially correct |
47 ms |
4928 KB |
Partially correct |
5 |
Correct |
53 ms |
5604 KB |
Output is correct |
6 |
Partially correct |
41 ms |
5476 KB |
Partially correct |
7 |
Correct |
46 ms |
5312 KB |
Output is correct |
8 |
Correct |
44 ms |
5148 KB |
Output is correct |
9 |
Correct |
50 ms |
5200 KB |
Output is correct |
10 |
Correct |
37 ms |
5064 KB |
Output is correct |
11 |
Partially correct |
48 ms |
4928 KB |
Partially correct |
12 |
Partially correct |
40 ms |
4520 KB |
Partially correct |
13 |
Partially correct |
36 ms |
4604 KB |
Partially correct |
14 |
Partially correct |
53 ms |
4792 KB |
Partially correct |
15 |
Partially correct |
42 ms |
4920 KB |
Partially correct |
16 |
Partially correct |
43 ms |
5008 KB |
Partially correct |
17 |
Partially correct |
41 ms |
4852 KB |
Partially correct |
18 |
Correct |
50 ms |
4880 KB |
Output is correct |
19 |
Partially correct |
56 ms |
4832 KB |
Partially correct |
20 |
Partially correct |
31 ms |
5320 KB |
Partially correct |
21 |
Partially correct |
27 ms |
5312 KB |
Partially correct |
22 |
Correct |
41 ms |
5304 KB |
Output is correct |
23 |
Correct |
41 ms |
5320 KB |
Output is correct |
24 |
Partially correct |
54 ms |
5176 KB |
Partially correct |
25 |
Correct |
43 ms |
5440 KB |
Output is correct |
26 |
Partially correct |
46 ms |
5312 KB |
Partially correct |
27 |
Partially correct |
56 ms |
5304 KB |
Partially correct |
28 |
Correct |
47 ms |
5228 KB |
Output is correct |
29 |
Correct |
38 ms |
4828 KB |
Output is correct |
30 |
Correct |
45 ms |
5056 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
48 ms |
6220 KB |
Output is correct |
2 |
Correct |
52 ms |
6340 KB |
Output is correct |
3 |
Incorrect |
54 ms |
6344 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |