답안 #276327

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
276327 2020-08-20T12:07:16 Z AKaan37 Building Skyscrapers (CEOI19_skyscrapers) C++17
54 / 100
1778 ms 98248 KB
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;
typedef pair< lo,PII > PIII;

#define fi first
#define se second
#define mp make_pair
#define endl "\n"
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo inf = 1000000000000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 200005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t,fa[li],vis[li],c[li],bos[li];
int cev;
PIII p[li];
string s;
map<PII,int> mpp;
vector<int> vv;
vector<PII> v[li];

inline int dsu(int x){
	if(x==fa[x])return x;
	return fa[x]=dsu(fa[x]);
}

inline void dfs(int node){
	set<PII> st;
	st.insert({a[node],b[node]});
	while(st.size()){
		auto it=st.begin();
		PII pa=*it;
		int node=mpp[pa];
		st.erase(it);
		if(vis[node])continue;
		vv.pb(node);
		vis[node]=1;
		for(int i=0;i<(int)v[node].size();i++){
			int go=v[node][i].se;
			//~ if(st.find({bos[go],{-c[go],go}})!=st.end())st.erase({bos[go],{-c[go],go}});
			bos[go]--;
			st.insert({a[go],b[go]});
		}
	}
}

int main(void){
	scanf("%d %d",&n,&t);
	FOR bos[i]=4;
	FOR fa[i]=i;
	FOR{
		int x,y;
		scanf("%d %d",&a[i],&b[i]);
		x=a[i];
		y=b[i];
		cev=0;
		p[i].fi=x;
		p[i].se.fi=y;
		p[i].se.se=i;
		if(mpp[{x-1,y}]){
			cev++;
		}
		if(mpp[{x+1,y}]){
			cev++;
		}
		if(mpp[{x,y-1}]){
			cev++;
		}
		if(mpp[{x,y+1}]){
			cev++;
		}
		c[i]=cev;
		mpp[{x,y}]=i;
	}
	mpp.clear();
	FOR{
		int x,y;
		x=a[i];
		y=b[i];
		if(mpp[{x-1,y}]){
			v[mpp[{x-1,y}]].pb({c[i],i});
			v[i].pb({c[mpp[{x-1,y}]],mpp[{x-1,y}]});
		}
		if(mpp[{x+1,y}]){
			v[mpp[{x+1,y}]].pb({c[i],i});
			v[i].pb({c[mpp[{x+1,y}]],mpp[{x+1,y}]});
		}
		if(mpp[{x,y-1}]){
			v[mpp[{x,y-1}]].pb({c[i],i});
			v[i].pb({c[mpp[{x,y-1}]],mpp[{x,y-1}]});
		}
		if(mpp[{x,y+1}]){
			v[mpp[{x,y+1}]].pb({c[i],i});
			v[i].pb({c[mpp[{x,y+1}]],mpp[{x,y+1}]});
		}
		if(mpp[{x+1,y+1}]){
			v[mpp[{x+1,y+1}]].pb({c[i],i});
			v[i].pb({c[mpp[{x+1,y+1}]],mpp[{x+1,y+1}]});
		}
		if(mpp[{x-1,y+1}]){
			v[mpp[{x-1,y+1}]].pb({c[i],i});
			v[i].pb({c[mpp[{x-1,y+1}]],mpp[{x-1,y+1}]});
		}
		if(mpp[{x-1,y-1}]){
			v[mpp[{x-1,y-1}]].pb({c[i],i});
			v[i].pb({c[mpp[{x-1,y-1}]],mpp[{x-1,y-1}]});
		}
		if(mpp[{x+1,y-1}]){
			v[mpp[{x+1,y-1}]].pb({c[i],i});
			v[i].pb({c[mpp[{x+1,y-1}]],mpp[{x+1,y-1}]});
		}
		mpp[{x,y}]=i;
	}
	int mx=-1;
	int ind=0;
	sort(p+1,p+n+1);
	ind=p[1].se.se;
	dfs(ind);
	FOR{
		if(vis[i]==0){printf("NO\n");return 0;}
	}
	printf("YES\n");
	
	for(int i=0;i<n;i++)printf("%d\n",vv[i]);
	return 0;
}

