QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#140155 | #5413. 同构判定鸡 | 1kri# | 58.47636 | 159ms | 44700kb | C++14 | 2.0kb | 2023-08-15 10:26:08 | 2024-07-04 01:43:09 |
Judging History
answer
#include <iostream>
#include <cstdio>
#include <cstring>
#include <bitset>
#include <random>
#include <chrono>
#include <algorithm>
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
int t,sub_id,n,m,N,M;
int book[3005][3005];
int tot,sta[1000005][2];
void add(int x,int y){
if (x==y||book[x][y]==1||book[y][x]==1)return;
++tot;
sta[tot][0]=x,sta[tot][1]=y;
book[x][y]=book[y][x]=1;
return;
}
void out(){
printf("%d %d\n",N,tot);
for (int i=1;i<=tot;i++)printf("%d %d\n",sta[i][0],sta[i][1]);
return;
}
bool prime(int x){
if (x<2)return 0;
for (int i=2;i*i<=x;i++)
if (x%i==0)return 0;
return 1;
}
pair<int,int> e[1000005];
bitset<350> qwq[350];
int main(){
scanf("%d%d",&t,&sub_id);
while(t--){
scanf("%d%d",&n,&m);
for (int i=1;i<=m;i++){
int x,y;
scanf("%d%d",&x,&y);
}
scanf("%d%d",&N,&M);
tot=0;
memset(book,0,sizeof(book));
if (sub_id==1){
for (int i=1;i<=N/2;i++)
for (int j=N/2+1;j<=N;j++)
add(i,j);
out();
}
if (sub_id==2){
for (int i=1;i<=N;i++)
for (int j=i+1;j<=N;j++)
if (i%(n-1)!=j%(n-1))add(i,j);
out();
}
if (sub_id==3||sub_id==4||sub_id==5){
int p=-1;
for (int i=N;i>=1;i--)
if (i*i<=N/2&&prime(i)){
p=i;
break;
}
int id=p*p;
for (int i=0;i<p;i++)
for (int d=0;d<p;d++){
int s=++id;
for (int j=0,t=i;j<p;j++,t=(t+d)%p)
add(s,j*p+t+1);
}
out();
}
if (sub_id==6){
for (int i=1;i<=N;i++)qwq[i].reset();
int e_tot=0;
for (int i=1;i<=N;i++)
for (int j=i+1;j<=N;j++)
e[++e_tot]=make_pair(i,j);
shuffle(e+1,e+1+e_tot,rnd);
for (int i=1;i<=e_tot;i++){
int x=e[i].first,y=e[i].second;
qwq[x][y]=qwq[y][x]=1;
int fg=1;
for (int k=1;k<=N&&fg==1;k++){
if (k!=x&&(qwq[k]&qwq[x]).count()>2)fg=0;
if (k!=y&&(qwq[k]&qwq[y]).count()>2)fg=0;
}
if (fg==1)add(x,y);
else qwq[x][y]=qwq[y][x]=0;
}
out();
}
}
return 0;
}
詳細信息
Test #1:
score: 5
Accepted
time: 13ms
memory: 42216kb
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 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 2 28 2 29 2 30 2 31 2 32 2 33 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 3 26 3 27 3 28 3 29 3 30 3 31 3 32 3 33 4 17 4 18 4 19 4 20 4 21 4 22 4 23 4 2...
result:
ok correct! (10 test cases)
Test #2:
score: 10
Accepted
time: 17ms
memory: 42200kb
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: 27ms
memory: 42356kb
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 2197 170 1 170 14 170 27 170 40 170 53 170 66 170 79 170 92 170 105 170 118 170 131 170 144 170 157 171 1 171 15 171 29 171 43 171 57 171 71 171 85 171 99 171 113 171 127 171 141 171 155 171 169 172 1 172 16 172 31 172 46 172 61 172 76 172 91 172 93 172 108 172 123 172 138 172 153 172 168 173 1 ...
result:
ok correct! (10 test cases)
Test #4:
score: 0
Wrong Answer
time: 30ms
memory: 42332kb
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 343 50 1 50 8 50 15 50 22 50 29 50 36 50 43 51 1 51 9 51 17 51 25 51 33 51 41 51 49 52 1 52 10 52 19 52 28 52 30 52 39 52 48 53 1 53 11 53 21 53 24 53 34 53 37 53 47 54 1 54 12 54 16 54 27 54 31 54 42 54 46 55 1 55 13 55 18 55 23 55 35 55 40 55 45 56 1 56 14 56 20 56 26 56 32 56 38 56 44 57 2 57...
result:
wrong answer Integer parameter [name=m] equals to 343, violates the range [1014, 14196] (test case 1)
Test #5:
score: 23.4119
Acceptable Answer
time: 6ms
memory: 41424kb
input:
1 5 4 4 1 2 2 3 3 4 4 1 2850 24300
output:
2850 50653 1370 1 1370 38 1370 75 1370 112 1370 149 1370 186 1370 223 1370 260 1370 297 1370 334 1370 371 1370 408 1370 445 1370 482 1370 519 1370 556 1370 593 1370 630 1370 667 1370 704 1370 741 1370 778 1370 815 1370 852 1370 889 1370 926 1370 963 1370 1000 1370 1037 1370 1074 1370 1111 1370 1148 ...
result:
points 0.78039800210 m' = 50653, 3M = 72900, points = 23.411940
Test #6:
score: 10.0644
Acceptable Answer
time: 159ms
memory: 44700kb
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 3027 157 304 200 232 8 80 59 232 153 339 74 111 34 111 156 244 107 309 145 331 179 230 108 278 188 288 30 65 227 259 276 292 157 313 26 51 165 245 154 334 91 108 2 291 33 102 61 114 171 325 2 113 58 197 48 238 31 211 48 329 233 341 13 134 164 206 261 321 31 151 28 338 103 341 15 252 103 202 15 1...
result:
points 0.33548067390 m' = 3027, 3M = 7050, points = 10.064420