답안 #598891

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
598891 2022-07-19T07:16:54 Z 조영욱(#8459) Building Skyscrapers (CEOI19_skyscrapers) C++17
0 / 100
85 ms 8200 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);
    queue<P> q;
    q.push(now);
    vector<int> ret;
    while (!q.empty()) {
        P now=q.front();
        q.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));
                q.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 1 ms 212 KB ans=YES N=4
3 Correct 1 ms 256 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 1 ms 212 KB ans=YES N=4
3 Correct 1 ms 256 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 1 ms 212 KB ans=YES N=4
3 Correct 1 ms 256 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 1 ms 468 KB ans=NO N=1934
2 Correct 1 ms 468 KB ans=NO N=1965
3 Incorrect 2 ms 504 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 1 ms 212 KB ans=YES N=4
3 Correct 1 ms 256 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 85 ms 7812 KB ans=NO N=66151
2 Correct 52 ms 7272 KB ans=NO N=64333
3 Incorrect 80 ms 8200 KB Contestant did not find solution
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB ans=NO N=1934
2 Correct 1 ms 468 KB ans=NO N=1965
3 Incorrect 2 ms 504 KB Contestant did not find solution
4 Halted 0 ms 0 KB -