QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#93846#5818. Macaronnhuang6850 167ms82516kbC++172.7kb2023-04-03 08:34:492023-04-03 08:34:50

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-03 08:34:50]
  • 评测
  • 测评结果:0
  • 用时:167ms
  • 内存:82516kb
  • [2023-04-03 08:34:49]
  • 提交

answer

/**
 * @author nhuang685
 * @date 2023-04-02 19:42:00
 */
#include <bits/stdc++.h>

using namespace std;

const array<int, 4> dx{-1, 0, 1, 0}, dy{0, 1, 0, -1};

int main() {
  ios::sync_with_stdio(false);

#ifdef LOCAL
  // freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  // freopen("log.txt", "w", stderr);
#else
  cin.tie(nullptr);
#endif

  int n, m;
  cin >> n >> m;
  int r2;
  cin >> r2;
  pair<int, int> s;
  cin >> s.first >> s.second;

  int k;
  cin >> k;
  vector<vector<int>> grid(n + 1, vector<int>(n + 1, (int)1001));
  for (int i = 0; i < k; ++i) {
    int x, y;
    cin >> x >> y;
    // x--;
    // y--;
    grid[x][y] = 0;
  }

  auto bfs = [&](queue<pair<int, int>> &q) {
    while (!q.empty()) {
      auto [x, y] = q.front();
      q.pop();
      for (int d : {1, 3}) {
        int a = x + dx[d], b = y + dy[d];
        if (a > 0 && a <= n && b > 0 && b <= n && grid[a][b] > grid[x][y] + 1) {
          grid[a][b] = grid[x][y] + 1;
          q.push({a, b});
        }
      }
    }
  };

  for (int i = 1; i <= n; ++i) {
    queue<pair<int, int>> q;
    for (int j = 1; j <= n; ++j) {
      if (grid[i][j] == 0) q.push({i, j});
    }
    bfs(q);
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      cout << grid[i][j] << '\t';
    }
    cout << '\n';
  }

  auto sqt = [](int a) {
    int l = 0, r = a;
    while (l < r) {
      int mid = (l + r) / 2;
      if (mid * mid >= a)
        r = mid;
      else
        l = mid + 1;
    }
    return l;
  };

  vector<vector<int>> over(n + 2, vector<int>(n + 2));
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      if (r2 <= grid[i][j] * grid[i][j]) continue;
      int d = sqt(r2 - grid[i][j] * grid[i][j]);
      // i - d + 1, i + d - 1
      over[max(1, i - d + 1)][j] += 1;
      over[min(n + 1, i + d)][j] -= 1;
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      over[i][j] += over[i - 1][j];
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      cout << over[i][j] << '\t';
    }
    cout << '\n';
  }

  vector<vector<bool>> v(n + 1, vector<bool>(n + 1));
  auto dfs = [&](auto &self, int a, int b) -> int {
    v[a][b] = true;
    int ans = 1;
    for (int d = 0; d < 4; ++d) {
      int i = a + dx[d], j = b + dy[d];
      if (i >= 1 && i <= n && j >= 1 && j <= n && i * i >= r2 &&
          (n - i + 1) * (n - i + 1) >= r2 && j * j >= r2 &&
          (n - j + 1) * (n - j + 1) >= r2 && over[i][j] == 0 && !v[i][j])
        ans += self(self, i, j);
    }
    return ans;
  };
  cout << dfs(dfs, s.first, s.second) << '\n';
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 3472kb

input:

11 11
5
9 7
4
1 10
1 11
8 3
8 4

output:

9	8	7	6	5	4	3	2	1	0	0	
1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	
1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	
1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	
1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	
1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	100...

result:

wrong answer 1st lines differ - expected: '37', found: '9	8	7	6	5	4	3	2	1	0	0	'

Test #2:

score: 0
Wrong Answer
time: 140ms
memory: 78712kb

input:

999 999
3000
340 211
25
230 432
513 610
514 610
360 56
360 55
474 319
474 318
687 476
687 477
204 142
205 142
206 142
207 142
244 511
243 511
242 511
241 511
32 652
32 653
32 654
32 655
197 976
539 579
540 579
540 578

output:

1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	...

result:

wrong answer 1st lines differ - expected: '724629', found: '1001	1001	1001	1001	1001	1001	...	1001	1001	1001	1001	1001	1001	'

Test #3:

score: 0
Wrong Answer
time: 160ms
memory: 82516kb

input:

1000 1000
5000
748 173
24
944 654
943 654
944 653
942 654
941 654
941 655
942 655
940 655
939 655
938 655
939 656
938 656
635 128
636 128
634 128
635 127
637 128
633 128
632 128
633 127
631 128
630 128
629 128
628 128

