QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#395884 | #63. Meetings | Rafi22 | 0 | 6ms | 4240kb | C++14 | 1.9kb | 2024-04-22 00:07:01 | 2024-04-22 00:07:02 |
answer
#include <bits/stdc++.h>
#include "meetings.h"
//#define int long long
#define ll long long
#define ld long double
//#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;
int inf=1000000007;
ll infl=1000000000000000007;
ll mod=1000000007;
ll mod1=998244353;
const int N=2007;
set<int>G[N];
bool odw[N];
bool was[N];
int s[N];
void del(int u,int v)
{
G[v].erase(u);
G[u].erase(v);
//cout<<"DEL "<<u<<" "<<v<<endl;
}
void add(int u,int v)
{
G[v].insert(u);
G[u].insert(v);
//cout<<"ADD "<<u<<" "<<v<<endl;
}
void dfs(int v,int o)
{
s[v]=1;
for(auto u:G[v])
{
if(u==o||odw[v]) continue;
dfs(u,v);
s[v]+=s[u];
}
}
void Solve(int n)
{
vector<int>V;
for(int i=0;i<n;i++) V.pb(i);
random_shuffle(all(V));
add(V[0],V[1]);
for(int i=2;i<n;i++)
{
if(was[V[i]]) continue;
memset(odw,0,sizeof odw);
int r=V[0];
//cout<<"XD "<<V[i]<<endl;
while(true)
{
dfs(r,0);
int v=r;
while(true)
{
int nx=-1;
for(auto u:G[v]) if(!odw[u]&&s[u]>i/2&&s[u]<s[v]) nx=u;
if(nx==-1) break;
v=nx;
}
odw[v]=1;
//cout<<v<<endl;
vector<pair<int,int>>X;
for(auto u:G[v]) if(!odw[u]) X.pb({s[u],u});
sort(all(X),greater<pair<int,int>>());
bool is=0,is1=0;
for(auto [k,u]:X)
{
int t=Query(v,u,V[i]);
if(t!=v)
{
if(t==u)
{
r=u;
is1=1;
}
else if(t==V[i])
{
is=1;
del(u,v);
add(u,V[i]);
add(V[i],v);
}
else
{
is=1;
del(u,v);
add(u,t);
add(t,v);
add(t,V[i]);
}
break;
}
}
if(is) break;
if(!is1)
{
add(v,V[i]);
break;
}
}
}
for(int u=0;u<n;u++) for(auto v:G[u]) if(u<v) Bridge(u,v);
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 7
Accepted
time: 0ms
memory: 4192kb
input:
3 0 2 0 1
output:
Accepted: 1
result:
ok 1 move(s)
Test #2:
score: 0
Accepted
time: 0ms
memory: 3960kb
input:
4 1 2 0 2 0 3
output:
Accepted: 3
result:
ok 3 move(s)
Test #3:
score: 0
Accepted
time: 0ms
memory: 3944kb
input:
4 0 3 2 3 0 1
output:
Accepted: 2
result:
ok 2 move(s)
Test #4:
score: 0
Accepted
time: 0ms
memory: 4240kb
input:
5 2 4 2 3 0 2 1 3
output:
Accepted: 4
result:
ok 4 move(s)
Test #5:
score: -7
Wrong Answer
time: 0ms
memory: 4192kb
input:
5 3 4 0 1 0 2 0 3
output:
Wrong Answer [1]
result:
wrong answer
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Wrong Answer
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
100%
Accepted
Test #40:
score: 0
Wrong Answer
time: 6ms
memory: 4120kb
input:
2000 58 503 623 1403 1004 1083 249 491 1524 1849 192 562 1261 1877 547 909 267 896 747 1986 381 1329 57 317 779 886 469 1652 628 1456 1732 1790 700 825 494 1799 1450 1733 103 1069 1114 1342 243 1496 930 1361 240 905 398 1737 1008 1765 357 954 1157 1898 1228 1344 1062 1731 160 1977 40 364 343 694 108...
output:
Wrong Answer [1]
result:
wrong answer