QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#138016#1142. Fountain Parksyahia#0 362ms66548kbC++143.8kb2023-08-10 20:48:482024-07-04 01:34:16

Judging History

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

  • [2024-07-04 01:34:16]
  • 评测
  • 测评结果:0
  • 用时:362ms
  • 内存:66548kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-10 20:48:48]
  • 提交

answer

#include "parks.h"
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef int in;
#define int long long
#define double long double
#define f first
#define s second
#define pb push_back
#define pp push
#define ceil(x,y) (x/y)+(x%y!=0)*(x*y<0?0:1)
#define floor(x,y) (x/y)+(x%y!=0)*(x*y<0?-1:0)
const int MAAX=1e18;
const int MOD=1e9+7;
const int MAX=1e9;
bool vis[200010],lst[200010],ch[200010];
map<pair<int,int>,int> mp;
map<pair<int,int>,int> tk;
in construct_roads(vector<in> x, vector<in> y) {
    if (x.size() == 1) {
		build({}, {}, {}, {});
        return 1;
    }
    vector<in> ansu,ansv,ansa,ansb;
    int n=x.size();
    for(int i=0;i<n;i++){
    	mp[{x[i],y[i]}]=i;
    	ch[i]=1;
    }
   	int cur=1;
   	queue<int> q;
   	srand(72);
   	q.pp(1);
   	while(q.size()&&cur<n){
   		int curx=x[q.front()],cury=y[q.front()],curid=q.front();
   		q.pop();
   		if(mp[{curx-2,cury}]&&!vis[mp[{curx-2,cury}]]){
   			int idx=mp[{curx-2,cury}];
   			vis[idx]=1;
   			cur++;
   			q.pp(idx);
   			ansu.pb(curid);
   			ansv.pb(idx);
   		}
   		if(mp[{curx+2,cury}]&&!vis[mp[{curx+2,cury}]]){
   			int idx=mp[{curx+2,cury}];
   			vis[idx]=1;
   			cur++;
   			q.pp(idx);
   			ansu.pb(curid);
   			ansv.pb(idx);
   		}
   		if(mp[{curx,cury-2}]&&!vis[mp[{curx,cury-2}]]){
   			int idx=mp[{curx,cury-2}];
   			vis[idx]=1;
   			cur++;
   			q.pp(idx);
   			ansu.pb(curid);
   			ansv.pb(idx);
   		}
   		if(mp[{curx,cury+2}]&&!vis[mp[{curx,cury+2}]]){
   			int idx=mp[{curx,cury+2}];
   			vis[idx]=1;
   			cur++;
   			q.pp(idx);
   			ansu.pb(curid);
   			ansv.pb(idx);
   		}
   	}
   	if(cur<n)
	    return 0;
	int c=0;
	int t=time(0);
	while(1){
		bool cor=1;
		for(int i=0;i<ansu.size();i++){
			if(time(0)-t==3){
				return 0;
			}
			int x1=x[ansu[i]],y1=y[ansu[i]],x2=x[ansv[i]],y2=y[ansv[i]];
			if(x1==x2+2){
				int rnd=lst[i];
				if(ch[i])
					rnd=rand()%2;
				ch[i]=0;
				lst[i]=rnd;
				int bx=x1-1,by=y1-1+2*rnd;
				if(tk[{bx,by}])
					rnd=!rnd;
				by=y1-1+2*rnd;
				if(tk[{bx,by}]){
					ch[i]=1;
					ch[tk[{bx,by}]-1]=1;
					rnd=!rnd;
					by=y1-1+2*rnd;
					ch[tk[{bx,by}]-1]=1;
					cor=0;
					continue;
				}
				tk[{bx,by}]=i+1;
				ansa.pb(bx);
				ansb.pb(by);
			}
			else if(x1==x2-2){
				int rnd=lst[i];
				if(ch[i])
					rnd=rand()%2;
				ch[i]=0;
				lst[i]=rnd;
				int bx=x1+1,by=y1-1+2*rnd;
				if(tk[{bx,by}])
					rnd=!rnd;
				by=y1-1+2*rnd;
				if(tk[{bx,by}]){
					ch[i]=1;
					ch[tk[{bx,by}]-1]=1;
					rnd=!rnd;
					by=y1-1+2*rnd;
					ch[tk[{bx,by}]-1]=1;
					cor=0;
					continue;
				}
				tk[{bx,by}]=i+1;
				ansa.pb(bx);
				ansb.pb(by);
			}
			else if(y1==y2+2){
				int rnd=lst[i];
				if(ch[i])
					rnd=rand()%2;
				ch[i]=0;
				lst[i]=rnd;
				int bx=x1-1+2*rnd,by=y1-1;
				if(tk[{bx,by}])
					rnd=!rnd;
				bx=x1-1+2*rnd;
				if(tk[{bx,by}]){
					ch[i]=1;
					ch[tk[{bx,by}]-1]=1;
					rnd=!rnd;
					bx=x1-1+2*rnd;
					ch[tk[{bx,by}]-1]=1;
					cor=0;
					continue;
				}
				tk[{bx,by}]=i+1;
				ansa.pb(bx);
				ansb.pb(by);
			}
			else{
				int rnd=lst[i];
				if(ch[i])
					rnd=rand()%2;
				ch[i]=0;
				lst[i]=rnd;
				int bx=x1-1+2*rnd,by=y1+1;
				if(tk[{bx,by}])
					rnd=!rnd;
				bx=x1-1+2*rnd;
				if(tk[{bx,by}]){
					ch[i]=1;
					ch[tk[{bx,by}]-1]=1;
					rnd=!rnd;
					bx=x1-1+2*rnd;
					ch[tk[{bx,by}]-1]=1;
					cor=0;
					continue;
				}
				tk[{bx,by}]=i+1;
				ansa.pb(bx);
				ansb.pb(by);
			}
		}
		if(cor)
			break;
		tk.clear();
		ansa.clear();
		ansb.clear();
		if(time(0)-t==3){
			return 0;
		}
	}
	build(ansu,ansv,ansa,ansb);
	return 1;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 5
Accepted
time: 0ms
memory: 3852kb

input:

ba73dbf9c7d5e5202834d6a500541c
1
2 2

output:

3kr2yac8xnf3ktgcoqviaw115df6rra7is6p5uix
OK
1
0

result:

ok 

Test #2:

score: -5
Wrong Answer
time: 0ms
memory: 4152kb

input:

ba73dbf9c7d5e5202834d6a500541c
2
2 2
2 4

output:

3kr2yac8xnf3ktgcoqviaw115df6rra7is6p5uix
OK
0

result:

wrong answer Solution announced impossible, but it is possible.

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Wrong Answer

Test #82:

score: 0
Wrong Answer
time: 0ms
memory: 3852kb

input:

ba73dbf9c7d5e5202834d6a500541c
3
200000 2
200000 4
199998 2

output:

3kr2yac8xnf3ktgcoqviaw115df6rra7is6p5uix
OK
0

result:

wrong answer Solution announced impossible, but it is possible.

Subtask #5:

score: 0
Wrong Answer

Test #108:

score: 0
Wrong Answer
time: 362ms
memory: 66548kb

input:

ba73dbf9c7d5e5202834d6a500541c
200000
82422 100002
100002 52498
82816 2
97624 2
100002 58032
20638 100002
100002 7646
80512 2
2 10584
28426 100002
2 83036
2 64556
47872 100002
55196 2
85350 100002
2 95376
2 23942
12488 100002
83178 2
2 9086
85598 2
100002 78820
100002 10868
98810 2
84182 100002
2 71...

output:

3kr2yac8xnf3ktgcoqviaw115df6rra7is6p5uix
OK
1
199999
1 67645 100001 52497
1 117727 100003 52499
67645 43203 100003 52495
67645 1 100003 52497
117727 23556 100001 52501
43203 159406 100003 52493
23556 97898 100003 52503
159406 196874 100001 52491
97898 40643 100003 52505
196874 167465 100001 52489
40...

result:

wrong answer Edge between 67645 and 1 appears more than once: appeared on positions 0 and 3

Subtask #6:

score: 0
Skipped

Dependency #1:

0%