Submission #244319

# Submission time Handle Problem Language Result Execution time Memory
244319 2020-07-03T15:34:32 Z redddd Amusement Park (JOI17_amusement_park) C++14
0 / 100
20 ms 3840 KB
#include <bits/stdc++.h> 
#include "Joi.h"
using namespace std; 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define MOD 1000000007
#define pb push_back
#define ve vector<ll>
#define dos pair<ll,ll>
#define vedos vector<dos>
#define rand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define EPS 0.000001
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
void setIO(string s) {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}
ve gr[10001];
ll yo;
int na,cum;
int col[10001],d[10001],p[10001],c[10001],vis[10001];
int explore(int node,int par,int dep){
	p[node]=par;
	vis[node]=1;
	bool ans=1;
	if(dep==59){
		col[node]=((yo&(1<<dep))?1:0);
		MessageBoard(node,col[node]);
		d[node]=dep;
		return 1;
	}
	bool zol=0;
	for(auto it:gr[node]){
		if(it!=par && col[it]==-1){
			int k=explore(it,node,dep+1);
			c[node]=it;
			zol=1;
			if(!k){
				MessageBoard(node,0);
				ans=0;
			}
			else{
				col[node]=((yo&(1<<dep))?1:0);
				MessageBoard(node,col[node]);
				d[node]=dep;
			}
			break;
		}
	}
	if(!zol){
		ans=0;	
		MessageBoard(node,0);
	}
	if(!ans){
		return 0;
	}
}
void Joi(int N, int M, int A[], int B[], long long X, int T) {
  memset(col,-1,sizeof col);
  memset(c,-1,sizeof c);
  memset(p,-1,sizeof p);
  memset(vis,-1,sizeof vis);
  na=N;
  yo=X;
  for (int i = 0; i < M; ++i)
  {
  	int u=A[i],v=B[i];
  	gr[u].pb(v),gr[v].pb(u);
  } 
  for (int i = 0; i < N; ++i)
  {
  	if(vis[i]==-1){
  		explore(i,-1,0);
  	}
  }
}
#include <bits/stdc++.h> 
#include "Ioi.h"
using namespace std; 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define MOD 1000000007
#define pb push_back
#define ve vector<ll>
#define dos pair<ll,ll>
#define vedos vector<dos>
#define rand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define EPS 0.000001
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
ve gr1[10001];
int fa;
int sii[10001],dii[10001],pii[10001],loo[10001],visa[10001],visi[10001];
int exp(int node,int par,int dep){
	pii[node]=par;
	visa[node]=1;
	bool ans=1;
	if(dep==59){
		sii[node]=1;
		dii[node]=dep;
		return 1;
	}
	ll fol=0;
	int zol=0;
	for(auto it:gr1[node]){
		if(it!=par && sii[it]==-1){
			int k=exp(it,node,dep+1);
			loo[node]=it;
			zol=1;
			if(!k){
				ans=0;
			}
			else{
				sii[node]=1;
				dii[node]=dep;
			}
			break;
		}
		else if(sii[it]==-1)fol=it;
	}
	if(!zol)ans=0;
	if(!ans){
		loo[node]=fol;
		return 0;
	}
}
ll ans;
ve cur;
map<int,int>g;
ll mizi(int node,int last){
	if(g.find(node)!=g.end() && last==node)return g[node];
	return g[node]=Move(node);
}
bool solve(int node){
	visi[node]=1;
	if(sii[node]==1){
	for(auto it:cur)mizi(it,-1);
		int ni=node;
		while(dii[ni]<=59 && ni!=-1){
			ll yo=mizi(ni,node);
			if(yo){
				ans|=(1<<dii[ni]);
			}
			if(loo[ni]==-1)break;
			ni=loo[ni];
		}

		if(dii[ni]>=0){
			ni=pii[ni];
			while(dii[ni]>=0 && ni!=-1){
			ll yo=Move(ni);
			if(yo){ 
				ans|=(1<<dii[ni]);
			}
			if(pii[ni]==-1)break;
			ni=pii[ni];
			}
		}
		return 1;
	}
	else{
		for(auto it:gr1[node]){
			if(!visi[it]){
				cur.pb(it);
				if(solve(it))return 1;
				cur.pop_back();
			}
		}
	}
	return 0;
}
long long Ioi(int N, int M, int A[], int B[], int p, int V, int T) {
  memset(sii,-1,sizeof sii);
  memset(loo,-1,sizeof loo);
  memset(pii,-1,sizeof pii);
  memset(visa,-1,sizeof visa);
  fa=N;
  g[p]=V;
  for (int i = 0; i < M; ++i)
  {
  	int u=A[i],v=B[i];
  	gr1[u].pb(v),gr1[v].pb(u);
  }
  for (int i = 0; i < N; ++i)
  {
  	if(visa[i]==-1){
  		exp(i,-1,0);
  	}
  }
  solve(p);
  return ans;
}

Compilation message

Joi.cpp:5:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization ("O3")
 
Joi.cpp:6:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization ("unroll-loops")
 
Joi.cpp: In function 'void setIO(std::__cxx11::string)':
Joi.cpp:28:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
  freopen((s+".in").c_str(),"r",stdin);
  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Joi.cpp:29:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
  freopen((s+".out").c_str(),"w",stdout);
  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Joi.cpp: In function 'int explore(int, int, int)':
Joi.cpp:70:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^

Ioi.cpp:5:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization ("O3")
 
Ioi.cpp:6:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization ("unroll-loops")
 
Ioi.cpp: In function 'int exp(int, int, int)':
Ioi.cpp:61:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 1536 KB Wrong Answer [2]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 3840 KB Wrong Answer [2]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 1776 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 3840 KB Wrong Answer [2]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 3840 KB Wrong Answer [2]
2 Halted 0 ms 0 KB -