답안 #985839

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
985839 2024-05-19T04:45:15 Z duckindog Building Skyscrapers (CEOI19_skyscrapers) C++17
8 / 100
55 ms 11772 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 150'000 + 10,
					dx[8] = {-1, 0, 1, -1, 1, 1, 0, -1},
					dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
int n, type;

struct Point { 
	int r, c, idx;
	bool operator > (const auto& rhs) { 
		return make_pair(r, c) > make_pair(rhs.r, rhs.c); 
	}
	friend ostream& operator << (ostream& os, const auto& rhs) { 
		return os << rhs.r << " " << rhs.c << " " << rhs.idx;
	}
} p[N];

unordered_map<int, unordered_map<int, int>> rvs;
bool mk[N];

vector<int> answer;
void dfs(int idx) { 
	int r = p[idx].r, c = p[idx].c;
	answer.push_back(idx);
	for (int i = 0; i < 8; ++i) { 
		int nR = r + dx[i], nC = c + dy[i],
				nxt = rvs[nR][nC];
		if (!nxt || mk[nxt]) continue;
		mk[nxt] = true;
		dfs(nxt);
	}
}

int32_t main() { 
	cin.tie(0)->sync_with_stdio(0);

	cin >> n >> type;
	for (int i = 1; i <= n; ++i) {
		int r, c; cin >> r >> c;
		p[i] = {r, c, i};	
		rvs[r][c] = i;
	}
	Point st = p[1];
	for (int i = 1; i <= n; ++i) if (st > p[i]) st = p[i];

	mk[st.idx] = true;
	dfs(st.idx);
	
	if (answer.size() != n)	{ cout << "No\n"; return 0; };
	cout << "YES\n";
	for (const auto& x : answer) cout << x << "\n";
}

Compilation message

skyscrapers.cpp:12:25: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   12 |  bool operator > (const auto& rhs) {
      |                         ^~~~
skyscrapers.cpp:15:50: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   15 |  friend ostream& operator << (ostream& os, const auto& rhs) {
      |                                                  ^~~~
skyscrapers.cpp: In function 'int32_t main()':
skyscrapers.cpp:51:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   51 |  if (answer.size() != n) { cout << "No\n"; return 0; };
      |      ~~~~~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB ans=YES N=1
2 Correct 0 ms 348 KB ans=YES N=4
3 Correct 0 ms 348 KB ans=NO N=4
4 Correct 0 ms 348 KB ans=YES N=5
5 Correct 0 ms 348 KB ans=YES N=9
6 Correct 0 ms 348 KB ans=YES N=5
7 Correct 0 ms 348 KB ans=NO N=9
8 Correct 0 ms 388 KB ans=NO N=10
9 Correct 1 ms 348 KB ans=YES N=10
10 Correct 0 ms 348 KB ans=YES N=10
11 Correct 1 ms 348 KB ans=YES N=10
12 Correct 0 ms 348 KB ans=YES N=9
13 Correct 0 ms 348 KB ans=YES N=9
14 Correct 0 ms 348 KB ans=YES N=8
15 Correct 1 ms 348 KB ans=YES N=8
16 Correct 0 ms 348 KB ans=NO N=2
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB ans=YES N=1
2 Correct 0 ms 348 KB ans=YES N=4
3 Correct 0 ms 348 KB ans=NO N=4
4 Correct 0 ms 348 KB ans=YES N=5
5 Correct 0 ms 348 KB ans=YES N=9
6 Correct 0 ms 348 KB ans=YES N=5
7 Correct 0 ms 348 KB ans=NO N=9
8 Correct 0 ms 388 KB ans=NO N=10
9 Correct 1 ms 348 KB ans=YES N=10
10 Correct 0 ms 348 KB ans=YES N=10
11 Correct 1 ms 348 KB ans=YES N=10
12 Correct 0 ms 348 KB ans=YES N=9
13 Correct 0 ms 348 KB ans=YES N=9
14 Correct 0 ms 348 KB ans=YES N=8
15 Correct 1 ms 348 KB ans=YES N=8
16 Correct 0 ms 348 KB ans=NO N=2
17 Incorrect 0 ms 348 KB Added cell 16 (1,2) not reachable from infinity
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB ans=YES N=1
2 Correct 0 ms 348 KB ans=YES N=4
3 Correct 0 ms 348 KB ans=NO N=4
4 Correct 0 ms 348 KB ans=YES N=5
5 Correct 0 ms 348 KB ans=YES N=9
6 Correct 0 ms 348 KB ans=YES N=5
7 Correct 0 ms 348 KB ans=NO N=9
8 Correct 0 ms 388 KB ans=NO N=10
9 Correct 1 ms 348 KB ans=YES N=10
10 Correct 0 ms 348 KB ans=YES N=10
11 Correct 1 ms 348 KB ans=YES N=10
12 Correct 0 ms 348 KB ans=YES N=9
13 Correct 0 ms 348 KB ans=YES N=9
14 Correct 0 ms 348 KB ans=YES N=8
15 Correct 1 ms 348 KB ans=YES N=8
16 Correct 0 ms 348 KB ans=NO N=2
17 Incorrect 0 ms 348 KB Added cell 16 (1,2) not reachable from infinity
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 860 KB ans=NO N=1934
2 Correct 1 ms 592 KB ans=NO N=1965
3 Incorrect 1 ms 604 KB Contestant's solution is not lexicographically largest at index 1824 (1813 vs 437)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB ans=YES N=1
2 Correct 0 ms 348 KB ans=YES N=4
3 Correct 0 ms 348 KB ans=NO N=4
4 Correct 0 ms 348 KB ans=YES N=5
5 Correct 0 ms 348 KB ans=YES N=9
6 Correct 0 ms 348 KB ans=YES N=5
7 Correct 0 ms 348 KB ans=NO N=9
8 Correct 0 ms 388 KB ans=NO N=10
9 Correct 1 ms 348 KB ans=YES N=10
10 Correct 0 ms 348 KB ans=YES N=10
11 Correct 1 ms 348 KB ans=YES N=10
12 Correct 0 ms 348 KB ans=YES N=9
13 Correct 0 ms 348 KB ans=YES N=9
14 Correct 0 ms 348 KB ans=YES N=8
15 Correct 1 ms 348 KB ans=YES N=8
16 Correct 0 ms 348 KB ans=NO N=2
17 Incorrect 0 ms 348 KB Added cell 16 (1,2) not reachable from infinity
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 55 ms 11772 KB ans=NO N=66151
2 Correct 21 ms 4028 KB ans=NO N=64333
3 Incorrect 46 ms 11580 KB Added cell 68036 (-3,10) not reachable from infinity
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 860 KB ans=NO N=1934
2 Correct 1 ms 592 KB ans=NO N=1965
3 Incorrect 1 ms 604 KB Contestant's solution is not lexicographically largest at index 1824 (1813 vs 437)
4 Halted 0 ms 0 KB -