QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#140193 | #5413. 同构判定鸡 | Lynkcat# | 29.097948 | 1225ms | 5652kb | C++17 | 3.2kb | 2023-08-15 11:55:53 | 2024-07-04 01:43:52 |
Judging History
answer
#include<bits/stdc++.h>
#define poly vector<int>
#define ull unsigned long long
#define IOS ios::sync_with_stdio(false)
#define ll long long
#define mp make_pair
#define mt make_tuple
#define pa pair < int,int >
#define fi first
#define se second
#define inf 1e18
#define mod 998244353
#define sz(x) (int)((x).size())
#define int ll
#define N 3005
using namespace std;
int id;
int n,m;
bitset<3005>f[3005];
int col[N];
poly G[3005];
mt19937_64 gen(time(0));
void BellaKira()
{
cin>>n>>m;
for (int i=1;i<=m;i++)
{
int x,y;
cin>>x>>y;
}
if (id==1)
{
cin>>n>>m;
cout<<n<<" "<<n/2*(n-n/2)<<'\n';
for (int i=1;i<=n/2;i++)
for (int j=n/2+1;j<=n;j++)
cout<<i<<" "<<j<<'\n';
return;
}
if (id==2)
{
int o,p;
cin>>o>>p;
int tot=0;
n--;
for (int i=1;i<=o;i++)
for (int j=i+1;j<=o;j++)
if (i%n!=j%n) tot++;
cout<<o<<" "<<tot<<'\n';
for (int i=1;i<=o;i++)
for (int j=i+1;j<=o;j++)
if (i%n!=j%n)
cout<<i<<" "<<j<<'\n';
return;
}
cin>>n>>m;
for (int i=1;i<=n;i++)
for (int j=1;j<=n;j++)
f[i][j]=0;
int lst=0;
int tot=0;
int mx=0,mxtim=0;
ull seed=gen();
mt19937_64 rnd(seed);
for (int tms=0;tms<=1000000;tms++)
{
if (tot>mx)
{
mx=tot,mxtim=tms;
}
if (lst>=2000)
{
int x,y;
x=rnd()%n+1,y=rnd()%n+1;
while (x==y||!f[x][y])
x=rnd()%n+1,y=rnd()%n+1;
f[x][y]=f[y][x]=0;
G[x].erase(find(G[x].begin(),G[x].end(),y));
G[y].erase(find(G[y].begin(),G[y].end(),x));
lst=0;
tot--;
continue;
}
int x,y;
x=rnd()%n+1,y=rnd()%n+1;
while (x==y||f[x][y])
x=rnd()%n+1,y=rnd()%n+1;
for (auto u:G[y])
col[u]=1;
bool bl=1;
for (auto u:G[x])
{
for (auto v:G[u])
if (col[v]) bl=0;
}
if (bl)
{
f[x][y]=1;
f[y][x]=1;
G[x].push_back(y);
G[y].push_back(x);
tot++;
} else lst++;
for (auto u:G[y]) col[u]=0;
}
for (int i=1;i<=n;i++)
for (int j=1;j<=n;j++)
f[i][j]=0;
for (int i=1;i<=n;i++) poly().swap(G[i]);
mt19937_64 rnd1(seed);
lst=0;tot=0;
for (int tms=0;tms<mxtim;tms++)
{
if (lst>=2000)
{
int x,y;
x=rnd1()%n+1,y=rnd1()%n+1;
while (x==y||!f[x][y])
x=rnd1()%n+1,y=rnd1()%n+1;
f[x][y]=f[y][x]=0;
G[x].erase(find(G[x].begin(),G[x].end(),y));
G[y].erase(find(G[y].begin(),G[y].end(),x));
lst=0;
tot--;
// cout<<"Ers "<<x<<" "<<y<<endl;
continue;
}
int x,y;
x=rnd1()%n+1,y=rnd1()%n+1;
while (x==y||f[x][y])
x=rnd1()%n+1,y=rnd1()%n+1;
for (auto u:G[y])
col[u]=1;
bool bl=1;
for (auto u:G[x])
{
for (auto v:G[u])
if (col[v]) bl=0;
}
if (bl)
{
f[x][y]=1;
f[y][x]=1;
G[x].push_back(y);
G[y].push_back(x);
tot++;
} else lst++;
for (auto u:G[y]) col[u]=0;
}
tot=0;
for (int i=1;i<=n;i++)
for (int j=i+1;j<=n;j++)
if (f[i][j]) tot++;
cout<<n<<" "<<tot<<'\n';
for (int i=1;i<=n;i++)
for (int j=i+1;j<=n;j++)
if (f[i][j])
{
cout<<i<<" "<<j<<'\n';
f[i][j]=f[j][i]=0;
}
for (int i=1;i<=n;i++) poly().swap(G[i]);
}
signed main()
{
IOS;
cin.tie(0);
int T=1;cin>>T>>id;
while (T--)
{
BellaKira();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 5
Accepted
time: 0ms
memory: 3860kb
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: 2ms
memory: 3860kb
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: 0
Time Limit Exceeded
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 2481 1 8 1 13 1 86 1 103 1 112 1 114 1 143 1 163 1 192 1 232 1 333 1 379 2 15 2 49 2 64 2 70 2 171 2 220 2 283 2 328 2 356 2 362 2 383 2 385 3 37 3 82 3 116 3 121 3 123 3 163 3 185 3 188 3 189 3 199 3 280 3 295 3 374 3 375 4 16 4 26 4 66 4 90 4 97 4 149 4 172 4 174 4 226 4 244 4 288 4 343 4 387 ...
result:
Test #4:
score: 0
Time Limit Exceeded
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 812 1 55 1 61 1 66 1 67 1 74 1 94 1 116 1 126 1 130 1 132 1 138 2 32 2 59 2 66 2 95 2 110 2 134 2 139 2 161 3 11 3 62 3 69 3 73 3 87 3 92 3 105 3 119 3 130 3 140 4 37 4 40 4 86 4 95 4 113 4 117 4 153 4 159 4 165 4 166 4 169 5 12 5 30 5 34 5 38 5 46 5 60 5 117 5 129 5 130 5 150 5 157 6 10 6 24 6 ...
result:
Test #5:
score: 14.0979
Acceptable Answer
time: 1225ms
memory: 5652kb
input:
1 5 4 4 1 2 2 3 3 4 4 1 2850 24300
output:
2850 35386 1 440 1 577 1 930 1 1124 1 1131 1 1462 1 1491 1 1566 1 1631 1 1650 1 1677 1 1776 1 1857 1 1895 1 2380 1 2388 1 2490 1 2516 1 2572 1 2579 1 2581 1 2838 2 11 2 109 2 147 2 413 2 512 2 543 2 547 2 679 2 758 2 867 2 890 2 1092 2 1121 2 1143 2 1153 2 1155 2 1315 2 1405 2 1449 2 1554 2 1585 2 1...
result:
points 0.46993161140 m' = 35386, 3M = 72900, points = 14.097948
Test #6:
score: 0
Wrong Answer
time: 392ms
memory: 4088kb
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 2111 1 43 1 68 1 74 1 103 1 149 1 163 1 176 1 209 1 274 1 287 1 301 1 339 2 49 2 52 2 121 2 132 2 145 2 194 2 197 2 276 2 302 2 312 2 327 2 338 3 33 3 57 3 61 3 65 3 66 3 73 3 79 3 131 3 140 3 210 3 239 3 247 3 253 4 57 4 75 4 76 4 78 4 81 4 84 4 117 4 208 4 209 4 228 4 298 4 309 4 338 5 19 5 30...
result:
wrong answer Integer parameter [name=m] equals to 2111, violates the range [2350, 58653]