답안 #660310

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
660310 2022-11-21T15:08:15 Z 600Mihnea Building Skyscrapers (CEOI19_skyscrapers) C++17
8 / 100
121 ms 6560 KB
bool home = 0;
#include <bits/stdc++.h>

using namespace std;

struct T
{
  int x;
  int y;
};

bool operator < (T a, T b)
{
  if (a.x != b.x)
  {
    return a.x < b.x;
  }
  return a.y < b.y;
}

const int N = 150000 + 7;
int n;
int task;
T points[N];
bool vis[N];
map<T, int> w;

int main()
{
  if (home == 0)
  {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  }
  else
  {
    freopen ("input.txt", "r", stdin);
  }

  cin >> n >> task;
  assert(task == 1 || task == 2);

  for (int i = 1; i <= n; i++)
  {
    cin >> points[i].x >> points[i].y;
    w[points[i]] = i;
  }
  vector<int> ord;
  int start = 1;
  queue<int> q;
  q.push(start);
  vis[start] = 1;
  while (!q.empty())
  {
    int a = q.front();
    ord.push_back(a);
    q.pop();
    for (int dx = -1; dx <= +1; dx++)
    {
      for (int dy = -1; dy <= +1; dy++)
      {
        T nw = {points[a].x + dx, points[a].y + dy};
        if (w.count(nw))
        {
          int j = w[nw];
          if (vis[j] == 0)
          {
            vis[j] = 1;
            q.push(j);
          }
        }
      }
    }
  }
  if ((int) ord.size() != n)
  {
    cout << "NO\n";
    return 0;
  }

  cout << "YES\n";
  for (auto &v : ord)
  {
    cout << v << "\n";
  }

  return 0;
}

Compilation message

skyscrapers.cpp: In function 'int main()':
skyscrapers.cpp:36:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |     freopen ("input.txt", "r", stdin);
      |     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB ans=YES N=1