Compilation message

skyscrapers.cpp: In function 'int main()':
skyscrapers.cpp:130:6: warning: unused variable 'mx' [-Wunused-variable]
  130 |  int mx=-1;
      |      ^~
skyscrapers.cpp:64:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   64 |  scanf("%d %d",&n,&t);
      |  ~~~~~^~~~~~~~~~~~~~~
skyscrapers.cpp:69:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   69 |   scanf("%d %d",&a[i],&b[i]);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 4992 KB ans=YES N=1
2 Correct 4 ms 4992 KB ans=YES N=4
3 Correct 4 ms 4992 KB ans=NO N=4
4 Correct 4 ms 5120 KB ans=YES N=5
5 Correct 4 ms 4992 KB ans=YES N=9
6 Correct 4 ms 4992 KB ans=YES N=5
7 Correct 4 ms 4992 KB ans=NO N=9
8 Correct 4 ms 4992 KB ans=NO N=10
9 Correct 4 ms 4992 KB ans=YES N=10
10 Correct 4 ms 5120 KB ans=YES N=10
11 Correct 4 ms 5120 KB ans=YES N=10
12 Correct 4 ms 5120 KB ans=YES N=9
13 Correct 4 ms 5056 KB ans=YES N=9
14 Correct 4 ms 4992 KB ans=YES N=8
15 Correct 5 ms 4992 KB ans=YES N=8
16 Correct 4 ms 4992 KB ans=NO N=2
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 4992 KB ans=YES N=1
2 Correct 4 ms 4992 KB ans=YES N=4
3 Correct 4 ms 4992 KB ans=NO N=4
4 Correct 4 ms 5120 KB ans=YES N=5
5 Correct 4 ms 4992 KB ans=YES N=9
6 Correct 4 ms 4992 KB ans=YES N=5
7 Correct 4 ms 4992 KB ans=NO N=9
8 Correct 4 ms 4992 KB ans=NO N=10
9 Correct 4 ms 4992 KB ans=YES N=10
10 Correct 4 ms 5120 KB ans=YES N=10
11 Correct 4 ms 5120 KB ans=YES N=10
12 Correct 4 ms 5120 KB ans=YES N=9
13 Correct 4 ms 5056 KB ans=YES N=9
14 Correct 4 ms 4992 KB ans=YES N=8
15 Correct 5 ms 4992 KB ans=YES N=8
16 Correct 4 ms 4992 KB ans=NO N=2
17 Correct 4 ms 5096 KB ans=YES N=17
18 Correct 5 ms 5120 KB ans=YES N=25
19 Correct 4 ms 5120 KB ans=YES N=100
20 Correct 5 ms 5120 KB ans=YES N=185
21 Correct 6 ms 5120 KB ans=NO N=174
22 Correct 5 ms 5120 KB ans=YES N=90
23 Correct 4 ms 5120 KB ans=YES N=63
24 Correct 4 ms 5120 KB ans=YES N=87
25 Correct 5 ms 5076 KB ans=YES N=183
26 Correct 5 ms 5120 KB ans=YES N=188
27 Correct 6 ms 5120 KB ans=YES N=183
28 Correct 6 ms 5120 KB ans=YES N=189
29 Correct 6 ms 5120 KB ans=YES N=200
30 Correct 4 ms 5120 KB ans=YES N=190
31 Correct 5 ms 5152 KB ans=YES N=187
32 Correct 4 ms 5120 KB ans=YES N=187
33 Correct 6 ms 5120 KB ans=YES N=182
34 Correct 4 ms 5120 KB ans=YES N=184
35 Correct 5 ms 5120 KB ans=YES N=188
36 Correct 5 ms 5096 KB ans=YES N=181
37 Correct 5 ms 5120 KB ans=YES N=188
38 Correct 4 ms 5120 KB ans=YES N=191
39 Correct 4 ms 5120 KB ans=YES N=196
40 Correct 4 ms 5120 KB ans=YES N=196
41 Correct 4 ms 5120 KB ans=YES N=196
42 Correct 5 ms 5120 KB ans=YES N=196
43 Correct 5 ms 5120 KB ans=YES N=195
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 4992 KB ans=YES N=1
2 Correct 4 ms 4992 KB ans=YES N=4
3 Correct 4 ms 4992 KB ans=NO N=4
4 Correct 4 ms 5120 KB ans=YES N=5
5 Correct 4 ms 4992 KB ans=YES N=9
6 Correct 4 ms 4992 KB ans=YES N=5
7 Correct 4 ms 4992 KB ans=NO N=9
8 Correct 4 ms 4992 KB ans=NO N=10
9 Correct 4 ms 4992 KB ans=YES N=10
10 Correct 4 ms 5120 KB ans=YES N=10
11 Correct 4 ms 5120 KB ans=YES N=10
12 Correct 4 ms 5120 KB ans=YES N=9
13 Correct 4 ms 5056 KB ans=YES N=9
14 Correct 4 ms 4992 KB ans=YES N=8
15 Correct 5 ms 4992 KB ans=YES N=8
16 Correct 4 ms 4992 KB ans=NO N=2
17 Correct 4 ms 5096 KB ans=YES N=17
18 Correct 5 ms 5120 KB ans=YES N=25
19 Correct 4 ms 5120 KB ans=YES N=100
20 Correct 5 ms 5120 KB ans=YES N=185
21 Correct 6 ms 5120 KB ans=NO N=174
22 Correct 5 ms 5120 KB ans=YES N=90
23 Correct 4 ms 5120 KB ans=YES N=63
24 Correct 4 ms 5120 KB ans=YES N=87
25 Correct 5 ms 5076 KB ans=YES N=183
26 Correct 5 ms 5120 KB ans=YES N=188
27 Correct 6 ms 5120 KB ans=YES N=183
28 Correct 6 ms 5120 KB ans=YES N=189
29 Correct 6 ms 5120 KB ans=YES N=200
30 Correct 4 ms 5120 KB ans=YES N=190
31 Correct 5 ms 5152 KB ans=YES N=187
32 Correct 4 ms 5120 KB ans=YES N=187
33 Correct 6 ms 5120 KB ans=YES N=182
34 Correct 4 ms 5120 KB ans=YES N=184
35 Correct 5 ms 5120 KB ans=YES N=188
36 Correct 5 ms 5096 KB ans=YES N=181
37 Correct 5 ms 5120 KB ans=YES N=188
38 Correct 4 ms 5120 KB ans=YES N=191
39 Correct 4 ms 5120 KB ans=YES N=196
40 Correct 4 ms 5120 KB ans=YES N=196
41 Correct 4 ms 5120 KB ans=YES N=196
42 Correct 5 ms 5120 KB ans=YES N=196
43 Correct 5 ms 5120 KB ans=YES N=195
44 Correct 10 ms 6272 KB ans=NO N=1934
45 Correct 12 ms 5632 KB ans=NO N=1965
46 Correct 17 ms 5632 KB ans=YES N=1824
47 Correct 20 ms 5640 KB ans=YES N=1981
48 Correct 16 ms 5632 KB ans=YES N=1814
49 Correct 17 ms 5632 KB ans=YES N=1854
50 Correct 14 ms 5632 KB ans=YES N=1831
51 Correct 19 ms 5632 KB ans=YES N=2000
52 Correct 13 ms 5632 KB ans=YES N=1847
53 Correct 16 ms 5632 KB ans=YES N=1819
54 Correct 14 ms 5632 KB ans=YES N=1986
55 Correct 13 ms 5760 KB ans=YES N=2000
56 Correct 14 ms 5760 KB ans=YES N=1834
57 Correct 12 ms 5760 KB ans=YES N=1860
58 Correct 14 ms 5760 KB ans=YES N=1898
59 Correct 13 ms 5760 KB ans=YES N=1832
60 Correct 13 ms 5760 KB ans=YES N=1929
61 Correct 14 ms 5740 KB ans=YES N=1919
62 Correct 15 ms 5792 KB ans=YES N=1882
63 Correct 13 ms 5888 KB ans=YES N=1922
64 Correct 14 ms 5760 KB ans=YES N=1989
65 Correct 11 ms 5632 KB ans=YES N=1978
66 Correct 12 ms 5632 KB ans=YES N=1867
67 Correct 14 ms 5632 KB ans=YES N=1942
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 6272 KB ans=NO N=1934
2 Correct 12 ms 5632 KB ans=NO N=1965
3 Incorrect 14 ms 5632 KB Contestant's solution is not lexicographically largest at index 1824 (1813 vs 1702)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 4992 KB ans=YES N=1
2 Correct 4 ms 4992 KB ans=YES N=4
3 Correct 4 ms 4992 KB ans=NO N=4
4 Correct 4 ms 5120 KB ans=YES N=5
5 Correct 4 ms 4992 KB ans=YES N=9
6 Correct 4 ms 4992 KB ans=YES N=5
7 Correct 4 ms 4992 KB ans=NO N=9
8 Correct 4 ms 4992 KB ans=NO N=10
9 Correct 4 ms 4992 KB ans=YES N=10
10 Correct 4 ms 5120 KB ans=YES N=10
11 Correct 4 ms 5120 KB ans=YES N=10
12 Correct 4 ms 5120 KB ans=YES N=9
13 Correct 4 ms 5056 KB ans=YES N=9
14 Correct 4 ms 4992 KB ans=YES N=8
15 Correct 5 ms 4992 KB ans=YES N=8
16 Correct 4 ms 4992 KB ans=NO N=2
17 Correct 4 ms 5096 KB ans=YES N=17
18 Correct 5 ms 5120 KB ans=YES N=25
19 Correct 4 ms 5120 KB ans=YES N=100
20 Correct 5 ms 5120 KB ans=YES N=185
21 Correct 6 ms 5120 KB ans=NO N=174
22 Correct 5 ms 5120 KB ans=YES N=90
23 Correct 4 ms 5120 KB ans=YES N=63
24 Correct 4 ms 5120 KB ans=YES N=87
25 Correct 5 ms 5076 KB ans=YES N=183
26 Correct 5 ms 5120 KB ans=YES N=188
27 Correct 6 ms 5120 KB ans=YES N=183
28 Correct 6 ms 5120 KB ans=YES N=189
29 Correct 6 ms 5120 KB ans=YES N=200
30 Correct 4 ms 5120 KB ans=YES N=190
31 Correct 5 ms 5152 KB ans=YES N=187
32 Correct 4 ms 5120 KB ans=YES N=187
33 Correct 6 ms 5120 KB ans=YES N=182
34 Correct 4 ms 5120 KB ans=YES N=184
35 Correct 5 ms 5120 KB ans=YES N=188
36 Correct 5 ms 5096 KB ans=YES N=181
37 Correct 5 ms 5120 KB ans=YES N=188
38 Correct 4 ms 5120 KB ans=YES N=191
39 Correct 4 ms 5120 KB ans=YES N=196
40 Correct 4 ms 5120 KB ans=YES N=196
41 Correct 4 ms 5120 KB ans=YES N=196
42 Correct 5 ms 5120 KB ans=YES N=196
43 Correct 5 ms 5120 KB ans=YES N=195
44 Correct 10 ms 6272 KB ans=NO N=1934
45 Correct 12 ms 5632 KB ans=NO N=1965
46 Correct 17 ms 5632 KB ans=YES N=1824
47 Correct 20 ms 5640 KB ans=YES N=1981
48 Correct 16 ms 5632 KB ans=YES N=1814
49 Correct 17 ms 5632 KB ans=YES N=1854
50 Correct 14 ms 5632 KB ans=YES N=1831
51 Correct 19 ms 5632 KB ans=YES N=2000
52 Correct 13 ms 5632 KB ans=YES N=1847
53 Correct 16 ms 5632 KB ans=YES N=1819
54 Correct 14 ms 5632 KB ans=YES N=1986
55 Correct 13 ms 5760 KB ans=YES N=2000
56 Correct 14 ms 5760 KB ans=YES N=1834
57 Correct 12 ms 5760 KB ans=YES N=1860
58 Correct 14 ms 5760 KB ans=YES N=1898
59 Correct 13 ms 5760 KB ans=YES N=1832
60 Correct 13 ms 5760 KB ans=YES N=1929
61 Correct 14 ms 5740 KB ans=YES N=1919
62 Correct 15 ms 5792 KB ans=YES N=1882
63 Correct 13 ms 5888 KB ans=YES N=1922
64 Correct 14 ms 5760 KB ans=YES N=1989
65 Correct 11 ms 5632 KB ans=YES N=1978
66 Correct 12 ms 5632 KB ans=YES N=1867
67 Correct 14 ms 5632 KB ans=YES N=1942
68 Correct 651 ms 24564 KB ans=NO N=66151
69 Correct 612 ms 37496 KB ans=NO N=64333
70 Correct 728 ms 24532 KB ans=YES N=69316
71 Correct 701 ms 23916 KB ans=YES N=66695
72 Correct 629 ms 24564 KB ans=YES N=68436
73 Correct 706 ms 24816 KB ans=YES N=70000
74 Correct 649 ms 24820 KB ans=YES N=68501
75 Correct 673 ms 25460 KB ans=YES N=70000
76 Correct 731 ms 25028 KB ans=YES N=65009
77 Correct 690 ms 25076 KB ans=YES N=67007
78 Correct 870 ms 26224 KB ans=YES N=66357
79 Correct 622 ms 27444 KB ans=YES N=65430
80 Correct 587 ms 26804 KB ans=YES N=65790
81 Correct 629 ms 26352 KB ans=YES N=66020
82 Correct 723 ms 26064 KB ans=YES N=65809
83 Correct 765 ms 25072 KB ans=YES N=65651
84 Correct 763 ms 30576 KB ans=YES N=68040
85 Correct 686 ms 29048 KB ans=YES N=66570
86 Correct 600 ms 24184 KB ans=YES N=65421
87 Correct 615 ms 25328 KB ans=YES N=68351
88 Correct 665 ms 24008 KB ans=YES N=67027
89 Correct 569 ms 22224 KB ans=YES N=68879
90 Correct 564 ms 23920 KB ans=YES N=67256
91 Correct 1656 ms 47564 KB ans=YES N=148315
92 Correct 1404 ms 83704 KB ans=NO N=142745
93 Correct 1010 ms 98248 KB ans=NO N=148443
94 Correct 1778 ms 48640 KB ans=YES N=148328
95 Correct 1749 ms 48684 KB ans=YES N=147855
96 Correct 1727 ms 49392 KB ans=YES N=150000
97 Correct 1747 ms 47720 KB ans=YES N=144725
98 Correct 1686 ms 49160 KB ans=YES N=149445
99 Correct 1664 ms 47852 KB ans=YES N=144455
100 Correct 1656 ms 47548 KB ans=YES N=143487
101 Correct 1709 ms 49028 KB ans=YES N=149688
102 Correct 1452 ms 49904 KB ans=YES N=141481
103 Correct 1601 ms 59296 KB ans=YES N=147430
104 Correct 1722 ms 46584 KB ans=YES N=142247
105 Correct 1598 ms 51176 KB ans=YES N=149941
106 Correct 1465 ms 57068 KB ans=YES N=141635
107 Correct 1604 ms 53612 KB ans=YES N=142896
108 Correct 1565 ms 56796 KB ans=YES N=142069
109 Correct 1541 ms 48492 KB ans=YES N=142378
110 Correct 1618 ms 56552 KB ans=YES N=150000
111 Correct 1721 ms 60648 KB ans=YES N=141452
112 Correct 1341 ms 57832 KB ans=YES N=134453
113 Correct 1197 ms 60904 KB ans=YES N=144172
# 결과 실행 시간 메모리 Grader output
1 Correct 671 ms 24516 KB ans=NO N=66151
2 Correct 553 ms 37368 KB ans=NO N=64333
3 Incorrect 697 ms 24448 KB Contestant's solution is not lexicographically largest at index 69316 (69235 vs 7320)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 6272 KB ans=NO N=1934
2 Correct 12 ms 5632 KB ans=NO N=1965
3 Incorrect 14 ms 5632 KB Contestant's solution is not lexicographically largest at index 1824 (1813 vs 1702)
4 Halted 0 ms 0 KB -