# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
49928 | MatheusLealV | Amusement Park (JOI17_amusement_park) | C++17 | 44 ms | 11520 KiB |
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 <bits/stdc++.h>
#define maxn 10005
#define f first
#define s second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
static int idx[maxn], pai[maxn], deep[maxn], cnt, maior;
static vector<int> grafo[maxn], tree[maxn];
void dfs(int x)
{
idx[x] = cnt++;
maior = max(maior, deep[x] + 1);
for(auto v: grafo[x])
{
if(idx[v] != -1) continue;
pai[v] = x;
deep[v] = deep[x] + 1;
tree[x].push_back(v);
tree[v].push_back(x);
dfs(v);
}
}
void Joi(int N, int M, int A[], int B[], ll X, int T)
{
memset(idx, -1, sizeof idx);
for(int i = 0; i < M; i++)
{
grafo[A[i]].push_back(B[i]);
grafo[B[i]].push_back(A[i]);
}
for(int i = 0; i < N; i++) sort(grafo[i].begin(), grafo[i].end());
dfs(0);
for(int i = 0; i < N; i++)
{
idx[i] = idx[i] % 60;
if(X & (1LL<<idx[i])) MessageBoard(i, 1);
else MessageBoard(i, 0);
}
}
#include "Ioi.h"
#include <bits/stdc++.h>
#define maxn 10005
#define f first
#define s second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
static ll idx2[maxn], pai2[maxn], deep2[maxn], cnt2, maior2, dp[maxn];
static ll opt[maxn], ini[maxn], fim[maxn], save[maxn];
static vector<ll> grafo2[maxn], tree2[maxn], euler;
static ll ans = 0;
static set<ll> usados, tem[maxn];
void dfs2(int x)
{
idx2[x] = cnt2++;
euler.push_back(x);
maior2 = max(maior2, deep2[x] + 1);
dp[x] = 0;
for(auto v: grafo2[x])
{
if(idx2[v] != -1) continue;
pai2[v] = x;
deep2[v] = deep2[x] + 1;
tree2[x].push_back(v);
tree2[v].push_back(x);
dfs2(v);
euler.push_back(x);
if(dp[v] + 1 > dp[x]) dp[x] = dp[v] + 1, opt[x] = v;
}
}
ll Ioi(int N, int M, int A[], int B[], int P, int V, int T)
{
memset(idx2, -1, sizeof idx2);
int Vo = V;
for(int i = 0; i < M; i++)
{
grafo2[A[i]].push_back(B[i]);
grafo2[B[i]].push_back(A[i]);
}
for(int i = 0; i < N; i++) sort(grafo2[i].begin(), grafo2[i].end());
dfs2(0);
for(int i = 0; i < N; i++) idx2[i] = (idx2[i] % 60);
ll t = 0, save;
for(int i = 0; i < euler.size(); i++)
{
if(euler[i] == P)
{
t = save = i;
break;
}
}
ll pos = 0;
pos |= (1LL<<idx2[P]);
t ++;
for(int cnt = 0; cnt < 120 ; cnt ++)
{
if(t >= euler.size() - 1) t = 0;
ll x = euler[t];
pos |= (1LL<<idx2[x]);
t ++;
}
//cout<<pos<<" "<<((1LL<<60) - 1LL)<<"\n";
if(pos == ((1LL<<60) - 1LL))
{
if(Vo) ans |= (1LL<<idx2[P]);
t = save + 1;
for(int cnt = 0; cnt < 120 ; cnt ++)
{
if(t >= euler.size() - 1) t = 0;
ll x = euler[t];
V = Move(x);
if(V) ans |= (1LL<<idx2[x]);
t ++;
}
//cout<<ans<<"\n";
return ans;
}
else
{
//for(auto tt: euler) cout<<tt<<" ";
//cout<<"\n";
if(Vo) ans |= (1LL<<idx2[P]);
t = save - 1;
//cout<<t<<"\n";
ll aux = 1LL<<idx2[P];
for(int cnt = 0; cnt < 120 ; cnt ++)
{
if(t <= 0) t = euler.size() - 1;
ll x = euler[t];
V = Move(x);
aux |= (1LL<<idx2[x]);
if(V) ans |= (1LL<<idx2[x]);
t --;
}
return ans;
}
}
Compilation message (stderr)
# | 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... |