Submission #100997

# Submission time Handle Problem Language Result Execution time Memory
100997 2019-03-16T02:06:51 Z autumn_eel Amusement Park (JOI17_amusement_park) C++14
28 / 100
59 ms 6228 KB
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

#include "Joi.h"

vector<int>E[20000];
vector<int>vs;
bool used[20000];

void dfs(int v,int p){
	used[v]=true;
	vs.push_back(v);
	for(int u:E[v]){
		if(used[u])continue;
		dfs(u,v);
		vs.push_back(v);
	}
}

void Joi(int N, int M, int A[], int B[], long long X, int T) {
	rep(i,M){
		E[A[i]].push_back(B[i]);
		E[B[i]].push_back(A[i]);
	}
	dfs(0,-1);
	set<int>se1,se2;
	for(int v:vs){
		if(!se1.count(v)){
			se2.insert(v);
		}
		if(se2.size()==60){
			int cnt=0;
			for(int i:se2){
				MessageBoard(i,X>>cnt&1);
				cnt++;
			}
			for(int i:se2){
				se1.insert(i);
			}
			se2.clear();
		}
	}
	int cnt=0;
	for(int i:se2){
		MessageBoard(i,X>>cnt&1);
		cnt++;
	}
}
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

#include "Ioi.h"

static vector<int>E[20000];
static vector<int>vs;
static int vid[20000];
static bool used[20000];

static void dfs(int v,int p){
	used[v]=true;
	vid[v]=vs.size();
	vs.push_back(v);
	for(int u:E[v]){
		if(used[u])continue;
		dfs(u,v);
		vs.push_back(v);
	}
}

long long Ioi(int N, int M, int A[], int B[], int Pos, int V, int T) {
	rep(i,M){
		E[A[i]].push_back(B[i]);
		E[B[i]].push_back(A[i]);
	}
	dfs(0,-1);
	set<int>se1,se2;
	map<int,int>id;
	for(int v:vs){
		if(!se1.count(v)){
			se2.insert(v);
		}
		if(se2.size()==60){
			int cnt=0;
			for(int i:se2){
				id[i]=cnt;
				cnt++;
			}
			for(int i:se2){
				se1.insert(i);
			}
			se2.clear();
		}
	}
	int cnt=0;
	for(int i:se2){
		id[i]=cnt;
		cnt++;
	}
	int x=vid[Pos];
	set<int>se;
	int r;
	for(r=x;r<vs.size();r++){
		se.insert(id[vs[r]]);
		if(se.size()==60)break;
	}
	if(r==vs.size())r=vs.size()-1;
	int l;
	for(l=x;l>=0;l--){
		se.insert(id[vs[l]]);
		if(se.size()==60)break;
	}
	set<int>Se;
	int l2;
	for(l2=x;l2>=0;l2--){
		Se.insert(id[vs[l2]]);
		if(Se.size()==60)break;
	}
	int r2;
	for(r2=x;r2<vs.size();r2++){
		Se.insert(id[vs[r2]]);
		if(Se.size()==60)break;
	}
	if(r2-l2<r-l){
		swap(l,l2);
		swap(r,r2);
	}
	if(l==-1)l=0;
	ll ans=0;
	ans|=ll(V)<<id[Pos];
	if(abs(x-l)<abs(x-r)){
		//left
		for(int i=x-1;i>=l;i--){
			ans|=ll(Move(vs[i]))<<id[vs[i]];
		}
		for(int i=l+1;i<=r;i++){
			ans|=ll(Move(vs[i]))<<id[vs[i]];
		}
	}
	else{
		//right
		for(int i=x+1;i<=r;i++){
			ans|=ll(Move(vs[i]))<<id[vs[i]];
		}
		for(int i=r-1;i>=l;i--){
			ans|=ll(Move(vs[i]))<<id[vs[i]];
		}
	}
	return ans;
	
}

Compilation message

