답안 #518584

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
518584 2022-01-24T08:02:37 Z Monarchuwu Building Skyscrapers (CEOI19_skyscrapers) C++17
0 / 100
19 ms 1612 KB
#include<iostream>
#include<algorithm>
#include<unordered_set>
#include<vector>
using namespace std;
typedef long long ll;

const int N = 2e5 + 8;
int n, t;
struct Point {
    int x, y, id;
    Point() {}
    bool operator < (const Point &o) const {
        return y < o.y;
    }
} p[N];

int main() {
    cin.tie(NULL)->sync_with_stdio(false);
    cin >> n >> t;
    for (int i = 1; i <= n; ++i)
        cin >> p[i].x >> p[i].y, p[i].id = i;
    sort(p + 1, p + n + 1);

    int i = 1, j;
    unordered_set<int> s1;
    vector<int> ans;

    for (int i = 1, j; i <= n; i = j + 1) {
        if (i != 1 && p[i - 1].y + 1 != p[i].y) {
            cout << "NO\n";
            return 0;
        }

        j = i;
        while (j < n && p[j + 1].y == p[i].y) ++j;

        unordered_set<int> s2;
        for (int k = i; k <= j; ++k) {
            if (i == 1 || s1.count(p[i - 1].x) || s1.count(p[i].x) || s1.count(p[i + 1].x)) {
                s2.insert(p[i].x);
                ans.push_back(p[i].id);
            }
            else {
                cout << "NO\n";
                return 0;
            }
        }

        s1.swap(s2);
    }

    cout << "YES\n";
    for (int x : ans) cout << x << '\n';
}
/**  /\_/\
 *  (= ._.)
 *  / >0  \>1
**/

Compilation message

skyscrapers.cpp: In function 'int main()':
skyscrapers.cpp:25:9: warning: unused variable 'i' [-Wunused-variable]
   25 |     int i = 1, j;
      |         ^
skyscrapers.cpp:25:16: warning: unused variable 'j' [-Wunused-variable]
   25 |     int i = 1, j;
      |                ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB ans=YES N=1
2 Incorrect 1 ms 208 KB Each cell must be removed exactly once
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB ans=YES N=1
2 Incorrect 1 ms 208 KB Each cell must be removed exactly once
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB ans=YES N=1
2 Incorrect 1 ms 208 KB Each cell must be removed exactly once
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 332 KB ans=NO N=1934
2 Correct 1 ms 336 KB ans=NO N=1965
3 Incorrect 1 ms 336 KB Contestant did not find solution
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB ans=YES N=1
2 Incorrect 1 ms 208 KB Each cell must be removed exactly once
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 1548 KB ans=NO N=66151
2 Correct 19 ms 1508 KB ans=NO N=64333
3 Incorrect 14 ms 1612 KB Contestant did not find solution
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 332 KB ans=NO N=1934
2 Correct 1 ms 336 KB ans=NO N=1965
3 Incorrect 1 ms 336 KB Contestant did not find solution
4 Halted 0 ms 0 KB -