답안 #1089027

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1089027 2024-09-15T19:06:17 Z LilPluton Building Skyscrapers (CEOI19_skyscrapers) C++14
0 / 100
25 ms 5072 KB
#include <bits/stdc++.h>
using namespace std;
#define int ll 
#define ll long long
const int inf = 1e9 + 7;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
const int sz = 2e5 + 5;


bool isadj(pair<int,int>& a, pair<int,int>& b){
    int x1 = a.first;
    int x2 = b.first;
    int y1 = a.second;
    int y2 = b.second;
    if(x1 == x2){
        return abs(y1 - y2) < 2;
    }
    if(y1 == y2){
        return abs(x1 - x2) < 2;
    }
    int sum = abs(x1 - x2) + abs(y1 - y2);
    return sum <= 2;
}

signed main(){
    int n, t;
    cin >> n >> t;
    vector<pair<int,int>> a(n);
    vector<pair<pair<int,int>, int>>v;
    for(int i = 0; i < n; ++i){
        cin >> a[i].first >> a[i].second;
        v.push_back({{a[i].first, a[i].second}, i + 1});
    }
    sort(begin(v), end(v));
    bool ok = false;
    for(int i = 1; i < n; ++i){
        if(!isadj(v[i].first, v[i - 1].first)){
            ok = true;
        }
    }
    if(ok){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
        for(int i = 0; i < n; ++i){
            cout << v[i].second << endl;
        }
    }
    
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB ans=YES N=1
2 Correct 0 ms 348 KB ans=YES N=4
3 Correct 0 ms 348 KB ans=NO N=4
4 Incorrect 1 ms 344 KB Contestant did not find solution
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB ans=YES N=1
2 Correct 0 ms 348 KB ans=YES N=4
3 Correct 0 ms 348 KB ans=NO N=4
4 Incorrect 1 ms 344 KB Contestant did not find solution
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB ans=YES N=1
2 Correct 0 ms 348 KB ans=YES N=4
3 Correct 0 ms 348 KB ans=NO N=4
4 Incorrect 1 ms 344 KB Contestant did not find solution
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 600 KB ans=NO N=1934
2 Correct 1 ms 348 KB ans=NO N=1965
3 Incorrect 2 ms 348 KB Contestant did not find solution
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB ans=YES N=1
2 Correct 0 ms 348 KB ans=YES N=4
3 Correct 0 ms 348 KB ans=NO N=4
4 Incorrect 1 ms 344 KB Contestant did not find solution
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 5072 KB ans=NO N=66151
2 Correct 23 ms 3536 KB ans=NO N=64333
3 Incorrect 25 ms 5068 KB Contestant did not find solution
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 600 KB ans=NO N=1934
2 Correct 1 ms 348 KB ans=NO N=1965
3 Incorrect 2 ms 348 KB Contestant did not find solution
4 Halted 0 ms 0 KB -