Submission #53250821


Source Code Expand

// LUOGU_RID: 158436210
#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 fi first
#define se second
#define eb emplace_back
#define all(x) x.begin(),x.end()
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;
const int N=400+5,M=(1<<15)+5,K=1000+5,mod=1e9+7,Mod=mod-1;const db eps=1e-8;const int INF=1e9+7;mt19937 rnd(263082);
#define Tp template<typename T>
#define Ts template<typename T,typename... Ar>
namespace Debug{
	Tp void _debug(char* f,T t){cerr<<f<<'='<<t<<endl;}
	Ts void _debug(char* f,T x,Ar... y){while(*f!=',') cerr<<*f++;cerr<<'='<<x<<",";_debug(f+1,y...);}
	#ifdef LOCAL
	#define gdb(...) _debug((char*)#__VA_ARGS__,__VA_ARGS__)
	#else 
	#define gdb(...) void()
	#endif
}using namespace Debug;
int n,m,fa[N],flag[N],in[N],vis[N];
int GF(int x){return fa[x]^x?fa[x]=GF(fa[x]):x;}
void add(int x,int y){in[x]--;in[y]++;flag[x]=flag[y]=1;fa[GF(x)]=GF(y);gdb(x,y);}
void Solve(){
	int i,j;scanf("%d%d",&n,&m);
	iota(fa+1,fa+2*m+1,1);
	while(n--){
		int a,b,c,d;scanf("%d%d%d%d",&a,&b,&c,&d);
		add(c?c+m:a,d?d:b+m);
	}
	for(i=1;i<=2*m;i++) if(flag[i]){
		if(in[i]<0){
			if(i>m){puts("NO");return;}
			vis[GF(i)]=1;
		}
		if(in[i]>0){
			if(i<=m){puts("NO");return;}
			vis[GF(i)]=1;
		}
	}
	for(i=1;i<=2*m;i++) if(flag[i]&&!vis[GF(i)]){puts("NO");return;}
	puts("YES");
}
int main(){
	int t=1;
	// scanf("%d",&t);
	while(t--) Solve();
	cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}

Submission Info

Submission Time
Task E - Jigsaw
User fangxintong
Language C++ 20 (gcc 12.2)
Score 1200
Code Size 1696 Byte
Status AC
Exec Time 21 ms
Memory 3996 KiB

Compile Error

Main.cpp: In function ‘void Solve()’:
Main.cpp:32:15: warning: unused variable ‘j’ [-Wunused-variable]
   32 |         int i,j;scanf("%d%d",&n,&m);
      |               ^
Main.cpp:32:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   32 |         int i,j;scanf("%d%d",&n,&m);
      |                 ~~~~~^~~~~~~~~~~~~~
Main.cpp:35:34: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   35 |                 int a,b,c,d;scanf("%d%d%d%d",&a,&b,&c,&d);
      |                             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 1200 / 1200