Ioi.cpp: In function 'long long int Ioi(int, int, int*, int*, int, int, int)':
Ioi.cpp:57:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(r=x;r<vs.size();r++){
          ~^~~~~~~~~~
Ioi.cpp:61:6: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if(r==vs.size())r=vs.size()-1;
     ~^~~~~~~~~~~
Ioi.cpp:74:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(r2=x;r2<vs.size();r2++){
           ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1924 KB Output is correct
2 Correct 7 ms 1664 KB Output is correct
3 Correct 6 ms 1924 KB Output is correct
4 Correct 6 ms 2044 KB Output is correct
5 Correct 5 ms 1792 KB Output is correct
6 Correct 6 ms 1928 KB Output is correct
7 Correct 6 ms 1804 KB Output is correct
8 Correct 6 ms 1932 KB Output is correct
9 Correct 6 ms 1796 KB Output is correct
10 Correct 5 ms 1792 KB Output is correct
11 Correct 9 ms 2204 KB Output is correct
12 Correct 7 ms 1800 KB Output is correct
13 Correct 7 ms 1796 KB Output is correct
14 Correct 6 ms 1924 KB Output is correct
15 Correct 5 ms 1884 KB Output is correct
16 Correct 7 ms 1924 KB Output is correct
17 Correct 6 ms 2048 KB Output is correct
18 Correct 7 ms 1924 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 56 ms 5956 KB Output is correct
2 Correct 52 ms 6104 KB Output is correct
3 Correct 50 ms 6212 KB Output is correct
4 Correct 40 ms 4792 KB Output is correct
5 Correct 43 ms 5192 KB Output is correct
6 Correct 44 ms 5192 KB Output is correct
7 Correct 39 ms 5064 KB Output is correct
8 Correct 46 ms 5048 KB Output is correct
9 Correct 41 ms 5168 KB Output is correct
10 Correct 37 ms 4808 KB Output is correct
11 Correct 37 ms 4936 KB Output is correct
12 Correct 35 ms 4664 KB Output is correct
13 Correct 41 ms 4640 KB Output is correct
14 Correct 36 ms 4864 KB Output is correct
15 Correct 36 ms 4856 KB Output is correct
16 Correct 36 ms 4792 KB Output is correct
17 Correct 39 ms 4800 KB Output is correct
18 Correct 43 ms 4672 KB Output is correct
19 Correct 37 ms 4800 KB Output is correct
20 Correct 33 ms 5184 KB Output is correct
21 Correct 27 ms 5196 KB Output is correct
22 Correct 36 ms 4936 KB Output is correct
23 Correct 34 ms 5192 KB Output is correct
24 Correct 36 ms 5064 KB Output is correct
25 Correct 41 ms 5060 KB Output is correct
26 Correct 43 ms 5212 KB Output is correct
27 Correct 43 ms 5184 KB Output is correct
28 Correct 44 ms 5324 KB Output is correct
29 Correct 41 ms 4772 KB Output is correct
30 Correct 38 ms 4920 KB Output is correct
31 Correct 6 ms 1912 KB Output is correct
32 Correct 5 ms 1664 KB Output is correct
33 Correct 6 ms 1920 KB Output is correct
34 Correct 7 ms 1940 KB Output is correct
35 Correct 7 ms 1664 KB Output is correct
36 Correct 6 ms 1928 KB Output is correct
37 Correct 5 ms 1800 KB Output is correct
38 Correct 5 ms 1664 KB Output is correct
39 Correct 8 ms 1792 KB Output is correct
40 Correct 7 ms 1924 KB Output is correct
41 Correct 5 ms 1664 KB Output is correct
42 Correct 5 ms 1920 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1800 KB Output is correct
2 Correct 5 ms 1664 KB Output is correct
3 Correct 6 ms 1664 KB Output is correct
4 Correct 8 ms 2340 KB Output is correct
5 Correct 10 ms 2340 KB Output is correct
6 Correct 8 ms 2468 KB Output is correct
7 Correct 8 ms 2344 KB Output is correct
8 Correct 8 ms 2332 KB Output is correct
9 Correct 25 ms 5568 KB Output is correct
10 Correct 27 ms 5772 KB Output is correct
11 Correct 33 ms 5704 KB Output is correct
12 Correct 6 ms 1928 KB Output is correct
13 Correct 5 ms 1664 KB Output is correct
14 Correct 6 ms 1664 KB Output is correct
15 Correct 6 ms 1792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 6228 KB Output is correct
2 Partially correct 55 ms 6092 KB Partially correct
3 Partially correct 51 ms 6088 KB Partially correct
4 Partially correct 37 ms 4884 KB Partially correct
5 Correct 37 ms 5440 KB Output is correct
6 Partially correct 41 ms 5176 KB Partially correct
7 Correct 40 ms 5160 KB Output is correct
8 Correct 39 ms 4972 KB Output is correct
9 Correct 39 ms 5056 KB Output is correct
10 Correct 33 ms 4800 KB Output is correct
11 Partially correct 39 ms 4800 KB Partially correct
12 Partially correct 37 ms 4528 KB Partially correct
13 Partially correct 44 ms 4400 KB Partially correct
14 Partially correct 51 ms 4764 KB Partially correct
15 Partially correct 44 ms 4912 KB Partially correct
16 Partially correct 48 ms 4864 KB Partially correct
17 Partially correct 45 ms 4844 KB Partially correct
18 Correct 47 ms 4876 KB Output is correct
19 Partially correct 39 ms 4732 KB Partially correct
20 Incorrect 37 ms 5312 KB Output isn't correct
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 59 ms 6100 KB Output is correct
2 Correct 46 ms 6100 KB Output is correct
3 Incorrect 50 ms 6100 KB Output isn't correct
4 Halted 0 ms 0 KB -