Submission #533196

# Submission time Handle Problem Language Result Execution time Memory
533196 2022-03-05T06:22:27 Z wenqi Building Skyscrapers (CEOI19_skyscrapers) C++17
0 / 100
72 ms 6524 KB
// trans rights

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#define M 1000000069

int N, T;
int X[150069];
int Y[150069];
unordered_map<ll, int> P;

int main(int argc, const char *argv[])
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> N >> T;
    priority_queue<int> pq;
    for (int i = 1; i <= N; i++)
    {
        int x, y;
        cin >> x >> y;
        X[i] = x;
        Y[i] = y;

        if (i == 1)
        {
            pq.push(-i);
        }else{
            P[(ll) x * M + y] = i;
        }
    }
    vector<int> R;
    while (not pq.empty())
    {
        int i = -pq.top();
        pq.pop();

        R.push_back(i);

        for (int x = -1; x <= 1; x++)
        {
            for (int y = -1; y <= 1; y++)
            {
                ll idx = (ll) (X[i] + x) * M + (Y[i] + y);
                if (P[idx])
                {
                    pq.push(-P[idx]);
                    P[idx] = 0;
                }
            }
        }
    }
    if (R.size() != N)
    {
        cout << "NO\n";
    }else{
        cout << "YES\n";

        for (int a : R)
            cout << a << '\n';
    }
    return 0;
}

Compilation message

skyscrapers.cpp: In function 'int main(int, const char**)':
skyscrapers.cpp:56:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   56 |     if (R.size() != N)
      |         ~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB ans=YES N=1
2 Correct 1 ms 204 KB ans=YES N=4
3 Correct 1 ms 316 KB ans=NO N=4
4 Correct 1 ms 204 KB ans=YES N=5
5 Correct 1 ms 208 KB ans=YES N=9
6 Correct 1 ms 208 KB ans=YES N=5
7 Correct 1 ms 324 KB ans=NO N=9
8 Correct 1 ms 328 KB ans=NO N=10
9 Correct 1 ms 312 KB ans=YES N=10
10 Incorrect 1 ms 208 KB Added cell 8 (2,0) not reachable from infinity
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB ans=YES N=1
2 Correct 1 ms 204 KB ans=YES N=4
3 Correct 1 ms 316 KB ans=NO N=4
4 Correct 1 ms 204 KB ans=YES N=5
5 Correct 1 ms 208 KB ans=YES N=9
6 Correct 1 ms 208 KB ans=YES N=5
7 Correct 1 ms 324 KB ans=NO N=9
8 Correct 1 ms 328 KB ans=NO N=10
9 Correct 1 ms 312 KB ans=YES N=10
10 Incorrect 1 ms 208 KB Added cell 8 (2,0) not reachable from infinity
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB ans=YES N=1
2 Correct 1 ms 204 KB ans=YES N=4
3 Correct 1 ms 316 KB ans=NO N=4
4 Correct 1 ms 204 KB ans=YES N=5
5 Correct 1 ms 208 KB ans=YES N=9
6 Correct 1 ms 208 KB ans=YES N=5
7 Correct 1 ms 324 KB ans=NO N=9
8 Correct 1 ms 328 KB ans=NO N=10
9 Correct 1 ms 312 KB ans=YES N=10
10 Incorrect 1 ms 208 KB Added cell 8 (2,0) not reachable from infinity
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 464 KB ans=NO N=1934
2 Correct 2 ms 380 KB ans=NO N=1965
3 Incorrect 2 ms 460 KB Added cell 1824 (370,234) not reachable from infinity
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB ans=YES N=1
2 Correct 1 ms 204 KB ans=YES N=4
3 Correct 1 ms 316 KB ans=NO N=4
4 Correct 1 ms 204 KB ans=YES N=5
5 Correct 1 ms 208 KB ans=YES N=9
6 Correct 1 ms 208 KB ans=YES N=5
7 Correct 1 ms 324 KB ans=NO N=9
8 Correct 1 ms 328 KB ans=NO N=10
9 Correct 1 ms 312 KB ans=YES N=10
10 Incorrect 1 ms 208 KB Added cell 8 (2,0) not reachable from infinity
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 72 ms 6524 KB ans=NO N=66151
2 Correct 22 ms 4048 KB ans=NO N=64333
3 Incorrect 56 ms 5464 KB Added cell 69316 (-22,-94) not reachable from infinity
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 464 KB ans=NO N=1934
2 Correct 2 ms 380 KB ans=NO N=1965
3 Incorrect 2 ms 460 KB Added cell 1824 (370,234) not reachable from infinity
4 Halted 0 ms 0 KB -