답안 #564797

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
564797 2022-05-19T16:22:59 Z AbdullahMW Building Skyscrapers (CEOI19_skyscrapers) C++14
8 / 100
233 ms 18132 KB
#include <bits/stdc++.h>
 
#define all(vec) vec.begin(), vec.end()
#define ll long long
#define db double
#define pb push_back
#define pf push_front
#define newl "\n"
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define f first
#define s second
#define MOD 1000000007
 
using namespace std;
 
#pragma GCC diagnostic ignored "-Wunused-result"
void setIO(string name = "") {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << fixed << setprecision(15);
    if (name.size()) {
        freopen((name+".in").c_str(), "r", stdin);
        freopen((name+".out").c_str(), "w", stdout);
    }
}
 
map <pair <ll, ll>, bool> vis, exist;
vector <pair <ll, ll>> ans;
priority_queue <pair <ll, ll>, vector <pair <ll, ll>>, greater <pair <ll, ll>>> pq;
void bfs(ll ii, ll jj)
{
    pq.push({ii, jj});
    vis[{ii, jj}] = true;
    ans.pb({ii, jj});
    while (pq.size())
    {
        ll x = pq.top().f, y = pq.top().s;
        pq.pop();
        
        for (ll i = x - 1; i <= x + 1; i++)
        {
            for (ll j = y - 1; j <= y + 1; j++)
            {
                if (exist[{i, j}] && !vis[{i, j}])
                {
                    vis[{i, j}] = true;
                    pq.push({i, j});
                    ans.pb({i, j});
                }
            }
        }
        
    }
}
 
int main()
{
    //fast
    //setIO("");
    
    //freopen("filename.in", "r", stdin);
    //freopen("filename.out", "w", stdout);
    
    ll n, t; cin >> n >> t;
    vector <pair <ll, ll>> a(n);
    map <pair <ll, ll>, ll> mp;
    for (ll i = 0; i < n; i++) 
    {
        cin >> a[i].f >> a[i].s;
        mp[a[i]] = i + 1;
        exist[a[i]] = true;
    }
    
    sort(a.begin(), a.end());
    bfs(a[0].f, a[0].s);

    if (ans.size() < n) 
    {
        cout << "NO" << newl;
        return 0;
    }
    
    cout << "YES" << newl;
    for (auto v : ans) cout << mp[v] << newl;
    
    //cout << 1;
 
 
 
    
    
    
}

Compilation message

skyscrapers.cpp: In function 'int main()':
skyscrapers.cpp:76:20: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   76 |     if (ans.size() < n)
      |         ~~~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB ans=YES N=1
