QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#841307#5413. 同构判定鸡275307894a100 ✓20ms4328kbC++142.4kb2025-01-03 16:37:062025-01-03 16:37:15

Judging History

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

  • [2025-01-03 16:37:15]
  • 评测
  • 测评结果:100
  • 用时:20ms
  • 内存:4328kb
  • [2025-01-03 16:37:06]
  • 提交

answer

#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define eb emplace_back
#define all(x) x.begin(),x.end()
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;
const int N=(1<<20)+5,M=(1<<20)+5,K=1000+5,mod=998244353,Mod=mod-1;const db eps=1e-9;const int INF=1e9+7;mt19937 rnd(28382);
#define Tp template<typename T>
#define Ts template<typename T,typename... Ar>
namespace Debug{
	Tp void _debug(char* f,T t){cerr<<f<<'='<<t<<endl;}
	Ts void _debug(char* f,T x,Ar... y){while(*f!=',') cerr<<*f++;cerr<<'='<<x<<",";_debug(f+1,y...);}
	#ifdef LOCAL
	#define gdb(...) _debug((char*)#__VA_ARGS__,__VA_ARGS__)
	#else 
	#define gdb(...) void()
	#endif
}using namespace Debug;
int type,n,m,nn,mm;
vector<pii> e;
void con(int x,int y){e.emplace_back(x,y);}
namespace Solve1{
	void Solve(){
		vector<pii> e;
		for(int i=1;i<=nn;i++){
			for(int j=i+1;j<=nn;j++) if(i%(n-1)!=j%(n-1)) con(i,j);
		}
	}
}
namespace Solve2{
	int p;
	int getid(int x,int y){return x*p+y+1;}
	bool ckp(int x){
		for(int i=2;i*i<=x;i++) if(x%i==0) return false;
		return true;
	}
	void Solve(){
		p=sqrt(nn);
		while(!ckp(p)) p--;
		for(int i=0;i<p;i++) for(int j=0;j<p;j++){
			for(int h=i+1;h<p;h++) con(getid(i,j),getid(h,(i*h+p-j)%p));
		}
	}
}
namespace Solve3{
	int p=7;
	int getid(int x,int y,int z){return x*p*p+y*p+z+1;}
	void Solve(){
		for(int x=0;x<p;x++) for(int y=0;y<p;y++) for(int z=0;z<p;z++){
			for(int a=0;a<p;a++) for(int b=0;b<p;b++) for(int c=0;c<p;c++){
				int w=((x-a)*(x-a)+(y-b)*(y-b)+(z-c)*(z-c))%p;
				if(w==1) con(getid(x,y,z),getid(a,b,c));
			}
		}
		for(auto &[a,b]:e) if(a>b) swap(a,b);
		sort(all(e));
		e.erase(unique(all(e)),e.end());
	}
}
void Solve(){
	scanf("%d%d",&n,&m);
	e.clear();
	while(m--){
		int x,y;scanf("%d%d",&x,&y);
	}
	scanf("%d%d",&nn,&mm);
	if(type<=2) Solve1::Solve();
	else if(type<=5) Solve2::Solve();
	else Solve3::Solve();
	printf("%d %d\n",nn,int(e.size()));
	for(auto [a,b]:e) printf("%d %d\n",a,b);
}
int main(){
	int t=1;
	scanf("%d%d",&t,&type);
	while(t--) Solve();
	cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}

詳細信息


Pretests


Final Tests

Test #1:

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

input:

10 1
3 3
1 2
1 3
2 3
33 272
3 3
1 2
1 3
2 3
28 196
3 3
1 2
1 3
2 3
92 2116
3 3
1 2
1 3
2 3
29 210
3 3
1 2
1 3
2 3
62 961
3 3
1 2
1 3
2 3
97 2352
3 3
1 2
1 3
2 3
60 900
3 3
1 2
1 3
2 3
70 1225
3 3
1 2
1 3
2 3
67 1122
3 3
1 2
1 3
2 3
67 1122

output:

33 272
1 2
1 4
1 6
1 8
1 10
1 12
1 14
1 16
1 18
1 20
1 22
1 24
1 26
1 28
1 30
1 32
2 3
2 5
2 7
2 9
2 11
2 13
2 15
2 17
2 19
2 21
2 23
2 25
2 27
2 29
2 31
2 33
3 4
3 6
3 8
3 10
3 12
3 14
3 16
3 18
3 20
3 22
3 24
3 26
3 28
3 30
3 32
4 5
4 7
4 9
4 11
4 13
4 15
4 17
4 19
4 21
4 23
4 25
4 27
4 29
4 31
4 ...

result:

ok correct! (10 test cases)

Test #2:

score: 10
Accepted
time: 1ms
memory: 4076kb

input:

10 2
5 10
1 2
1 3
1 4
1 5
2 3
2 4
2 5
3 4
3 5
4 5
28 293
8 28
1 2
1 3
1 4
1 5
1 6
1 7
1 8
2 3
2 4
2 5
2 6
2 7
2 8
3 4
3 5
3 6
3 7
3 8
4 5
4 6
4 7
4 8
5 6
5 7
5 8
6 7
6 8
7 8
8 26
4 6
1 2
1 3
1 4
2 3
2 4
3 4
82 2240
3 3
1 2
1 3
2 3
46 528
4 6
1 2
1 3
1 4
2 3
2 4
3 4
42 587
9 36
1 2
1 3
1 4
1 5
1 6
1 ...

output:

28 294
1 2
1 3
1 4
1 6
1 7
1 8
1 10
1 11
1 12
1 14
1 15
1 16
1 18
1 19
1 20
1 22
1 23
1 24
1 26
1 27
1 28
2 3
2 4
2 5
2 7
2 8
2 9
2 11
2 12
2 13
2 15
2 16
2 17
2 19
2 20
2 21
2 23
2 24
2 25
2 27
2 28
3 4
3 5
3 6
3 8
3 9
3 10
3 12
3 13
3 14
3 16
3 17
3 18
3 20
3 21
3 22
3 24
3 25
3 26
3 28
4 5
4 6
4 ...

result:

ok correct! (10 test cases)

Test #3:

score: 10
Accepted
time: 20ms
memory: 4140kb

input:

10 3
4 4
1 2
2 3
3 4
4 1
387 774
4 4
1 2
2 3
3 4
4 1
668 1336
4 4
1 2
2 3
3 4
4 1
1403 2806
4 4
1 2
2 3
3 4
4 1
1516 3032
4 4
1 2
2 3
3 4
4 1
1601 3202
4 4
1 2
2 3
3 4
4 1
1649 3298
4 4
1 2
2 3
3 4
4 1
1722 3444
4 4
1 2
2 3
3 4
4 1
1854 3708
4 4
1 2
2 3
3 4
4 1
1926 3852
4 4
1 2
2 3
3 4
4 1
1989 3978

output:

387 3249
1 20
1 39
1 58
1 77
1 96
1 115
1 134
1 153
1 172
1 191
1 210
1 229
1 248
1 267
1 286
1 305
1 324
1 343
2 38
2 57
2 76
2 95
2 114
2 133
2 152
2 171
2 190
2 209
2 228
2 247
2 266
2 285
2 304
2 323
2 342
2 361
3 37
3 56
3 75
3 94
3 113
3 132
3 151
3 170
3 189
3 208
3 227
3 246
3 265
3 284
3 30...

result:

ok correct! (10 test cases)

Test #4:

score: 15
Accepted
time: 11ms
memory: 4088kb

input:

10 4
4 4
1 2
2 3
3 4
4 1
169 1014
4 4
1 2
2 3
3 4
4 1
529 5819
4 4
1 2
2 3
3 4
4 1
841 11774
4 4
1 2
2 3
3 4
4 1
961 14415
4 4
1 2
2 3
3 4
4 1
1369 24642
4 4
1 2
2 3
3 4
4 1
1681 33620
4 4
1 2
2 3
3 4
4 1
1849 38829
4 4
1 2
2 3
3 4
4 1
361 3249
4 4
1 2
2 3
3 4
4 1
289 2312
4 4
1 2
2 3
3 4
4 1
9 9

output:

169 1014
1 14
1 27
1 40
1 53
1 66
1 79
1 92
1 105
1 118
1 131
1 144
1 157
2 26
2 39
2 52
2 65
2 78
2 91
2 104
2 117
2 130
2 143
2 156
2 169
3 25
3 38
3 51
3 64
3 77
3 90
3 103
3 116
3 129
3 142
3 155
3 168
4 24
4 37
4 50
4 63
4 76
4 89
4 102
4 115
4 128
4 141
4 154
4 167
5 23
5 36
5 49
5 62
5 75
5 8...

result:

ok correct! (10 test cases)

Test #5:

score: 30
Accepted
time: 0ms
memory: 4328kb

input:

1 5
4 4
1 2
2 3
3 4
4 1
2850 24300

output:

2850 73034
1 54
1 107
1 160
1 213
1 266
1 319
1 372
1 425
1 478
1 531
1 584
1 637
1 690
1 743
1 796
1 849
1 902
1 955
1 1008
1 1061
1 1114
1 1167
1 1220
1 1273
1 1326
1 1379
1 1432
1 1485
1 1538
1 1591
1 1644
1 1697
1 1750
1 1803
1 1856
1 1909
1 1962
1 2015
1 2068
1 2121
1 2174
1 2227
1 2280
1 2333
...

result:

points 1.0 m' = 73034, 3M = 72900, points = 30.027521

Test #6:

score: 30
Accepted
time: 2ms
memory: 4148kb

input:

1 6
6 9
1 4
1 5
1 6
2 4
2 5
2 6
3 4
3 5
3 6
343 2350

output:

343 7203
1 2
1 7
1 8
1 17
1 20
1 38
1 41
1 43
1 50
1 101
1 104
1 113
1 123
1 124
1 130
1 131
1 134
1 165
1 166
1 171
1 174
1 178
1 181
1 186
1 187
1 214
1 215
1 220
1 223
1 227
1 230
1 235
1 236
1 248
1 251
1 260
1 270
1 271
1 277
1 278
1 281
1 295
2 3
2 9
2 18
2 21
2 39
2 42
2 44
2 51
2 102
2 105
2...

result:

points 1.0 m' = 7203, 3M = 7050, points = 30.318617