QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#481465#408. Dungeon 2Rafi220 0ms0kbC++202.8kb2024-07-17 06:17:122024-07-17 06:17:12

Judging History

你现在查看的是最新测评结果

  • [2024-07-17 06:17:12]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2024-07-17 06:17:12]
  • 提交

answer

#include "dungeon2.h"
#include <bits/stdc++.h>

using namespace std;

#ifdef DEBUG
auto&operator<<(auto&o,pair<auto,auto>p){return o<<"("<<p.first<<", "<<p.second<<")";}
auto operator<<(auto&o,auto x)->decltype(x.end(),o){o<<"{";int i=0;for(auto e:x)o<<","+!i++<<e;return o<<"}";}
#define debug(X...)cerr<<"["#X"]: ",[](auto...$){((cerr<<$<<"; "),...)<<endl;}(X)
#else
#define debug(...){}
#endif

#define ll long long
#define ld long double
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define FOR(i,l,r) for(int i=(l);i<=(r);i++)
#define ROF(i,r,l) for(int i=(r);i>=(l);i--)
int inf=1000000007;
ll infl=1000000000000000007;
ll mod=1000000007;
ll mod1=998244353;

const int N=207;

vector<int>G[N];
vector<int>G1[N];
int ile[N][N];
bool is[N][N];
bool skip[N][N];
bool go[N][N];
int M[N];
int O[N];

vector<int>val={1,2,3};

int it;


void dfs_init(int v)
{
	O[v]=LastRoad();
	if(v!=1) is[v][LastRoad()]=1;
	int m=NumberOfRoads();
	M[v]=m;
	FOR(i,1,m)
	{
		if(i==LastRoad()&&v!=1) continue;
		Move(i,2);
		if(Color()==1)
		{
			is[v][i]=1;
			go[v][i]=1;
			it++;
			G[v].pb(it);
			dfs_init(it);
		}
		else 
		{
			if(Color()==3) skip[v][i]=1;
			Move(LastRoad(),Color());
		}
	}
	if(v!=1) Move(O[v],3);
}

void dfs(int v,int j,int d)
{
	int m=NumberOfRoads();
	debug(v);
	FOR(i,1,m)
	{
		if(skip[v][i]) continue;
		if(j!=0&&d<=(1<<j)+ile[v][i]&&!is[v][i]) continue;
		Move(i,val[(d&(1<<j))>0]);
		if(go[v][i])
		{
			it++;
			debug(i);
			dfs(it,j,d+1);
		}
		else if(!is[v][i])
		{
			if(Color()==val[1]) ile[v][i]+=(1<<j);
			Move(LastRoad(),Color());
		}
	}
	if(v!=1) Move(O[v],val[0]);
}

vector<int>ord;
int xd[N];
vector<pair<int,int>>E;

void dfs1(int v,int d)
{
	ord.pb(v);
	for(auto u:G[v])
	{
		dfs1(u,d+1);
		E.pb({u,v});
	}
	debug(v,M[v]);
	FOR(i,1,M[v])
	{
		debug(is[v][i],ile[v][i]);
		if(!is[v][i]) 
		{
			if(ile[v][i]==0&&xd[v]>0) xd[v]--; 
			else 
			{
				E.pb({v,ord[ile[v][i]]});
				debug(v,ord[ile[v][i]]);
				xd[ord[ile[v][i]]]++;
			}
		}
	}
	ord.pop_back();
}

int ans[N];
int D[N];

void Inspect(int R)
{
	int n;
	it=1;
	dfs_init(1);
	Move(1,3);
	Move(LastRoad(),Color());
	n=it;
	FOR(j,0,7)
	{
		it=1;
		dfs(1,j,0);
		swap(val[0],val[2]);
		debug("XD");
	}
	dfs1(1,0);
	debug(E);
	for(auto [u,v]:E) 
	{
		G[u].pb(v);
		G[v].pb(u);
	}
	FOR(i,1,n)
	{
		deque<int>Q;
		Q.pb(i);
		FOR(j,1,n) D[j]=inf;
		D[i]=0;
		while(sz(Q)>0)
		{
			int v=Q[0];
			Q.pop_front();
			ans[D[v]]++;
			for(auto u:G[v])
			{
				if(D[u]==inf)
				{
					D[u]=D[v]+1;
					Q.pb(u);
				}
			}
		}
	}
	FOR(i,1,R)
	{
		debug(i,ans[i]);
		Answer(i,ans[i]/2);
	}
}

詳細信息

Subtask #1:

score: 0
Runtime Error

Test #1:

score: 0
Runtime Error

input:

10 100 50
7
5 7 10 4 6 2 3
2
1 5
3
1 10 7
2
10 1
3
1 9 2
2
1 7
5
9 6 8 3 1
1
7
2
5 7
3
1 4 3
15
24
6
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

output:

Wrong Answer [5]

result:


Subtask #2:

score: 0
Runtime Error

Test #16:

score: 0
Runtime Error

input:

10 3 50
4
7 4 10 5
2
8 6
1
10
2
1 9
3
1 7 10
2
7 2
5
6 1 5 8 9
3
7 9 2
4
10 8 7 4
4
1 9 5 3
15
19
9
2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

output:

Wrong Answer [5]

result:


Subtask #3:

score: 0
Runtime Error

Test #31:

score: 0
Runtime Error

input:

200 3 200
6
149 79 143 164 179 68
4
44 52 144 113
1
84
3
31 188 166
1
109
4
154 192 125 147
1
198
4
103 27 192 95
3
33 166 179
1
125
3
31 61 150
3
168 152 161
2
67 64
1
136
2
150 17
1
192
2
15 142
2
56 122
1
35
2
97 200
2
129 22
4
72 134 31 21
2
53 82
4
195 181 104 146
1
78
1
88
3
8 78 127
4
152 200...

output:

Wrong Answer [5]

result: