提出 #41850733
ソースコード 拡げる
// LUOGU_RID: 111625378
#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define PB push_back
#define fi first
#define se second
using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using LL=__int128;
using namespace std;const int N=1e5+5,M=N*10+5,K=20,mod=998244353,Mod=mod-1;const db eps=1e-9;const int INF=1e9+7;mt19937 rnd(time(0));
int m,n,d,x,y,vis[N],S,T,X[N],Y[N];vector<int> G[N];
struct yyy{int to,w,z;};struct ljb{int head,h[N];yyy f[M];void add(int x,int y,int z){f[++head]=(yyy){y,z,h[x]};h[x]=head;}}s;
void con(int x,int y,int z){s.add(x,y,z);s.add(y,x,0);}
namespace Dicnic{
int d[N],Ns[N];queue<int> Q;
int bfs(){
queue<int> Q;fill(d,d+T+1,INF);d[S]=0;Q.push(S);Ns[S]=s.h[S];while(!Q.empty()){
int x=Q.front();Q.pop();yyy tmp;for(int i=s.h[x];i;i=tmp.z){
tmp=s.f[i];if(!tmp.w||d[tmp.to]<=d[x]+1) continue;d[tmp.to]=d[x]+1;
Q.push(tmp.to);Ns[tmp.to]=s.h[tmp.to];if(tmp.to==T) return 1;
}
}return 0;
}
int dfs(int x,int Sum){
if(x==T) return Sum;yyy tmp;int k,pus=0;for(int &i=Ns[x];i&∑i=tmp.z){
tmp=s.f[i];if(!tmp.w||d[tmp.to]!=d[x]+1) continue;k=dfs(tmp.to,min(tmp.w,Sum));
if(!k) d[tmp.to]=INF;s.f[i].w-=k;s.f[i^1].w+=k;Sum-=k;pus+=k;
}return pus;
}
int calc(){int Ans=0;while(bfs()) Ans+=dfs(S,INF);return Ans;}
}
int Ct;
namespace Tarjan{
int dfn[N],low[N],dh,st[N],sh,vis[N];
void Cl(){fill(dfn+1,dfn+n+1,0);fill(low+1,low+n+1,0);fill(st+1,st+n+1,0);fill(vis+1,vis+n+1,0);sh=dh=0;}
void Tarjan(int x){
dfn[x]=low[x]=++dh;st[++sh]=x;vis[x]=1;for(int i:G[x]) {
if(!dfn[i]) Tarjan(i),low[x]=min(low[x],low[i]);else if(vis[i]) low[x]=min(low[x],dfn[i]);
}if(low[x]==dfn[x]){++Ct;while(st[sh+1]^x) vis[st[sh--]]=0;}
}
void BD(){for(int i=1;i<=n;i++) if(!dfn[i]) Tarjan(i);}
}
void Solve(){
int i,j;fill(s.h,s.h+T+1,0);s.head=1;for(i=1;i<=n;i++) G[i].clear();Tarjan::Cl();
scanf("%d%d",&n,&d);S=0;T=n+n*d+1;for(i=1;i<=n;i++) con(S,i,d);
for(i=1;i<=n*d;i++) scanf("%d%d",&X[i],&Y[i]),con(i+n,T,1),con(X[i],i+n,1),con(Y[i],i+n,1);
if(Dicnic::calc()!=n*d) {puts("No");return;}
for(i=1;i<=n;i++) {
yyy tmp;for(int j=s.h[i];j;j=tmp.z) tmp=s.f[j],tmp.to^S&&!tmp.w&&(G[i].PB(X[tmp.to-n]^Y[tmp.to-n]^i),0);
}
Ct=0;Tarjan::BD();
cerr<<Ct<<'\n';
puts(Ct^1?"No":"Yes");
}
int main(){
int t;scanf("%d",&t);while(t--) Solve();
}
提出情報
コンパイルエラー
./Main.cpp: In function ‘int Dicnic::dfs(int, int)’:
./Main.cpp:30:3: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
30 | if(x==T) return Sum;yyy tmp;int k,pus=0;for(int &i=Ns[x];i&∑i=tmp.z){
| ^~
./Main.cpp:30:23: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
30 | if(x==T) return Sum;yyy tmp;int k,pus=0;for(int &i=Ns[x];i&∑i=tmp.z){
| ^~~
./Main.cpp:32:4: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
32 | if(!k) d[tmp.to]=INF;s.f[i].w-=k;s.f[i^1].w+=k;Sum-=k;pus+=k;
| ^~
./Main.cpp:32:25: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
32 | if(!k) d[tmp.to]=INF;s.f[i].w-=k;s.f[i^1].w+=k;Sum-=k;pus+=k;
| ^
./Main.cpp: In function ‘void Solve()’:
./Main.cpp:49:8: warning: unused variable ‘j’ [-Wunused-variable]
49 | int i,j;fill(s.h,s.h+T+1,0);s.head=1;for(i=1;i<=n;i++) G[i].clear();Tarjan::Cl();
| ^
./Main.cpp:50:7: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
50 | scanf("%d%d",&n,&d);S=0;T=n+n*d+1;for(i=1;i<=n;i++) con(S,i,d);
| ~~~~~^~~~~~~~~~~~~~
./Main.cpp:51:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
51 | for(i=1;i<=n*d;i++) scanf("%d%d",&X[i],&Y[i]),con(i+n,T,1),con(X[i],i+n,1),con(Y[i],i+n,1);
| ~~~~~^~~~~~~~~~~~~~~~~~~~
./Main.cpp: In function ‘int main()’:
./Main.cpp:61:13: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
61 | int t;scanf("%d",&t);while(t--) Solve();
| ~~~~~^~~~~~~~~
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
900 / 900 |
| 結果 |
|
|
| セット名 |
テストケース |
| Sample |
00-sample-001.txt |
| All |
00-sample-001.txt, 01-001.txt, 01-002.txt, 01-003.txt, 01-004.txt, 01-005.txt, 01-006.txt, 01-007.txt, 01-008.txt, 01-009.txt, 01-010.txt, 01-011.txt, 01-012.txt, 01-013.txt, 01-014.txt, 01-015.txt, 01-016.txt, 01-017.txt, 01-018.txt, 01-019.txt, 01-020.txt, 01-021.txt, 01-022.txt, 01-023.txt, 01-024.txt, 01-025.txt, 01-026.txt, 01-027.txt, 01-028.txt, 01-029.txt, 01-030.txt, 01-031.txt, 01-032.txt, 01-033.txt, 01-034.txt, 01-035.txt, 01-036.txt, 01-037.txt, 01-038.txt, 01-039.txt, 01-040.txt, 01-041.txt, 01-042.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| 00-sample-001.txt |
AC |
8 ms |
5868 KiB |
| 01-001.txt |
AC |
30 ms |
6004 KiB |
| 01-002.txt |
AC |
21 ms |
5884 KiB |
| 01-003.txt |
AC |
23 ms |
6288 KiB |
| 01-004.txt |
AC |
23 ms |
6296 KiB |
| 01-005.txt |
AC |
27 ms |
6236 KiB |
| 01-006.txt |
AC |
29 ms |
6476 KiB |
| 01-007.txt |
AC |
34 ms |
8292 KiB |
| 01-008.txt |
AC |
33 ms |
8348 KiB |
| 01-009.txt |
AC |
32 ms |
6264 KiB |
| 01-010.txt |
AC |
32 ms |
6352 KiB |
| 01-011.txt |
AC |
34 ms |
8456 KiB |
| 01-012.txt |
AC |
35 ms |
8472 KiB |
| 01-013.txt |
AC |
31 ms |
18428 KiB |
| 01-014.txt |
AC |
74 ms |
13752 KiB |
| 01-015.txt |
AC |
56 ms |
12084 KiB |
| 01-016.txt |
AC |
51 ms |
11456 KiB |
| 01-017.txt |
AC |
24 ms |
8704 KiB |
| 01-018.txt |
AC |
28 ms |
8808 KiB |
| 01-019.txt |
AC |
23 ms |
8432 KiB |
| 01-020.txt |
AC |
23 ms |
8436 KiB |
| 01-021.txt |
AC |
20 ms |
7312 KiB |
| 01-022.txt |
AC |
24 ms |
10624 KiB |
| 01-023.txt |
AC |
29 ms |
10672 KiB |
| 01-024.txt |
AC |
21 ms |
7784 KiB |
| 01-025.txt |
AC |
19 ms |
7904 KiB |
| 01-026.txt |
AC |
32 ms |
6852 KiB |
| 01-027.txt |
AC |
16 ms |
6176 KiB |
| 01-028.txt |
AC |
17 ms |
5968 KiB |
| 01-029.txt |
AC |
22 ms |
5884 KiB |
| 01-030.txt |
AC |
48 ms |
18512 KiB |
| 01-031.txt |
AC |
46 ms |
18408 KiB |
| 01-032.txt |
AC |
48 ms |
16236 KiB |
| 01-033.txt |
AC |
71 ms |
13736 KiB |
| 01-034.txt |
AC |
75 ms |
13748 KiB |
| 01-035.txt |
AC |
99 ms |
13248 KiB |
| 01-036.txt |
AC |
58 ms |
12024 KiB |
| 01-037.txt |
AC |
60 ms |
12024 KiB |
| 01-038.txt |
AC |
62 ms |
12008 KiB |
| 01-039.txt |
AC |
36 ms |
6984 KiB |
| 01-040.txt |
AC |
29 ms |
6056 KiB |
| 01-041.txt |
AC |
32 ms |
14276 KiB |
| 01-042.txt |
AC |
30 ms |
14384 KiB |