#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
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]
}
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
608 KB |
Output is correct |
2 |
Correct |
4 ms |
1080 KB |
Output is correct |
3 |
Correct |
4 ms |
1168 KB |
Output is correct |
4 |
Correct |
4 ms |
1256 KB |
Output is correct |
5 |
Correct |
4 ms |
1256 KB |
Output is correct |
6 |
Correct |
4 ms |
1256 KB |
Output is correct |
7 |
Correct |
4 ms |
1256 KB |
Output is correct |
8 |
Correct |
4 ms |
1340 KB |
Output is correct |
9 |
Correct |
4 ms |
1424 KB |
Output is correct |
10 |
Correct |
4 ms |
1424 KB |
Output is correct |
11 |
Correct |
8 ms |
1452 KB |
Output is correct |
12 |
Correct |
4 ms |
1480 KB |
Output is correct |
13 |
Correct |
4 ms |
1480 KB |
Output is correct |
14 |
Correct |
5 ms |
1480 KB |
Output is correct |
15 |
Correct |
4 ms |
1480 KB |
Output is correct |
16 |
Correct |
4 ms |
1480 KB |
Output is correct |
17 |
Correct |
4 ms |
1480 KB |
Output is correct |
18 |
Correct |
4 ms |
1564 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
30 ms |
3364 KB |
Wrong Answer [8] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
4072 KB |
Output is correct |
2 |
Correct |
4 ms |
4072 KB |
Output is correct |
3 |
Correct |
4 ms |
4072 KB |
Output is correct |
4 |
Correct |
5 ms |
4072 KB |
Output is correct |
5 |
Correct |
7 ms |
4072 KB |
Output is correct |
6 |
Correct |
5 ms |
4072 KB |
Output is correct |
7 |
Correct |
5 ms |
4072 KB |
Output is correct |
8 |
Correct |
5 ms |
4072 KB |
Output is correct |
9 |
Correct |
13 ms |
4072 KB |
Output is correct |
10 |
Correct |
13 ms |
4072 KB |
Output is correct |
11 |
Correct |
13 ms |
4072 KB |
Output is correct |
12 |
Correct |
4 ms |
4072 KB |
Output is correct |
13 |
Correct |
4 ms |
4072 KB |
Output is correct |
14 |
Correct |
3 ms |
4072 KB |
Output is correct |
15 |
Correct |
4 ms |
4072 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
11 ms |
4072 KB |
Wrong Answer [4] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
11 ms |
4072 KB |
Wrong Answer [4] |
2 |
Halted |
0 ms |
0 KB |
- |