Submission #49927

# Submission time Handle Problem Language Result Execution time Memory
49927 2018-06-05T03:32:06 Z MatheusLealV Amusement Park (JOI17_amusement_park) C++17
10 / 100
46 ms 9168 KB
#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]);
	}

	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]);
	}

	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 ++;
	}

	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 ++;
		}

		return ans;
	}
	else
	{
		//cout<<"penis\n";
		//for(auto tt: euler) cout<<tt<<" ";

		//cout<<"\n";
		if(Vo) ans |= (1LL<<idx2[P]);

		t = save - 1;

		//cout<<t<<"\n";

		for(int cnt = 0; cnt < 120 ; cnt ++)
		{
			if(t <= 0) t = euler.size() - 1;

			ll x = euler[t];

			//cout<<"MOVE "<<euler[ (t + 1)%euler.size() ]<<" "<<x<<"\n";

			V = Move(x);

			if(V) ans |= (1LL<<idx2[x]);

			t --;
		}

		return ans;
	}
}

Compilation message

Ioi.cpp: In function 'll Ioi(int, int, int*, int*, int, int, int)':
Ioi.cpp:69:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < euler.size(); i++)
                 ~~^~~~~~~~~~~~~~
Ioi.cpp:87:8: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(t >= euler.size() - 1) t = 0;
      ~~^~~~~~~~~~~~~~~~~~~
Ioi.cpp:104:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(t >= euler.size() - 1) t = 0;
       ~~^~~~~~~~~~~~~~~~~~~
Ioi.cpp: At global scope:
Ioi.cpp:12:44: warning: 'save' defined but not used [-Wunused-variable]
 static ll opt[maxn], ini[maxn], fim[maxn], save[maxn];
                                            ^~~~
Ioi.cpp:12:33: warning: 'fim' defined but not used [-Wunused-variable]
 static ll opt[maxn], ini[maxn], fim[maxn], save[maxn];
                                 ^~~
Ioi.cpp:12:22: warning: 'ini' defined but not used [-Wunused-variable]
 static ll opt[maxn], ini[maxn], fim[maxn], save[maxn];
                      ^~~
Ioi.cpp: In function 'll Ioi(int, int, int*, int*, int, int, int)':
Ioi.cpp:100:5: warning: 'save' may be used uninitialized in this function [-Wmaybe-uninitialized]
   t = save + 1;
   ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 2280 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 46 ms 6460 KB Output is correct
2 Correct 36 ms 7772 KB Output is correct
3 Correct 36 ms 8028 KB Output is correct
4 Correct 24 ms 8208 KB Output is correct
5 Correct 32 ms 8208 KB Output is correct
6 Correct 24 ms 8208 KB Output is correct
7 Correct 26 ms 8208 KB Output is correct
8 Correct 27 ms 8208 KB Output is correct
9 Incorrect 25 ms 8208 KB Wrong Answer [7]
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 8208 KB Output is correct
2 Correct 5 ms 8208 KB Output is correct
3 Correct 5 ms 8208 KB Output is correct
4 Correct 9 ms 8208 KB Output is correct
5 Correct 8 ms 8208 KB Output is correct
6 Correct 7 ms 8208 KB Output is correct
7 Correct 9 ms 8208 KB Output is correct
8 Correct 8 ms 8208 KB Output is correct
9 Correct 27 ms 8424 KB Output is correct
10 Correct 31 ms 8640 KB Output is correct
11 Correct 30 ms 8640 KB Output is correct
12 Correct 6 ms 8640 KB Output is correct
13 Correct 7 ms 8640 KB Output is correct
14 Correct 6 ms 8640 KB Output is correct
15 Correct 7 ms 8640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 40 ms 8900 KB Output is correct
2 Correct 40 ms 9160 KB Output is correct
3 Incorrect 41 ms 9160 KB Wrong Answer [7]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 44 ms 9164 KB Output is correct
2 Correct 46 ms 9168 KB Output is correct
3 Incorrect 42 ms 9168 KB Wrong Answer [7]
4 Halted 0 ms 0 KB -