#include "Joi.h"
#include <bits/stdc++.h>
using namespace std;
static vector<vector<int>> adj;
static int tim;
static vector<int> ts;
static vector<int> path;
static void dfs(int u) {
ts[u] = tim++;
path.push_back(u);
for(int v : adj[u]) {
if(ts[v] == -1) {
dfs(v);
path.push_back(u);
}
}
}
static void find_tree(int n, int m, int A[], int B[]) {
adj.assign(n, vector<int>());
path.clear();
tim = 0;
for(int i = 0; i < m; ++i) {
adj[A[i]].push_back(B[i]);
adj[B[i]].push_back(A[i]);
}
ts.assign(n, -1);
dfs(0);
}
void Joi(int n, int m, int A[], int B[], long long X, int T) {
int seq[60];
//cout << "seq: { ";
for(int i = 0; i < 60; ++i) {
seq[i] = ((X&(1LL << i)) > 0);
//cout << seq[i] << ", ";
}
//cout << "}" << endl;
find_tree(n, m, A, B);
for(int i = 0; i < n; ++i) {
assert(ts[i] != -1);
MessageBoard(i, seq[ts[i]%60]);
}
}
#include "Ioi.h"
#include <bits/stdc++.h>
using namespace std;
static vector<vector<int>> adj;
static int tim;
static vector<int> ts;
static vector<int> path;
static void dfs(int u) {
ts[u] = tim++;
path.push_back(u);
for(int v : adj[u]) {
if(ts[v] == -1) {
dfs(v);
path.push_back(u);
}
}
}
static void find_tree(int n, int m, int A[], int B[]) {
adj.assign(n, vector<int>());
path.clear();
tim = 0;
for(int i = 0; i < m; ++i) {
adj[A[i]].push_back(B[i]);
adj[B[i]].push_back(A[i]);
}
ts.assign(n, -1);
dfs(0);
}
long long Ioi(int n, int m, int A[], int B[], int p, int v, int T) {
find_tree(n, m, A, B);
int seq[60];
seq[ts[p]%60] = v;
int i;
for(i = 0; i < path.size()-1; ++i) {
if(path[i] == p) {
break;
}
}
if(path[i] != p) while(true);
if(path.front() != path.back()) while(true);
for(int k = 0; k < 120; ++k) {
int prev = i;
i = (i+1)%path.size();
if(i == path.size()-1) {
i = 0;
}
if(find(adj[path[prev]].begin(), adj[path[prev]].end(), path[i]) == adj[path[prev]].end()) while(true);
int res = Move(path[i]);
seq[ts[path[i]]%60] = res;
}
long long X = 0;
for(int j = 0; j < 60; ++j)
X |= ((long long)seq[j]) << j;
return X;
}
Compilation message
Ioi.cpp: In function 'long long int Ioi(int, int, int*, int*, int, int, int)':
Ioi.cpp:39:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(i = 0; i < path.size()-1; ++i) {
~~^~~~~~~~~~~~~~~
Ioi.cpp:49:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(i == path.size()-1) {
~~^~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
608 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
4780 KB |
Output is correct |
2 |
Correct |
35 ms |
4792 KB |
Output is correct |
3 |
Correct |
32 ms |
4800 KB |
Output is correct |
4 |
Correct |
22 ms |
4808 KB |
Output is correct |
5 |
Incorrect |
22 ms |
4808 KB |
Wrong Answer [7] |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
4808 KB |
Output is correct |
2 |
Correct |
4 ms |
4808 KB |
Output is correct |
3 |
Correct |
5 ms |
4808 KB |
Output is correct |
4 |
Correct |
6 ms |
4808 KB |
Output is correct |
5 |
Correct |
7 ms |
4808 KB |
Output is correct |
6 |
Correct |
6 ms |
4808 KB |
Output is correct |
7 |
Correct |
9 ms |
4808 KB |
Output is correct |
8 |
Correct |
6 ms |
4808 KB |
Output is correct |
9 |
Correct |
19 ms |
4808 KB |
Output is correct |
10 |
Correct |
18 ms |
4808 KB |
Output is correct |
11 |
Correct |
17 ms |
4808 KB |
Output is correct |
12 |
Correct |
4 ms |
4808 KB |
Output is correct |
13 |
Correct |
4 ms |
4808 KB |
Output is correct |
14 |
Correct |
5 ms |
4808 KB |
Output is correct |
15 |
Correct |
5 ms |
4808 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
4992 KB |
Output is correct |
2 |
Incorrect |
37 ms |
5060 KB |
Wrong Answer [7] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
35 ms |
5128 KB |
Output is correct |
2 |
Correct |
31 ms |
5128 KB |
Output is correct |
3 |
Incorrect |
31 ms |
5128 KB |
Wrong Answer [7] |
4 |
Halted |
0 ms |
0 KB |
- |