Submission #1776260


Source Code Expand

#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
int M=0,fst[SZ],vb[SZ],nxt[SZ],in[SZ],ou[SZ];
int ff[SZ];
int gf(int x) {return ff[x]?ff[x]=gf(ff[x]):x;}
void uni(int a,int b)
{
	int ga=gf(a),gb=gf(b);
	if(ga^gb) ff[ga]=gb;
}
void ad_de(int a,int b)
{++in[b]; ++ou[a]; uni(a,b);
++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}
int n,h;
bool bb[SZ];
#define GG {puts("NO"); exit(0);}
int main()
{
	scanf("%d%d",&n,&h);
	for(int i=1,a,b,c,d,l,r;i<=n;++i)
	{
		scanf("%d%d%d%d",&a,&b,&c,&d);
		if(!c) l=a; else l=-c;
		if(!d) r=-b; else r=d;
		ad_de(l+n+1,r+n+1);
	}
	for(int i=n+1;i<=n+n;++i)
		if(ou[i]<in[i]) GG
	for(int i=1;i<=n;++i)
		if(in[i]<ou[i]) GG
	for(int i=1;i<=n+n;++i)
		if(in[i]!=ou[i]) bb[gf(i)]=1;
	for(int i=1;i<=n+n;++i)
		if((in[i]||ou[i])&&gf(i)==i&&!bb[i]) GG
	puts("YES");
}

Submission Info

Submission Time
Task E - Jigsaw
User fjzzq2002
Language C++14 (GCC 5.4.1)
Score 1200
Code Size 1826 Byte
Status AC
Exec Time 31 ms
Memory 10496 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:49:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&h);
                     ^
./Main.cpp:52:32: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   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 3 ms 10496 KB
a2.txt AC 6 ms 10496 KB
a3.txt AC 30 ms 10496 KB
b1.txt AC 3 ms 10496 KB
b10.txt AC 9 ms 10496 KB
b101.txt AC 30 ms 10496 KB
b102.txt AC 30 ms 10496 KB
b103.txt AC 30 ms 10496 KB
b104.txt AC 30 ms 10496 KB
b105.txt AC 31 ms 10496 KB
b106.txt AC 15 ms 10496 KB
b107.txt AC 28 ms 10496 KB
b108.txt AC 30 ms 10496 KB
b109.txt AC 28 ms 10496 KB
b11.txt AC 21 ms 10496 KB
b110.txt AC 30 ms 10496 KB
b111.txt AC 30 ms 10496 KB
b112.txt AC 31 ms 10496 KB
b113.txt AC 30 ms 10496 KB
b114.txt AC 30 ms 10496 KB
b115.txt AC 15 ms 10496 KB
b116.txt AC 28 ms 10496 KB
b117.txt AC 31 ms 10496 KB
b118.txt AC 24 ms 10496 KB
b119.txt AC 28 ms 10496 KB
b12.txt AC 22 ms 10496 KB
b13.txt AC 30 ms 10496 KB
b14.txt AC 30 ms 10496 KB
b15.txt AC 30 ms 10496 KB
b2.txt AC 6 ms 10496 KB
b200.txt AC 30 ms 10496 KB
b201.txt AC 30 ms 10496 KB
b202.txt AC 30 ms 10496 KB
b203.txt AC 30 ms 10496 KB
b204.txt AC 30 ms 10496 KB
b205.txt AC 30 ms 10496 KB
b206.txt AC 30 ms 10496 KB
b207.txt AC 30 ms 10496 KB
b208.txt AC 30 ms 10496 KB
b209.txt AC 29 ms 10496 KB
b210.txt AC 30 ms 10496 KB
b211.txt AC 30 ms 10496 KB
b212.txt AC 30 ms 10496 KB
b213.txt AC 30 ms 10496 KB
b214.txt AC 30 ms 10496 KB
b215.txt AC 29 ms 10496 KB
b216.txt AC 30 ms 10496 KB
b217.txt AC 30 ms 10496 KB
b218.txt AC 29 ms 10496 KB
b219.txt AC 30 ms 10496 KB
b3.txt AC 30 ms 10496 KB
b300.txt AC 29 ms 10496 KB
b301.txt AC 29 ms 10496 KB
b302.txt AC 22 ms 10496 KB
b303.txt AC 22 ms 10496 KB
b304.txt AC 29 ms 10496 KB
b305.txt AC 29 ms 10496 KB
b306.txt AC 23 ms 10496 KB
b307.txt AC 22 ms 10496 KB
b308.txt AC 27 ms 10496 KB
b309.txt AC 29 ms 10496 KB
b310.txt AC 28 ms 10496 KB
b311.txt AC 27 ms 10496 KB
b4.txt AC 30 ms 10496 KB
b5.txt AC 6 ms 10496 KB
b6.txt AC 6 ms 10496 KB
b7.txt AC 6 ms 10496 KB
b8.txt AC 6 ms 10496 KB
b9.txt AC 6 ms 10496 KB
c1.txt AC 27 ms 10496 KB
c2.txt AC 28 ms 10496 KB
c3.txt AC 23 ms 10496 KB
c4.txt AC 27 ms 10496 KB
c5.txt AC 16 ms 10496 KB
d1.txt AC 30 ms 10496 KB
d2.txt AC 31 ms 10496 KB
d3.txt AC 30 ms 10496 KB
d4.txt AC 24 ms 10496 KB
sample1.txt AC 3 ms 10496 KB
sample2.txt AC 3 ms 10496 KB
sample3.txt AC 3 ms 10496 KB