Status
AC × 3
AC × 84
Set Name Test Cases
Sample sample1.txt, sample2.txt, sample3.txt
All sample1.txt, sample2.txt, sample3.txt, a1.txt, a2.txt, a3.txt, b1.txt, b10.txt, b101.txt, b102.txt, b103.txt, b104.txt, b105.txt, b106.txt, b107.txt, b108.txt, b109.txt, b11.txt, b110.txt, b111.txt, b112.txt, b113.txt, b114.txt, b115.txt, b116.txt, b117.txt, b118.txt, b119.txt, b12.txt, b13.txt, b14.txt, b15.txt, b2.txt, b200.txt, b201.txt, b202.txt, b203.txt, b204.txt, b205.txt, b206.txt, b207.txt, b208.txt, b209.txt, b210.txt, b211.txt, b212.txt, b213.txt, b214.txt, b215.txt, b216.txt, b217.txt, b218.txt, b219.txt, b3.txt, b300.txt, b301.txt, b302.txt, b303.txt, b304.txt, b305.txt, b306.txt, b307.txt, b308.txt, b309.txt, b310.txt, b311.txt, b4.txt, b5.txt, b6.txt, b7.txt, b8.txt, b9.txt, c1.txt, c2.txt, c3.txt, c4.txt, c5.txt, d1.txt, d2.txt, d3.txt, d4.txt, sample1.txt, sample2.txt, sample3.txt
Case Name Status Exec Time Memory
a1.txt AC 1 ms 3812 KiB
a2.txt AC 3 ms 3632 KiB
a3.txt AC 20 ms 3884 KiB
b1.txt AC 1 ms 3820 KiB
b10.txt AC 5 ms 3788 KiB
b101.txt AC 20 ms 3848 KiB
b102.txt AC 20 ms 3724 KiB
b103.txt AC 20 ms 3820 KiB
b104.txt AC 20 ms 3860 KiB
b105.txt AC 20 ms 3812 KiB
b106.txt AC 9 ms 3864 KiB
b107.txt AC 18 ms 3820 KiB
b108.txt AC 20 ms 3724 KiB
b109.txt AC 18 ms 3820 KiB
b11.txt AC 13 ms 3600 KiB
b110.txt AC 20 ms 3812 KiB
b111.txt AC 20 ms 3768 KiB
b112.txt AC 20 ms 3888 KiB
b113.txt AC 20 ms 3788 KiB
b114.txt AC 20 ms 3896 KiB
b115.txt AC 10 ms 3892 KiB
b116.txt AC 18 ms 3784 KiB
b117.txt AC 20 ms 3844 KiB
b118.txt AC 16 ms 3884 KiB
b119.txt AC 18 ms 3812 KiB
b12.txt AC 14 ms 3860 KiB
b13.txt AC 20 ms 3848 KiB
b14.txt AC 20 ms 3848 KiB
b15.txt AC 21 ms 3724 KiB
b2.txt AC 3 ms 3784 KiB
b200.txt AC 20 ms 3888 KiB
b201.txt AC 20 ms 3788 KiB
b202.txt AC 20 ms 3836 KiB
b203.txt AC 20 ms 3896 KiB
b204.txt AC 19 ms 3820 KiB
b205.txt AC 20 ms 3848 KiB
b206.txt AC 19 ms 3756 KiB
b207.txt AC 20 ms 3996 KiB
b208.txt AC 19 ms 3812 KiB
b209.txt AC 19 ms 3788 KiB
b210.txt AC 20 ms 3840 KiB
b211.txt AC 20 ms 3792 KiB
b212.txt AC 19 ms 3840 KiB
b213.txt AC 20 ms 3888 KiB
b214.txt AC 20 ms 3892 KiB
b215.txt AC 20 ms 3892 KiB
b216.txt AC 19 ms 3640 KiB
b217.txt AC 19 ms 3740 KiB
b218.txt AC 19 ms 3724 KiB
b219.txt AC 20 ms 3788 KiB
b3.txt AC 20 ms 3760 KiB
b300.txt AC 18 ms 3792 KiB
b301.txt AC 18 ms 3760 KiB
b302.txt AC 10 ms 3812 KiB
b303.txt AC 11 ms 3704 KiB
b304.txt AC 18 ms 3892 KiB
b305.txt AC 18 ms 3700 KiB
b306.txt AC 12 ms 3840 KiB
b307.txt AC 11 ms 3780 KiB
b308.txt AC 16 ms 3768 KiB
b309.txt AC 18 ms 3788 KiB
b310.txt AC 13 ms 3760 KiB
b311.txt AC 14 ms 3896 KiB
b4.txt AC 19 ms 3812 KiB
b5.txt AC 3 ms 3888 KiB
b6.txt AC 3 ms 3892 KiB
b7.txt AC 3 ms 3724 KiB
b8.txt AC 3 ms 3720 KiB
b9.txt AC 3 ms 3764 KiB
c1.txt AC 15 ms 3888 KiB
c2.txt AC 14 ms 3784 KiB
c3.txt AC 12 ms 3992 KiB
c4.txt AC 14 ms 3888 KiB
c5.txt AC 8 ms 3996 KiB
d1.txt AC 19 ms 3788 KiB
d2.txt AC 20 ms 3820 KiB
d3.txt AC 20 ms 3784 KiB
d4.txt AC 16 ms 3888 KiB
sample1.txt AC 1 ms 3844 KiB
sample2.txt AC 1 ms 3636 KiB
sample3.txt AC 1 ms 3764 KiB