QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#351846 | #8315. Candy Ads | Lynkcat | WA | 12ms | 77096kb | C++20 | 2.6kb | 2024-03-12 16:16:33 | 2024-03-12 16:16:33 |
Judging History
answer
#include<bits/stdc++.h>
#define poly vector<int>
#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
using namespace std;
const int N=100005;
bitset<50001>L[3][2005],R[3][2005],vs[2];
int dfn[N],idfn[N],DFN;
int n,W,H;
poly G[N],rG[N];
int scc[N],scc_tot;
int l[N][3],r[N][3];
inline int id(int x,int y)
{
return 2*x-1+y;
}
inline int fd(int k,int x)
{
bitset<50001>now=vs[x];
for (int i=0;i<3;i++) now&=L[i][l[k][i]]&R[i][r[k][i]];
now[k]=0;
return now._Find_first();
}
void dfs(int k)
{
dfn[k]=++DFN;
idfn[DFN]=k;
if (!(k%2))
{
while (1)
{
int v=fd((k+1)/2,0);
if (v==50001) break;
dfs(v*2-1);
}
} else
vs[0][(k+1)/2]=0;
for (auto u:G[k])
if (!dfn[u])
{
dfs(u);
}
}
void dfs1(int k)
{
// assert(!scc[k]);
scc[k]=scc_tot;
// cout<<k<<" "<<scc[k]<<" "<<endl;
if ((k%2))
{
while (1)
{
int v=fd((k+1)/2,1);
if (v==50001) break;
dfs1(v*2);
}
} else
vs[1][(k+1)/2]=0;
for (auto u:rG[k])
if (!scc[u])
{
dfs1(u);
}
}
void BellaKira()
{
cin>>n>>W>>H;
for (int i=1;i<=n;i++)
{
cin>>l[i][0]>>r[i][0];
cin>>l[i][1]>>l[i][2];
r[i][1]=l[i][1]+W-1;
r[i][2]=l[i][2]+H-1;
r[i][1]=min(r[i][1],2000);
r[i][2]=min(r[i][2],2000);
// for (int j=0;j<3;j++) cout<<l[i][j]<<";"<<r[i][j]<<'\n';
// cout<<endl;
}
for (int j=0;j<3;j++)
{
for (int i=1;i<=n;i++)
L[j][r[i][j]][i]=1,
R[j][l[i][j]][i]=1;
for (int i=1;i<=2000;i++) R[j][i]|=R[j][i-1];
for (int i=2000;i>=1;i--) L[j][i]|=L[j][i+1];
}
int m;
cin>>m;
while (m--)
{
int x,y;
cin>>x>>y;
G[id(x,0)].push_back(id(y,1));
G[id(y,0)].push_back(id(x,1));
rG[id(x,1)].push_back(id(y,0));
rG[id(y,1)].push_back(id(x,0));
}
for (int i=1;i<=n;i++) vs[0][i]=1;
// vs[0][2]=0;
// cout<<"???asdasd "<<fd(1,0)<<endl;
for (int i=1;i<=2*n;i++)
if (!dfn[i]) dfs(i);
for (int i=1;i<=n;i++) vs[1][i]=1;
for (int i=2*n;i>=1;i--)
if (!scc[idfn[i]])
{
++scc_tot;
dfs1(idfn[i]);
}
for (int i=1;i<=n;i++)
if (scc[id(i,0)]==scc[id(i,1)])
{
cout<<"No\n";
return;
}
cout<<"Yes\n";
for (int i=1;i<=n;i++)
cout<<(scc[id(i,1)]<scc[id(i,0)]);
cout<<'\n';
}
signed main()
{
IOS;
cin.tie(0);
int T=1;
while (T--)
{
BellaKira();
}
}
/*list:
1.mod 998244353 or 1e9+7 or ???
2.N
3.duipai shuju xingtai duoyidian
...
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 12ms
memory: 76956kb
input:
2 2 2 1 2 1 1 2 3 2 2 1 1 2
output:
Yes 10
result:
ok accepted
Test #2:
score: 0
Accepted
time: 4ms
memory: 77096kb
input:
3 2 2 1 2 1 1 1 3 1 2 2 3 2 2 3 1 2 2 3 1 3
output:
No
result:
ok accepted
Test #3:
score: -100
Wrong Answer
time: 8ms
memory: 77000kb
input:
10 3 3 2 3 7 10 1 3 9 6 3 5 2 1 4 5 8 9 4 7 1 7 3 4 4 4 6 8 9 5 1 3 6 7 2 5 7 4 6 9 9 9 10 9 1 6 2 8 5 9 5 10 4 5 1 3 2 10 9 9 5 8 2
output:
Yes 1101001000
result:
wrong answer both 8 and 5 are not chosen