답안 #594823

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
594823 2022-07-13T01:38:34 Z lunchbox 화성 (APIO22_mars) C++17
14 / 100
19 ms 2248 KB
#include <bits/stdc++.h>
using namespace std;

struct dsu {
  vector<int> ds;

  dsu() {}
  dsu(int n) {
    ds.assign(n, -1);
  }
  const int& operator[](int i) {
    return ds[i];
  }
  int find(int i) {
    return ds[i] < 0 ? i : ds[i] = find(ds[i]);
  }
  int size(int i) {
    return -ds[find(i)];
  }
  bool same(int i, int j) {
    return find(i) == find(j);
  }
  bool join(int i, int j) {
    i = find(i), j = find(j);
    if (i == j)
      return false;
    if (ds[i] > ds[j])
      swap(i, j);
    ds[i] += ds[j], ds[j] = i;
    return true;
  }
};

string process(vector<vector<string>> ss, int i, int j, int k, int n) {
  int n_ = (k + 1) * 2 + 1;
  string s(100, '0');
  for (int x1 = 0; x1 < 3; x1++)
    for (int y1 = 0; y1 < 3; y1++)
        for (int x2 = 0; x2 < n_ - 2; x2++)
          for (int y2 = 0; y2 < n_ - 2; y2++)
            s[(x1 + x2) * n_ + (y1 + y2)] = ss[x1][y1][x2 * (n_ - 2) + y2];
  if (k < n - 1)
    return s;
  else {
    dsu ds(n_ * n_);
    int m = 0;
    for (int x = 0; x < n_; x++)
      for (int y = 0; y < n_; y++)
        if (s[x * n_ + y] == '1') {
          if (x > 0 && s[(x - 1) * n_ + y] == '1')
            ds.join(x * n_ + y, (x - 1) * n_ + y);
          if (y > 0 && s[x * n_ + (y - 1)] == '1')
            ds.join(x * n_ + y, x * n_ + (y - 1));
        }
    for (int i = 0; i < n_ * n_; i++)
      if (ds[i] < 0 && s[i] == '1')
        m++;
    string t(100, '0');
    for (int b = 0; b < 10; b++)
      t[b] = '0' + (m >> b & 1);
    return t;
  }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1704 KB Output is correct
2 Correct 8 ms 1768 KB Output is correct
3 Correct 8 ms 1876 KB Output is correct
4 Correct 8 ms 1792 KB Output is correct
5 Correct 6 ms 1944 KB Output is correct
6 Correct 8 ms 2052 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1704 KB Output is correct
2 Correct 8 ms 1768 KB Output is correct
3 Correct 8 ms 1876 KB Output is correct
4 Correct 8 ms 1792 KB Output is correct
5 Correct 6 ms 1944 KB Output is correct
6 Correct 8 ms 2052 KB Output is correct
7 Correct 10 ms 2136 KB Output is correct
8 Correct 16 ms 2140 KB Output is correct
9 Correct 16 ms 1960 KB Output is correct
10 Correct 16 ms 2056 KB Output is correct
11 Correct 19 ms 2248 KB Output is correct
12 Correct 16 ms 2136 KB Output is correct
13 Correct 16 ms 1808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1704 KB Output is correct
2 Correct 8 ms 1768 KB Output is correct
3 Correct 8 ms 1876 KB Output is correct
4 Correct 8 ms 1792 KB Output is correct
5 Correct 6 ms 1944 KB Output is correct
6 Correct 8 ms 2052 KB Output is correct
7 Correct 10 ms 2136 KB Output is correct
8 Correct 16 ms 2140 KB Output is correct
9 Correct 16 ms 1960 KB Output is correct
10 Correct 16 ms 2056 KB Output is correct
11 Correct 19 ms 2248 KB Output is correct
12 Correct 16 ms 2136 KB Output is correct
13 Correct 16 ms 1808 KB Output is correct
14 Runtime error 4 ms 432 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1704 KB Output is correct
2 Correct 8 ms 1768 KB Output is correct
3 Correct 8 ms 1876 KB Output is correct
4 Correct 8 ms 1792 KB Output is correct
5 Correct 6 ms 1944 KB Output is correct
6 Correct 8 ms 2052 KB Output is correct
7 Correct 10 ms 2136 KB Output is correct
8 Correct 16 ms 2140 KB Output is correct
9 Correct 16 ms 1960 KB Output is correct
10 Correct 16 ms 2056 KB Output is correct
11 Correct 19 ms 2248 KB Output is correct
12 Correct 16 ms 2136 KB Output is correct
13 Correct 16 ms 1808 KB Output is correct
14 Runtime error 4 ms 432 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1704 KB Output is correct
2 Correct 8 ms 1768 KB Output is correct
3 Correct 8 ms 1876 KB Output is correct
4 Correct 8 ms 1792 KB Output is correct
5 Correct 6 ms 1944 KB Output is correct
6 Correct 8 ms 2052 KB Output is correct
7 Correct 10 ms 2136 KB Output is correct
8 Correct 16 ms 2140 KB Output is correct
9 Correct 16 ms 1960 KB Output is correct
10 Correct 16 ms 2056 KB Output is correct
11 Correct 19 ms 2248 KB Output is correct
12 Correct 16 ms 2136 KB Output is correct
13 Correct 16 ms 1808 KB Output is correct
14 Runtime error 4 ms 432 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1704 KB Output is correct
2 Correct 8 ms 1768 KB Output is correct
3 Correct 8 ms 1876 KB Output is correct
4 Correct 8 ms 1792 KB Output is correct
5 Correct 6 ms 1944 KB Output is correct
6 Correct 8 ms 2052 KB Output is correct
7 Correct 10 ms 2136 KB Output is correct
8 Correct 16 ms 2140 KB Output is correct
9 Correct 16 ms 1960 KB Output is correct
10 Correct 16 ms 2056 KB Output is correct
11 Correct 19 ms 2248 KB Output is correct
12 Correct 16 ms 2136 KB Output is correct
13 Correct 16 ms 1808 KB Output is correct
14 Runtime error 4 ms 432 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1704 KB Output is correct
2 Correct 8 ms 1768 KB Output is correct
3 Correct 8 ms 1876 KB Output is correct
4 Correct 8 ms 1792 KB Output is correct
5 Correct 6 ms 1944 KB Output is correct
6 Correct 8 ms 2052 KB Output is correct
7 Correct 10 ms 2136 KB Output is correct
8 Correct 16 ms 2140 KB Output is correct
9 Correct 16 ms 1960 KB Output is correct
10 Correct 16 ms 2056 KB Output is correct
11 Correct 19 ms 2248 KB Output is correct
12 Correct 16 ms 2136 KB Output is correct
13 Correct 16 ms 1808 KB Output is correct
14 Runtime error 4 ms 432 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1704 KB Output is correct
2 Correct 8 ms 1768 KB Output is correct
3 Correct 8 ms 1876 KB Output is correct
4 Correct 8 ms 1792 KB Output is correct
5 Correct 6 ms 1944 KB Output is correct
6 Correct 8 ms 2052 KB Output is correct
7 Correct 10 ms 2136 KB Output is correct
8 Correct 16 ms 2140 KB Output is correct
9 Correct 16 ms 1960 KB Output is correct
10 Correct 16 ms 2056 KB Output is correct
11 Correct 19 ms 2248 KB Output is correct
12 Correct 16 ms 2136 KB Output is correct
13 Correct 16 ms 1808 KB Output is correct
14 Runtime error 4 ms 432 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1704 KB Output is correct
2 Correct 8 ms 1768 KB Output is correct
3 Correct 8 ms 1876 KB Output is correct
4 Correct 8 ms 1792 KB Output is correct
5 Correct 6 ms 1944 KB Output is correct
6 Correct 8 ms 2052 KB Output is correct
7 Correct 10 ms 2136 KB Output is correct
8 Correct 16 ms 2140 KB Output is correct
9 Correct 16 ms 1960 KB Output is correct
10 Correct 16 ms 2056 KB Output is correct
11 Correct 19 ms 2248 KB Output is correct
12 Correct 16 ms 2136 KB Output is correct
13 Correct 16 ms 1808 KB Output is correct
14 Runtime error 4 ms 432 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1704 KB Output is correct
2 Correct 8 ms 1768 KB Output is correct
3 Correct 8 ms 1876 KB Output is correct
4 Correct 8 ms 1792 KB Output is correct
5 Correct 6 ms 1944 KB Output is correct
6 Correct 8 ms 2052 KB Output is correct
7 Correct 10 ms 2136 KB Output is correct
8 Correct 16 ms 2140 KB Output is correct
9 Correct 16 ms 1960 KB Output is correct
10 Correct 16 ms 2056 KB Output is correct
11 Correct 19 ms 2248 KB Output is correct
12 Correct 16 ms 2136 KB Output is correct
13 Correct 16 ms 1808 KB Output is correct
14 Runtime error 4 ms 432 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -