This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "Joi.h"
#include<stdio.h>
void Joi(int N, int M, int A[], int B[], long long X, int T) {
if(T<3){
long long int pow2=1;
for(int i=0;i<N;i++){
if(i<60){
pow2*=2;
if(X%pow2<pow2/2){
MessageBoard(i,0);
}
else{
MessageBoard(i,1);
}
}
else{
MessageBoard(i,0);
}
}
}
if(T==3){
int arr[60];
long long int pow2=1;
for(int i=0;i<60;i++){
pow2*=2;
if(X%pow2<pow2/2){
arr[i]=0;
}
else{
arr[i]=1;
}
}
for(int i=0;i<N;i++){
MessageBoard(i,arr[i%60]);
}
}
}
#include "Ioi.h"
#include<vector>
#include<queue>
#include<stdio.h>
using namespace std;
int arr[2000000];
int dist[2000000];
void check(int node,vector<int>nei[]){
for(int i=0;i<nei[node].size();i++){
int v=nei[node][i];
if(dist[v]>dist[node]){
arr[v]=Move(v);
check(v,nei);
arr[node]=Move(node);
}
}
}
long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
if(T<3){
vector<int>nei[N];
for(int i=0;i<M;i++){
nei[A[i]].push_back(B[i]);
nei[B[i]].push_back(A[i]);
}
for(int i=0;i<N;i++){
arr[i]=-1;
dist[i]=-1;
}
dist[P]=0;
queue<int>q;
q.push(P);
arr[P]=V;
while(!q.empty()){
int u=q.front();q.pop();
for(int i=0;i<nei[u].size();i++){
int v=nei[u][i];
if(dist[v]==-1){
q.push(v);
dist[v]=dist[u]+1;
}
}
}
check(P,nei);
long long int X=0;
long long int pow2=1;
for(int i=0;i<60;i++){
if(arr[i]==1){
X+=pow2;
}
pow2+=pow2;
}
return X;
}
if(T==3){
int X[60];
int currentIndex=P;
int direction=1;
int moves=0;
if(currentIndex==N-1){
direction=-1;
}
while(moves<=240){
if(currentIndex==N-2 && direction==1){
X[(N-1)%60]=Move(N-1);
direction=-1;
currentIndex++;
}
else if(currentIndex==1 && direction==-1){
X[0]=Move(0);
direction=1;
currentIndex--;
}
else{
X[(currentIndex+direction)%60]=Move(currentIndex+direction);
currentIndex+=direction;
}
moves++;
}
long long int ans=0;
long long int pow2=1;
for(int i=0;i<60;i++){
if(X[i]==1){
ans+=pow2;
}
pow2+=pow2;
}
return ans;
}
}
Compilation message (stderr)
Ioi.cpp: In function 'void check(int, std::vector<int>*)':
Ioi.cpp:9:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<nei[node].size();i++){
~^~~~~~~~~~~~~~~~~
Ioi.cpp: In function 'long long int Ioi(int, int, int*, int*, int, int, int)':
Ioi.cpp:37:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<nei[u].size();i++){
~^~~~~~~~~~~~~~
Ioi.cpp:94:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# | 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... |