QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#379093 | #8566. Can We Still Qualify For Semifinals? | ucup-team266# | WA | 0ms | 3832kb | C++23 | 3.2kb | 2024-04-06 16:10:23 | 2024-04-06 16:10:25 |
Judging History
answer
//Author: Kevin
#include<bits/stdc++.h>
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
void die(string S){puts(S.c_str());exit(0);}
class MaximumFlow
{
private:
struct edge
{
int u,v,capa;
}E[10010];
edge make_edge(int u,int v,int capa)
{
edge e;
e.u=u;
e.v=v;
e.capa=capa;
return e;
}
vector<int> G[1010];
int p;
bool inque[1010];
int dep[1010];
bool bfs(int s,int t)
{
for(int i=0;i<1010;i++)
dep[i]=inf;
memset(inque,0,sizeof(inque));
dep[s]=0;
inque[s]=1;
queue<int> q;
q.push(s);
while(!q.empty())
{
int x=q.front();
q.pop();
inque[x]=0;
for(int e:G[x])
{
int v=E[e].v;
if(dep[v]>dep[x]+1&&E[e].capa)
{
dep[v]=dep[x]+1;
if(!inque[v])
{
q.push(v);
inque[v]=1;
}
}
}
}
return (dep[t]!=inf);
}
int dfs(int u,int t,int aug)
{
int naug=0;
if(u==t)
return aug;
for(int e:G[u])
{
int v=E[e].v;
if(E[e].capa&&dep[v]==dep[u]+1)
{
if((naug=dfs(v,t,min(aug,E[e].capa))))
{
E[e].capa-=naug;
E[e^1].capa+=naug;
return naug;
}
}
}
return 0;
}
public:
void clear()
{
p=0;
for(int i=0;i<1010;i++)
G[i].clear();
}
MaximumFlow()
{
clear();
}
void addEdge(int u,int v,int capa)
{
G[u].pb(p);
E[p++]=make_edge(u,v,capa);
G[v].pb(p);
E[p++]=make_edge(v,u,0);
}
int dinic(int s,int t)
{
int flow;
int maxflow=0;
while(bfs(s,t))
while((flow=dfs(s,t,inf)))
maxflow+=flow;
return maxflow;
}
};
MaximumFlow mf;
vector<int> a,b;
int cnt[15];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
for(int i=11;i>=3;i--)
{
vector<int> tmp;
tmp.pb(1);
for(int j=i;j<=10;j++)
tmp.pb(j);
for(int j=2;j<i;j++)
tmp.pb(j);
for(int x=0;x<5;x++)
a.pb(tmp[x]);
for(int x=0;x<5;x++)
b.pb(tmp[9-x]);
}
int t;
cin>>t;
while(t--)
{
mf.clear();
int k;
cin>>k;
string s;
cin>>s;
memset(cnt,0,sizeof(cnt));
for(int i=0;i<k;i++)
if(s[i]=='1')
cnt[a[i]]++;
else
cnt[b[i]]++;
int tot=0;
for(int i=k;i<45;i++)
if(a[i]==1||b[i]==1)
cnt[1]++;
else
{
mf.addEdge(100,i,1);
tot++;
mf.addEdge(i,45+a[i],1);
mf.addEdge(i,45+b[i],1);
}
bool flag=1;
for(int i=1;i<=10;i++)
if(cnt[i]>cnt[1])
flag=0;
for(int i=1;i<=10;i++)
mf.addEdge(45+i,101,cnt[1]-cnt[i]);
if(flag&&mf.dinic(100,101)==tot)
cout<<"YES\n";
else
cout<<"NO\n";
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3536kb
input:
3 3 111 25 1000010101111111111010100 35 01111011110111101111011110111101111
output:
YES YES NO
result:
ok 3 token(s): yes count is 2, no count is 1
Test #2:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
10 16 0110000001010100 17 01111000110110101 15 001100010101111 16 0010101010011100 19 0000000100010110100 16 0011101010011100 18 011110010001100000 18 000110101001100011 20 01100010000100100100 15 001000111001101
output:
YES YES YES YES YES YES YES YES YES YES
result:
ok 10 token(s): yes count is 10, no count is 0
Test #3:
score: 0
Accepted
time: 0ms
memory: 3828kb
input:
10 37 0110000001010100011101001011100110001 39 000100111101101001100101101000000000100 35 00111000100111100101011010111100100 33 010000010001110010110001101110001 30 000100010100000010010110101010 31 0000101000011010101001010000000 44 00001000000111101011010110000101100011000100 42 01111011110001001...
output:
NO NO NO NO NO NO NO NO NO NO
result:
ok 10 token(s): yes count is 0, no count is 10
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3832kb
input:
10 23 01100000010101000111010 38 01111001100011000101011110101001101001 27 010000000001001001110001001 26 01101001110011101101000110 8 00001000 22 0110100110001110110001 9 000100010 24 000000100101101010100100 6 011000 29 01101010100101000000000000100
output:
NO NO NO NO YES NO YES NO YES NO
result:
wrong answer expected YES, found NO [1st token]