output:

1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	...

result:

wrong answer 1st lines differ - expected: '716645', found: '1001	1001	1001	1001	1001	1001	...	1001	1001	1001	1001	1001	1001	'

Test #4:

score: 0
Wrong Answer
time: 131ms
memory: 25188kb

input:

1000 1000
10000
668 126
30
9 589
39 505
165 527
185 25
211 383
231 699
235 849
291 839
317 955
319 627
355 79
355 117
365 521
447 253
473 721
515 161
517 157
587 465
627 849
641 515
729 893
775 81
783 583
813 1
839 699
869 215
931 365
937 975
941 47
965 249

output:

1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	...

result:

wrong answer 1st lines differ - expected: '192418', found: '1001	1001	1001	1001	1001	1001	...	1001	1001	1001	1001	1001	1001	'

Test #5:

score: 0
Wrong Answer
time: 2ms
memory: 3504kb

input:

50 50
30
36 40
11
50 41
29 16
31 23
48 9
27 22
8 33
9 33
1 40
3 39
27 21
29 30

output:

39	38	37	36	35	34	33	32	31	30	29	28	27	26	25	24	23	22	21	20	19	18	17	16	15	14	13	12	11	10	9	8	7	6	5	4	3	2	1	0	1	2	3	4	5	6	7	8	9	10	
1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	100...

result:

wrong answer 1st lines differ - expected: '1200', found: '39	38	37	36	35	34	33	32	31	30	...4	3	2	1	0	1	2	3	4	5	6	7	8	9	10	'

Test #6:

score: 0
Wrong Answer
time: 4ms
memory: 3636kb

input:

100 100
300
69 24
17
32 34
33 34
31 34
40 55
32 10
98 77
97 77
96 77
81 71
19 69
87 66
88 66
88 67
100 38
100 37
19 89
13 48

output:

1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	...

result:

wrong answer 1st lines differ - expected: '1730', found: '1001	1001	1001	1001	1001	1001	...	1001	1001	1001	1001	1001	1001	'

Test #7:

score: 0
Wrong Answer
time: 126ms
memory: 76752kb

input:

1000 1000
5000
845 228
41
13 132
12 132
13 133
13 131
11 132
12 133
14 131
11 131
908 888
907 888
401 736
350 495
350 494
349 494
348 494
349 493
348 495
350 493
347 495
348 496
351 493
349 496
348 497
351 492
351 491
859 937
295 732
295 733
151 720
152 720
151 721
152 721
151 722
37 291
675 123
676...

output:

1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	...

result:

wrong answer 1st lines differ - expected: '646861', found: '1001	1001	1001	1001	1001	1001	...	1001	1001	1001	1001	1001	1001	'

Test #8:

score: 0
Wrong Answer
time: 128ms
memory: 80704kb

input:

1000 1000
10000
845 168
7949
901 901
901 902
901 903
901 904
901 905
901 906
901 909
901 911
901 912
901 913
901 914
901 915
901 916
901 917
901 918
901 919
901 920
901 921
901 923
901 924
901 925
901 926
901 927
901 928
901 930
901 935
901 936
901 938
901 939
901 940
901 942
901 943
901 945
901 946...

output:

1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	...

result:

wrong answer 1st lines differ - expected: '635255', found: '1001	1001	1001	1001	1001	1001	...	1001	1001	1001	1001	1001	1001	'

Test #9:

score: 0
Wrong Answer
time: 167ms
memory: 65832kb

input:

1000 1000
1
19 587
249999
1 1
1 3
1 5
1 7
1 9
1 11
1 13
1 15
1 17
1 19
1 21
1 23
1 25
1 27
1 29
1 31
1 33
1 35
1 37
1 39
1 41
1 43
1 45
1 47
1 49
1 51
1 53
1 55
1 57
1 59
1 61
1 63
1 65
1 67
1 69
1 71
1 73
1 75
1 77
1 79
1 81
1 83
1 85
1 87
1 89
1 91
1 93
1 95
1 97
1 99
1 101
1 103
1 105
1 107
1 109...

output:

0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	...

result:

wrong answer 1st lines differ - expected: '750001', found: '0	1	0	1	0	1	0	1	0	1	0	1	0	1	0	...	1	0	1	0	1	0	1	0	1	0	1	0	1	0	1	'

Test #10:

score: 0
Wrong Answer
time: 125ms
memory: 23504kb

input:

1000 1000
111012
587 619
0

output:

1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	1001	...

result:

wrong answer 1st lines differ - expected: '111556', found: '1001	1001	1001	1001	1001	1001	...	1001	1001	1001	1001	1001	1001	'