2 Correct 1 ms 212 KB ans=YES N=4
3 Correct 1 ms 212 KB ans=NO N=4
4 Correct 1 ms 328 KB ans=YES N=5
5 Correct 1 ms 328 KB ans=YES N=9
6 Correct 1 ms 212 KB ans=YES N=5
7 Correct 0 ms 212 KB ans=NO N=9
8 Correct 1 ms 332 KB ans=NO N=10
9 Correct 0 ms 340 KB ans=YES N=10
10 Correct 1 ms 332 KB ans=YES N=10
11 Correct 1 ms 212 KB ans=YES N=10
12 Correct 1 ms 212 KB ans=YES N=9
13 Correct 1 ms 212 KB ans=YES N=9
14 Correct 1 ms 212 KB ans=YES N=8
15 Correct 1 ms 340 KB ans=YES N=8
16 Correct 1 ms 212 KB ans=NO N=2
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB ans=YES N=1
2 Correct 1 ms 212 KB ans=YES N=4
3 Correct 1 ms 212 KB ans=NO N=4
4 Correct 1 ms 328 KB ans=YES N=5
5 Correct 1 ms 328 KB ans=YES N=9
6 Correct 1 ms 212 KB ans=YES N=5
7 Correct 0 ms 212 KB ans=NO N=9
8 Correct 1 ms 332 KB ans=NO N=10
9 Correct 0 ms 340 KB ans=YES N=10
10 Correct 1 ms 332 KB ans=YES N=10
11 Correct 1 ms 212 KB ans=YES N=10
12 Correct 1 ms 212 KB ans=YES N=9
13 Correct 1 ms 212 KB ans=YES N=9
14 Correct 1 ms 212 KB ans=YES N=8
15 Correct 1 ms 340 KB ans=YES N=8
16 Correct 1 ms 212 KB ans=NO N=2
17 Correct 0 ms 212 KB ans=YES N=17
18 Correct 0 ms 340 KB ans=YES N=25
19 Correct 1 ms 328 KB ans=YES N=100
20 Correct 1 ms 340 KB ans=YES N=185
21 Correct 1 ms 340 KB ans=NO N=174
22 Correct 1 ms 332 KB ans=YES N=90
23 Correct 1 ms 340 KB ans=YES N=63
24 Correct 1 ms 212 KB ans=YES N=87
25 Correct 1 ms 340 KB ans=YES N=183
26 Correct 1 ms 340 KB ans=YES N=188
27 Incorrect 1 ms 332 KB Added cell 102 (-529426737,-391881217) not reachable from infinity
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB ans=YES N=1
2 Correct 1 ms 212 KB ans=YES N=4
3 Correct 1 ms 212 KB ans=NO N=4
4 Correct 1 ms 328 KB ans=YES N=5
5 Correct 1 ms 328 KB ans=YES N=9
6 Correct 1 ms 212 KB ans=YES N=5
7 Correct 0 ms 212 KB ans=NO N=9
8 Correct 1 ms 332 KB ans=NO N=10
9 Correct 0 ms 340 KB ans=YES N=10
10 Correct 1 ms 332 KB ans=YES N=10
11 Correct 1 ms 212 KB ans=YES N=10
12 Correct 1 ms 212 KB ans=YES N=9
13 Correct 1 ms 212 KB ans=YES N=9
14 Correct 1 ms 212 KB ans=YES N=8
15 Correct 1 ms 340 KB ans=YES N=8
16 Correct 1 ms 212 KB ans=NO N=2
17 Correct 0 ms 212 KB ans=YES N=17
18 Correct 0 ms 340 KB ans=YES N=25
19 Correct 1 ms 328 KB ans=YES N=100
20 Correct 1 ms 340 KB ans=YES N=185
21 Correct 1 ms 340 KB ans=NO N=174
22 Correct 1 ms 332 KB ans=YES N=90
23 Correct 1 ms 340 KB ans=YES N=63
24 Correct 1 ms 212 KB ans=YES N=87
25 Correct 1 ms 340 KB ans=YES N=183
26 Correct 1 ms 340 KB ans=YES N=188
27 Incorrect 1 ms 332 KB Added cell 102 (-529426737,-391881217) not reachable from infinity
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 488 KB ans=NO N=1934
2 Correct 1 ms 468 KB ans=NO N=1965
3 Incorrect 2 ms 468 KB Contestant's solution is not lexicographically largest at index 1824 (1813 vs 1049)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB ans=YES N=1
2 Correct 1 ms 212 KB ans=YES N=4
3 Correct 1 ms 212 KB ans=NO N=4
4 Correct 1 ms 328 KB ans=YES N=5
5 Correct 1 ms 328 KB ans=YES N=9
6 Correct 1 ms 212 KB ans=YES N=5
7 Correct 0 ms 212 KB ans=NO N=9
8 Correct 1 ms 332 KB ans=NO N=10
9 Correct 0 ms 340 KB ans=YES N=10
10 Correct 1 ms 332 KB ans=YES N=10
11 Correct 1 ms 212 KB ans=YES N=10
12 Correct 1 ms 212 KB ans=YES N=9
13 Correct 1 ms 212 KB ans=YES N=9
14 Correct 1 ms 212 KB ans=YES N=8
15 Correct 1 ms 340 KB ans=YES N=8
16 Correct 1 ms 212 KB ans=NO N=2
17 Correct 0 ms 212 KB ans=YES N=17
18 Correct 0 ms 340 KB ans=YES N=25
19 Correct 1 ms 328 KB ans=YES N=100
20 Correct 1 ms 340 KB ans=YES N=185
21 Correct 1 ms 340 KB ans=NO N=174
22 Correct 1 ms 332 KB ans=YES N=90
23 Correct 1 ms 340 KB ans=YES N=63
24 Correct 1 ms 212 KB ans=YES N=87
25 Correct 1 ms 340 KB ans=YES N=183
26 Correct 1 ms 340 KB ans=YES N=188
27 Incorrect 1 ms 332 KB Added cell 102 (-529426737,-391881217) not reachable from infinity
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 120 ms 6088 KB ans=NO N=66151
2 Correct 38 ms 5324 KB ans=NO N=64333
3 Incorrect 121 ms 6560 KB Contestant's solution is not lexicographically largest at index 69316 (69235 vs 7320)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 488 KB ans=NO N=1934
2 Correct 1 ms 468 KB ans=NO N=1965
3 Incorrect 2 ms 468 KB Contestant's solution is not lexicographically largest at index 1824 (1813 vs 1049)
4 Halted 0 ms 0 KB -