QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#140195 | #5413. 同构判定鸡 | Lynkcat# | 39.032313 | 1184ms | 5724kb | C++17 | 3.2kb | 2023-08-15 11:57:15 | 2024-07-04 01:43:53 |
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 (id==3&&mx>=2*n)
{
mxtim=tms;
break;
}
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: 1ms
memory: 3844kb
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: 3724kb
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: 87ms
memory: 4612kb
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 775 1 114 1 163 1 352 2 15 2 283 2 356 2 385 3 163 3 185 3 188 3 280 3 374 4 26 4 172 4 357 5 49 5 108 5 247 5 285 6 199 6 202 7 43 7 187 7 318 8 78 8 170 8 216 8 262 9 107 9 182 9 241 9 342 10 146 10 268 10 306 10 344 11 20 11 182 12 148 12 300 13 33 13 275 13 312 13 327 14 39 14 252 15 50 15 1...
result:
ok correct! (10 test cases)
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 28 1 46 1 89 1 91 1 118 1 141 1 148 1 149 1 162 2 8 2 22 2 39 2 49 2 50 2 61 2 82 2 92 2 97 2 98 2 148 3 12 3 28 3 58 3 61 3 74 3 79 3 90 3 109 3 134 3 167 4 5 4 18 4 36 4 56 4 77 4 93 4 105 4 113 4 118 4 153 5 8 5 10 5 41 5 56 5 58 5 71 5 75 5 114 5 131 6 17 6 19 6 57 6 79 6 105 6 106 6 1...
result:
Test #5:
score: 14.0323
Acceptable Answer
time: 1184ms
memory: 5724kb
input:
1 5 4 4 1 2 2 3 3 4 4 1 2850 24300
output:
2850 35311 1 148 1 167 1 420 1 431 1 576 1 611 1 631 1 817 1 863 1 1143 1 1193 1 1264 1 1362 1 1604 1 1842 1 1899 1 2011 1 2204 1 2277 1 2535 1 2656 1 2705 1 2713 1 2730 1 2745 1 2849 2 3 2 21 2 30 2 40 2 116 2 167 2 292 2 333 2 432 2 497 2 513 2 532 2 603 2 1090 2 1365 2 1447 2 1636 2 1684 2 1768 2...
result:
points 0.46774376260 m' = 35311, 3M = 72900, points = 14.032313
Test #6:
score: 0
Wrong Answer
time: 381ms
memory: 3988kb
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 2113 1 39 1 70 1 117 1 157 1 160 1 195 1 216 1 231 1 245 1 288 1 289 1 317 2 69 2 100 2 117 2 187 2 262 2 277 2 283 2 284 2 294 2 313 2 343 3 46 3 52 3 100 3 119 3 139 3 164 3 249 3 261 3 272 3 279 3 281 3 317 4 40 4 71 4 147 4 157 4 180 4 188 4 215 4 220 4 315 4 328 4 340 5 29 5 67 5 78 5 91 5 ...
result:
wrong answer Integer parameter [name=m] equals to 2113, violates the range [2350, 58653]