답안 #598893

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
598893 2022-07-19T07:18:19 Z 조영욱(#8459) Building Skyscrapers (CEOI19_skyscrapers) C++17
0 / 100
87 ms 8244 KB
#include <bits/stdc++.h>
using namespace std;

int n,t;
typedef pair<int,int> P;
set<P> s;
map<P,int> mp;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};

int main() {
    scanf("%d %d",&n,&t);
    for(int i=0;i<n;i++) {
        int x,y;
        scanf("%d %d",&x,&y);
        s.insert(P(x,y));
        mp[P(x,y)]=i+1;
    }
    P now=*s.begin();
    s.erase(now);
    priority_queue<P,vector<P>,greater<P>> pq;
    pq.push(now);
    vector<int> ret;
    while (!pq.empty()) {
        P now=pq.top();
        pq.pop();
        ret.push_back(mp[P(now.first,now.second)]);
        for(int i=0;i<4;i++) {
            int x=now.first+dx[i];
            int y=now.second+dy[i];
            if (s.find(P(x,y))!=s.end()) {
                s.erase(P(x,y));
                pq.push(P(x,y));
            }
        }
    }
    if (ret.size()!=n) {
        printf("NO");
        return 0;
    }
    printf("YES\n");
    for(int i=0;i<n;i++) {
        printf("%d\n",ret[i]);
    }
    return 0;
}

Compilation message

skyscrapers.cpp: In function 'int main()':
skyscrapers.cpp:37:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   37 |     if (ret.size()!=n) {
      |         ~~~~~~~~~~^~~
skyscrapers.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf("%d %d",&n,&t);
      |     ~~~~~^~~~~~~~~~~~~~~
skyscrapers.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         scanf("%d %d",&x,&y);
      |         ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB ans=YES N=1
2 Correct 0 ms 212 KB ans=YES N=4
3 Correct 1 ms 212 KB ans=NO N=4
4 Incorrect 0 ms 212 KB Contestant did not find solution
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 1 ms 212 KB ans=NO N=4
4 Incorrect 0 ms 212 KB Contestant did not find solution
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 1 ms 212 KB ans=NO N=4
4 Incorrect 0 ms 212 KB Contestant did not find solution
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 468 KB ans=NO N=1934
2 Correct 1 ms 468 KB ans=NO N=1965
3 Incorrect 2 ms 468 KB Contestant did not find solution
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 Correct 1 ms 212 KB ans=NO N=4
4 Incorrect 0 ms 212 KB Contestant did not find solution
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 87 ms 7892 KB ans=NO N=66151
2 Correct 65 ms 7332 KB ans=NO N=64333
3 Incorrect 85 ms 8244 KB Contestant did not find solution
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 468 KB ans=NO N=1934
2 Correct 1 ms 468 KB ans=NO N=1965
3 Incorrect 2 ms 468 KB Contestant did not find solution
4 Halted 0 ms 0 KB -