QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#661482#8041. Life is Hard and Undecidable, but...LuckyblockAC ✓0ms3884kbC++203.8kb2024-10-20 16:27:042024-10-20 16:27:09

Judging History

This is the latest submission verdict.

  • [2024-10-20 16:27:09]
  • Judged
  • Verdict: AC
  • Time: 0ms
  • Memory: 3884kb
  • [2024-10-20 16:27:04]
  • Submitted

answer

//
/*
By:Luckyblock
*/
#include <bits/stdc++.h>
#define LL long long
//=============================================================
bool yes[310][310], temp[310][310];
//=============================================================
void solve(int n_, int k_, int r_) {
  std::vector<int> ansx, ansy;
  int ex = 100, ey = 5;
  if (r_ == 0) {
    ansx.push_back(ex), ansy.push_back(ey);
    ansx.push_back(ex), ansy.push_back(ey - 1);
    ansx.push_back(ex + 1), ansy.push_back(ey);
    ansx.push_back(ex + 1), ansy.push_back(ey - 2);
    ansx.push_back(ex + 2), ansy.push_back(ey);


  } else if (r_ == 1) {
    ansx.push_back(ex), ansy.push_back(ey - 1);
    ansx.push_back(ex + 1), ansy.push_back(ey);
    ansx.push_back(ex + 1), ansy.push_back(ey - 1);
    ansx.push_back(ex + 2), ansy.push_back(ey);
    ansx.push_back(ex + 2), ansy.push_back(ey - 2);


  } else if (r_ == 2) {
    ansx.push_back(ex + 1), ansy.push_back(ey);
    ansx.push_back(ex + 1), ansy.push_back(ey - 1);
    ansx.push_back(ex + 1), ansy.push_back(ey - 2);
    ansx.push_back(ex + 2), ansy.push_back(ey);
    ansx.push_back(ex + 3), ansy.push_back(ey - 1);


  } else {
    ansx.push_back(ex + 1), ansy.push_back(ey - 1);
    ansx.push_back(ex + 1), ansy.push_back(ey - 2);
    ansx.push_back(ex + 2), ansy.push_back(ey);
    ansx.push_back(ex + 2), ansy.push_back(ey - 1);
    ansx.push_back(ex + 3), ansy.push_back(ey - 2);


  }

  ex -= k_, ey += k_;
  ansx.push_back(ex - 1), ansy.push_back(ey + 2);
  ansx.push_back(ex - 1), ansy.push_back(ey + 3);
  ansx.push_back(ex - 2), ansy.push_back(ey + 2);
  ansx.push_back(ex - 2), ansy.push_back(ey + 3);

  std::cout << ansx.size() << "\n";
  for (int i = 0, sz = ansx.size(); i < sz; ++ i) {
    std::cout << ansx[i] << " " << ansy[i] << "\n";
  }

  // for (int i = 0, sz = ansx.size(); i < sz; ++ i) {
  //   yes[ansx[i]][ansy[i]] = 1;
  // }

  // for (int i = 1; i < n_; ++ i) {
  //   for (int x = 1; x <= 300; ++ x) {
  //     for (int y = 1; y <= 300; ++ y) {
  //       temp[x][y] = 0;
  //     }
  //   }
  //   for (int x = 1; x <= 300; ++ x) {
  //     for (int y = 1; y <= 300; ++ y) {
  //       int c = 0;
  //       if (x == 99 && y == 6) {
  //         std::cout << "?";
  //       }

  //       for (int dx = -1; dx <= 1; ++ dx) {
  //         for (int dy = -1; dy <= 1; ++ dy) {
  //           if (dx == 0 && dy == 0) continue;
  //           if (yes[x + dx][y + dy]) ++ c;
  //         }
  //       }
  //       if (c == 3) temp[x][y] = 1;
  //       else if (yes[x][y] && c == 2) temp[x][y] = 1;
  //       else temp[x][y] = 0;
  //     }
  //   }

  //   int cnt = 0;
  //   for (int x = 1; x <= 300; ++ x) {
  //     for (int y = 1; y <= 300; ++ y) {
  //       yes[x][y] = temp[x][y];
  //       if (yes[x][y]) {
  //         std::cout << x << " " << y << " alive!\n";
  //         ++ cnt;
  //       }
  //     }
  //   }
  //   std::cout << "=======================\n\n\n";
  //   if (!cnt) {
  //     std::cout << "dead previously!";
  //     return ;
  //   }
  // }
  // for (int x = 1; x <= 300; ++ x) {
  //   for (int y = 1; y <= 300; ++ y) {
  //     if (yes[x][y]) {
  //       std::cout << x << " " << y << " not dead!\n";
  //       // return ;
  //     }
  //   }
  // }
}
//=============================================================
int main() {
  // freopen("1.txt", "r", stdin);
  std::ios::sync_with_stdio(0), std::cin.tie(0);
  int n; std::cin >> n;
  if (n == 1) {
    std::cout << "1\n1 1\n";
    return 0;
  } else if (n == 2) {
    std::cout << "3\n2 2\n3 2\n4 1\n";
    return 0;
  } else if (n == 3) {
    std::cout << "5\n2 1\n1 2\n1 3\n3 2\n3 3\n";
    return 0;
  }
  int k = (n - 4) / 4, r = (n - 4) % 4;
  solve(n, k, r); 
  return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3584kb

input:

1

output:

1
1 1

result:

ok n=1

Test #2:

score: 0
Accepted
time: 0ms
memory: 3656kb

input:

2

output:

3
2 2
3 2
4 1

result:

ok n=3

Test #3:

score: 0
Accepted
time: 0ms
memory: 3652kb

input:

3

output:

5
2 1
1 2
1 3
3 2
3 3

result:

ok n=5

Test #4:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

4

output:

9
100 5
100 4
101 5
101 3
102 5
99 7
99 8
98 7
98 8

result:

ok n=9

Test #5:

score: 0
Accepted
time: 0ms
memory: 3688kb

input:

5

output:

9
100 4
101 5
101 4
102 5
102 3
99 7
99 8
98 7
98 8

result:

ok n=9

Test #6:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

6

output:

9
101 5
101 4
101 3
102 5
103 4
99 7
99 8
98 7
98 8

result:

ok n=9

Test #7:

score: 0
Accepted
time: 0ms
memory: 3644kb

input:

7

output:

9
101 4
101 3
102 5
102 4
103 3
99 7
99 8
98 7
98 8

result:

ok n=9

Test #8:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

8

output:

9
100 5
100 4
101 5
101 3
102 5
98 8
98 9
97 8
97 9

result:

ok n=9

Test #9:

score: 0
Accepted
time: 0ms
memory: 3812kb

input:

9

output:

9
100 4
101 5
101 4
102 5
102 3
98 8
98 9
97 8
97 9

result:

ok n=9

Test #10:

score: 0
Accepted
time: 0ms
memory: 3624kb

input:

10

output:

9
101 5
101 4
101 3
102 5
103 4
98 8
98 9
97 8
97 9

result:

ok n=9

Test #11:

score: 0
Accepted
time: 0ms
memory: 3540kb

input:

13

output:

9
100 4
101 5
101 4
102 5
102 3
97 9
97 10
96 9
96 10

result:

ok n=9

Test #12:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

17

output:

9
100 4
101 5
101 4
102 5
102 3
96 10
96 11
95 10
95 11

result:

ok n=9

Test #13:

score: 0
Accepted
time: 0ms
memory: 3880kb

input:

23

output:

9
101 4
101 3
102 5
102 4
103 3
95 11
95 12
94 11
94 12

result:

ok n=9

Test #14:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

29

output:

9
100 4
101 5
101 4
102 5
102 3
93 13
93 14
92 13
92 14

result:

ok n=9

Test #15:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

31

output:

9
101 4
101 3
102 5
102 4
103 3
93 13
93 14
92 13
92 14

result:

ok n=9

Test #16:

score: 0
Accepted
time: 0ms
memory: 3580kb

input:

37

output:

9
100 4
101 5
101 4
102 5
102 3
91 15
91 16
90 15
90 16

result:

ok n=9

Test #17:

score: 0
Accepted
time: 0ms
memory: 3648kb

input:

41

output:

9
100 4
101 5
101 4
102 5
102 3
90 16
90 17
89 16
89 17

result:

ok n=9

Test #18:

score: 0
Accepted
time: 0ms
memory: 3880kb

input:

43

output:

9
101 4
101 3
102 5
102 4
103 3
90 16
90 17
89 16
89 17

result:

ok n=9

Test #19:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

100

output:

9
100 5
100 4
101 5
101 3
102 5
75 31
75 32
74 31
74 32

result:

ok n=9

Test #20:

score: 0
Accepted
time: 0ms
memory: 3884kb

input:

85

output:

9
100 4
101 5
101 4
102 5
102 3
79 27
79 28
78 27
78 28

result:

ok n=9

Test #21:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

97

output:

9
100 4
101 5
101 4
102 5
102 3
76 30
76 31
75 30
75 31

result:

ok n=9

Test #22:

score: 0
Accepted
time: 0ms
memory: 3880kb

input:

98

output:

9
101 5
101 4
101 3
102 5
103 4
76 30
76 31
75 30
75 31

result:

ok n=9

Test #23:

score: 0
Accepted
time: 0ms
memory: 3884kb

input:

99

output:

9
101 4
101 3
102 5
102 4
103 3
76 30
76 31
75 30
75 31

result:

ok n=9

Extra Test:

score: 0
Extra Test Passed