답안 #658440

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
658440 2022-11-13T08:25:03 Z mychecksedad Building Skyscrapers (CEOI19_skyscrapers) C++17
0 / 100
220 ms 14228 KB
/* Author : Mychecksdead */
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef long double ld;
#define MOD1 (1000000000+7)
#define MOD (998244353)
#define PI 3.1415926535
#define pb push_back
#define setp() cout << setprecision(15)
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " is " << x << '\n';
const int N = 1e6+100, M = 1e5+10, F = 2147483646, K = 20;

int n, t, b[8][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};
map<pair<int, int>, int> m, visited;
pair<int, int> a[N];
void solve(){
    cin >> n >> t;
    for(int i = 0; i < n; ++i){
        cin >> a[i].first >> a[i].second;
        m[a[i]] = i;
    }
    queue<pair<int, int>> q[3];
    int k = 0;
    visited[a[0]] = 1;
    q[k].push(a[0]);
    vector<int> ans;
    while(!q[0].empty() || !q[1].empty() || !q[2].empty()){
        if(q[k].empty()) (k+=1)%=3;
        auto v = q[k].front(); q[k].pop();
        ans.pb(m[v]);
        for(int i = 0; i < 8; ++i){
            int x = v.first + b[i][0];
            int y = v.second + b[i][1];
            if(!visited[{x, y}] && m[{x, y}] > 0){
                q[(k + (i > 3) + 1) % 3].push({x, y});
                visited[{x, y}] = 1;
            }
        }
    }
    if(ans.size() == n){
        cout << "YES\n";
        for(int k: ans) cout << k + 1 << '\n';
    }else cout << "NO";
}





int main(){
    cin.tie(0); ios::sync_with_stdio(0);
    int T = 1, aa;
    // cin >> T;aa=T;
    while(T--){
        // cout << "Case #" << aa-T << ": ";
        solve();
        cout << '\n';
    }
    return 0;
 
}

Compilation message

skyscrapers.cpp: In function 'void solve()':
skyscrapers.cpp:44:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   44 |     if(ans.size() == n){
      |        ~~~~~~~~~~~^~~~
skyscrapers.cpp: In function 'int main()':
skyscrapers.cpp:56:16: warning: unused variable 'aa' [-Wunused-variable]
   56 |     int T = 1, aa;
      |                ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB ans=YES N=1
2 Correct 0 ms 212 KB ans=YES N=4
3 Correct 0 ms 332 KB ans=NO N=4
4 Runtime error 1 ms 400 KB Execution killed with signal 11
5 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 Correct 0 ms 332 KB ans=NO N=4
4 Runtime error 1 ms 400 KB Execution killed with signal 11
5 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 Correct 0 ms 332 KB ans=NO N=4
4 Runtime error 1 ms 400 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB ans=NO N=1934
2 Runtime error 2 ms 724 KB Execution killed with signal 11
3 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 Correct 0 ms 332 KB ans=NO N=4
4 Runtime error 1 ms 400 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 220 ms 14228 KB ans=NO N=66151
2 Runtime error 39 ms 9548 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB ans=NO N=1934
2 Runtime error 2 ms 724 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -