답안 #564790

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
564790 2022-05-19T16:14:32 Z AbdullahMW Building Skyscrapers (CEOI19_skyscrapers) C++14
0 / 100
194 ms 18120 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>> pq;
void bfs(ll i, ll j)
{
    pq.push({i, j});
    vis[{i, j}] = true;
    ans.pb({i, j});
    while (pq.size())
    {
        ll x = pq.top().f, y = pq.top().s;
        pq.pop();
        
        if (exist[{x + 1, y}] && !vis[{x + 1, y}]) 
        {
            pq.push({x + 1, y});
            vis[{x + 1, y}] = true;
            ans.pb({x + 1, y});
        }
        if (exist[{x - 1, y}] && !vis[{x - 1, y}]) 
        {
            pq.push({x - 1, y});
            vis[{x - 1, y}] = true;
            ans.pb({x - 1, y});
        }
        if (exist[{x, y + 1}] && !vis[{x, y + 1}]) 
        {
            pq.push({x, y + 1});
            vis[{x, y + 1}] = true;
            ans.pb({x, y + 1});
        }
        if (exist[{x, y - 1}] && !vis[{x, y - 1}]) 
        {
            pq.push({x, y - 1});
            vis[{x, y - 1}] = true;
            ans.pb({x, y - 1});
        }
        if (exist[{x + 1, y + 1}] && !vis[{x + 1, y + 1}]) 
        {
            pq.push({x + 1, y + 1});
            vis[{x + 1, y + 1}] = true;
            ans.pb({x + 1, y + 1});
        }
        if (exist[{x + 1, y - 1}] && !vis[{x + 1, y - 1}]) 
        {
            pq.push({x + 1, y - 1});
            vis[{x + 1, y - 1}] = true;
            ans.pb({x + 1, y - 1});
        }
        if (exist[{x - 1, y + 1}] && !vis[{x - 1, y + 1}]) 
        {
            pq.push({x - 1, y + 1});
            vis[{x - 1, y + 1}] = true;
            ans.pb({x - 1, y + 1});
        }
        if (exist[{x - 1, y - 1}] && !vis[{x - 1, y - 1}]) 
        {
            pq.push({x - 1, y - 1});
            vis[{x - 1, y - 1}] = true;
            ans.pb({x - 1, y - 1});
        }
        
    }
}
 
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.rbegin(), a.rend());
    bfs(a[0].f, a[0].s);

    if (ans.size() < n) 
    {
        cout << ans.size() << 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:112: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]
  112 |     if (ans.size() < n)
      |         ~~~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB ans=YES N=1
2 Correct 0 ms 212 KB ans=YES N=4
3 Incorrect 0 ms 212 KB YES or NO expected, but 1 found
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB ans=YES N=1
2 Correct 0 ms 212 KB ans=YES N=4
3 Incorrect 0 ms 212 KB YES or NO expected, but 1 found
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB ans=YES N=1
2 Correct 0 ms 212 KB ans=YES N=4
3 Incorrect 0 ms 212 KB YES or NO expected, but 1 found
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 468 KB YES or NO expected, but 1 found
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB ans=YES N=1
2 Correct 0 ms 212 KB ans=YES N=4
3 Incorrect 0 ms 212 KB YES or NO expected, but 1 found
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 194 ms 18120 KB YES or NO expected, but 66093 found
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 468 KB YES or NO expected, but 1 found
2 Halted 0 ms 0 KB -