2 Correct 1 ms 300 KB ans=YES N=4
3 Correct 1 ms 212 KB ans=NO N=4
4 Correct 1 ms 212 KB ans=YES N=5
5 Correct 1 ms 212 KB ans=YES N=9
6 Correct 1 ms 212 KB ans=YES N=5
7 Correct 1 ms 296 KB ans=NO N=9
8 Correct 1 ms 212 KB ans=NO N=10
9 Correct 1 ms 212 KB ans=YES N=10
10 Correct 1 ms 212 KB ans=YES N=10
11 Correct 1 ms 212 KB ans=YES N=10
12 Correct 1 ms 212 KB ans=YES N=9
13 Correct 1 ms 212 KB ans=YES N=9
14 Correct 1 ms 212 KB ans=YES N=8
15 Correct 1 ms 212 KB ans=YES N=8
16 Correct 1 ms 212 KB ans=NO N=2
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB ans=YES N=1
2 Correct 1 ms 300 KB ans=YES N=4
3 Correct 1 ms 212 KB ans=NO N=4
4 Correct 1 ms 212 KB ans=YES N=5
5 Correct 1 ms 212 KB ans=YES N=9
6 Correct 1 ms 212 KB ans=YES N=5
7 Correct 1 ms 296 KB ans=NO N=9
8 Correct 1 ms 212 KB ans=NO N=10
9 Correct 1 ms 212 KB ans=YES N=10
10 Correct 1 ms 212 KB ans=YES N=10
11 Correct 1 ms 212 KB ans=YES N=10
12 Correct 1 ms 212 KB ans=YES N=9
13 Correct 1 ms 212 KB ans=YES N=9
14 Correct 1 ms 212 KB ans=YES N=8
15 Correct 1 ms 212 KB ans=YES N=8
16 Correct 1 ms 212 KB ans=NO N=2
17 Correct 1 ms 212 KB ans=YES N=17
18 Correct 1 ms 212 KB ans=YES N=25
19 Correct 1 ms 296 KB ans=YES N=100
20 Correct 1 ms 340 KB ans=YES N=185
21 Correct 1 ms 212 KB ans=NO N=174
22 Correct 1 ms 212 KB ans=YES N=90
23 Correct 1 ms 212 KB ans=YES N=63
24 Correct 1 ms 212 KB ans=YES N=87
25 Correct 1 ms 340 KB ans=YES N=183
26 Correct 1 ms 340 KB ans=YES N=188
27 Correct 1 ms 340 KB ans=YES N=183
28 Correct 1 ms 312 KB ans=YES N=189
29 Correct 1 ms 340 KB ans=YES N=200
30 Correct 1 ms 340 KB ans=YES N=190
31 Correct 1 ms 340 KB ans=YES N=187
32 Correct 1 ms 340 KB ans=YES N=187
33 Correct 1 ms 340 KB ans=YES N=182
34 Correct 1 ms 340 KB ans=YES N=184
35 Correct 1 ms 352 KB ans=YES N=188
36 Correct 1 ms 340 KB ans=YES N=181
37 Correct 1 ms 340 KB ans=YES N=188
38 Correct 1 ms 340 KB ans=YES N=191
39 Correct 1 ms 340 KB ans=YES N=196
40 Correct 1 ms 340 KB ans=YES N=196
41 Correct 1 ms 340 KB ans=YES N=196
42 Incorrect 1 ms 340 KB Added cell 196 (16,2) not reachable from infinity
43 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB ans=YES N=1
2 Correct 1 ms 300 KB ans=YES N=4
3 Correct 1 ms 212 KB ans=NO N=4
4 Correct 1 ms 212 KB ans=YES N=5
5 Correct 1 ms 212 KB ans=YES N=9
6 Correct 1 ms 212 KB ans=YES N=5
7 Correct 1 ms 296 KB ans=NO N=9
8 Correct 1 ms 212 KB ans=NO N=10
9 Correct 1 ms 212 KB ans=YES N=10
10 Correct 1 ms 212 KB ans=YES N=10
11 Correct 1 ms 212 KB ans=YES N=10
12 Correct 1 ms 212 KB ans=YES N=9
13 Correct 1 ms 212 KB ans=YES N=9
14 Correct 1 ms 212 KB ans=YES N=8
15 Correct 1 ms 212 KB ans=YES N=8
16 Correct 1 ms 212 KB ans=NO N=2
17 Correct 1 ms 212 KB ans=YES N=17
18 Correct 1 ms 212 KB ans=YES N=25
19 Correct 1 ms 296 KB ans=YES N=100
20 Correct 1 ms 340 KB ans=YES N=185
21 Correct 1 ms 212 KB ans=NO N=174
22 Correct 1 ms 212 KB ans=YES N=90
23 Correct 1 ms 212 KB ans=YES N=63
24 Correct 1 ms 212 KB ans=YES N=87
25 Correct 1 ms 340 KB ans=YES N=183
26 Correct 1 ms 340 KB ans=YES N=188
27 Correct 1 ms 340 KB ans=YES N=183
28 Correct 1 ms 312 KB ans=YES N=189
29 Correct 1 ms 340 KB ans=YES N=200
30 Correct 1 ms 340 KB ans=YES N=190
31 Correct 1 ms 340 KB ans=YES N=187
32 Correct 1 ms 340 KB ans=YES N=187
33 Correct 1 ms 340 KB ans=YES N=182
34 Correct 1 ms 340 KB ans=YES N=184
35 Correct 1 ms 352 KB ans=YES N=188
36 Correct 1 ms 340 KB ans=YES N=181
37 Correct 1 ms 340 KB ans=YES N=188
38 Correct 1 ms 340 KB ans=YES N=191
39 Correct 1 ms 340 KB ans=YES N=196
40 Correct 1 ms 340 KB ans=YES N=196
41 Correct 1 ms 340 KB ans=YES N=196
42 Incorrect 1 ms 340 KB Added cell 196 (16,2) not reachable from infinity
43 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 468 KB ans=NO N=1934
2 Correct 2 ms 596 KB ans=NO N=1965
3 Incorrect 5 ms 724 KB Contestant's solution is not lexicographically largest at index 1824 (1813 vs 1702)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB ans=YES N=1
2 Correct 1 ms 300 KB ans=YES N=4
3 Correct 1 ms 212 KB ans=NO N=4
4 Correct 1 ms 212 KB ans=YES N=5
5 Correct 1 ms 212 KB ans=YES N=9
6 Correct 1 ms 212 KB ans=YES N=5
7 Correct 1 ms 296 KB ans=NO N=9
8 Correct 1 ms 212 KB ans=NO N=10
9 Correct 1 ms 212 KB ans=YES N=10
10 Correct 1 ms 212 KB ans=YES N=10
11 Correct 1 ms 212 KB ans=YES N=10
12 Correct 1 ms 212 KB ans=YES N=9
13 Correct 1 ms 212 KB ans=YES N=9
14 Correct 1 ms 212 KB ans=YES N=8
15 Correct 1 ms 212 KB ans=YES N=8
16 Correct 1 ms 212 KB ans=NO N=2
17 Correct 1 ms 212 KB ans=YES N=17
18 Correct 1 ms 212 KB ans=YES N=25
19 Correct 1 ms 296 KB ans=YES N=100
20 Correct 1 ms 340 KB ans=YES N=185
21 Correct 1 ms 212 KB ans=NO N=174
22 Correct 1 ms 212 KB ans=YES N=90
23 Correct 1 ms 212 KB ans=YES N=63
24 Correct 1 ms 212 KB ans=YES N=87
25 Correct 1 ms 340 KB ans=YES N=183
26 Correct 1 ms 340 KB ans=YES N=188
27 Correct 1 ms 340 KB ans=YES N=183
28 Correct 1 ms 312 KB ans=YES N=189
29 Correct 1 ms 340 KB ans=YES N=200
30 Correct 1 ms 340 KB ans=YES N=190
31 Correct 1 ms 340 KB ans=YES N=187
32 Correct 1 ms 340 KB ans=YES N=187
33 Correct 1 ms 340 KB ans=YES N=182
34 Correct 1 ms 340 KB ans=YES N=184
35 Correct 1 ms 352 KB ans=YES N=188
36 Correct 1 ms 340 KB ans=YES N=181
37 Correct 1 ms 340 KB ans=YES N=188
38 Correct 1 ms 340 KB ans=YES N=191
39 Correct 1 ms 340 KB ans=YES N=196
40 Correct 1 ms 340 KB ans=YES N=196
41 Correct 1 ms 340 KB ans=YES N=196
42 Incorrect 1 ms 340 KB Added cell 196 (16,2) not reachable from infinity
43 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 233 ms 18132 KB ans=NO N=66151
2 Correct 89 ms 9272 KB ans=NO N=64333
3 Incorrect 209 ms 16240 KB Contestant's solution is not lexicographically largest at index 69316 (69235 vs 7320)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 468 KB ans=NO N=1934
2 Correct 2 ms 596 KB ans=NO N=1965
3 Incorrect 5 ms 724 KB Contestant's solution is not lexicographically largest at index 1824 (1813 vs 1702)
4 Halted 0 ms 0 KB -