QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#33214#1861. Nondeterministic Finite AutomatonWu_RenAC ✓2ms3840kbC++17882b2022-05-30 11:04:172022-05-30 11:04:19

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-30 11:04:19]
  • 评测
  • 测评结果:AC
  • 用时:2ms
  • 内存:3840kb
  • [2022-05-30 11:04:17]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
vector<pair<int,int> >E[2];
vector<int>F;
int n,fl=0;
void add(int u,int v,int w){
	if(w<2) E[w].push_back({(u+fl)%n,(v+fl)%n});
	else add(u,v,0),add(u,v,1);
}
mt19937 rng(time(0));
void sol1(){
	fl=1;
	for(int i=0;i<n;i++) F.push_back(i);
	add(5,0,2),add(0,5,1);
	for(int i=2;i<5;i++) add(5,i,2),add(i,i,1);
	for(int i=0;i<5;i++) add(i,(i+1)%5,0);
}
void cir(int l,int r){
	for(int i=l;i<r;i++) F.push_back(i),add(i,i+1,2);
	add(r,l,2);
}
void sol2(){
	F.push_back(0);
	add(0,1,2),add(0,5,2),add(0,8,2),add(0,13,2);
	cir(1,4),cir(5,7),cir(8,12),cir(13,19);
}
int main(){
	scanf("%d",&n);
	if(n==6) sol1();
	else sol2();
	for(int k=0;k<2;k++){
		printf("%d\n",E[k].size());
		for(auto i:E[k]) printf("%d %d\n",i.first,i.second);
	}
	printf("%d\n",F.size());
	for(int i:F) printf("%d ",i);puts("");
} 

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 3840kb

input:

6

output:

9
0 1
0 3
0 4
0 5
1 2
2 3
3 4
4 5
5 1
8
0 1
1 0
0 3
3 3
0 4
4 4
0 5
5 5
6
0 1 2 3 4 5 

result:

ok n = 6

Test #2:

score: 0
Accepted
time: 2ms
memory: 3836kb

input:

20

output:

23
0 1
0 5
0 8
0 13
1 2
2 3
3 4
4 1
5 6
6 7
7 5
8 9
9 10
10 11
11 12
12 8
13 14
14 15
15 16
16 17
17 18
18 19
19 13
23
0 1
0 5
0 8
0 13
1 2
2 3
3 4
4 1
5 6
6 7
7 5
8 9
9 10
10 11
11 12
12 8
13 14
14 15
15 16
16 17
17 18
18 19
19 13
16
0 1 2 3 5 6 8 9 10 11 13 14 15 16 17 18 

result:

ok n = 20