QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#343466#6189. Full Clue Problemucup-team1198#AC ✓1ms3832kbC++201.7kb2024-03-02 16:49:162024-03-02 16:49:16

Judging History

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

  • [2024-03-02 16:49:16]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3832kb
  • [2024-03-02 16:49:16]
  • 提交

answer

#include <map>
#include <set>
#include <array>
#include <cmath>
#include <deque>
#include <bitset>
#include <random>
#include <string>
#include <vector>
#include <cassert>
#include <complex>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>

using namespace std;

const int MAXN = 30;
int a[MAXN][MAXN];

void col(int i) {
    for (int x = 0; x < 3; ++x) {
        for (int y = 0; y < 3; ++y) {
            if (x + y == 4) continue;
            a[i + x][i + y] = 1;
        }
    }
}

vector<int> dx = {0, 1, 0, -1}, dy = {1, 0, -1, 0};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int n;
    cin >> n;
    for (int i = 0; i < n; i += 2) {
        col(i);
    }

    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            int cnt = 0;
            for (int t = 0; t < 4; ++t) {
                int i1 = i + dx[t], j1 = j + dy[t];
                if (i1 >= 1 && i1 <= n && j1 >= 1 && j1 <= n && a[i1][j1] != a[i][j]) ++cnt; 
                if ((i1 < 1 || i1 > n || j1 < 1 || j1 > n) && a[i][j]) ++cnt;
            }
            cout << cnt << " ";
        }
        cout << "\n";
    }
    cout << "\n";
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            cout << a[i][j] << " ";
            a[i][j] = 0;
        }
        cout << "\n";
    }
    cout << "\n";

    col(1);
    a[1][1] = 0;
    for (int i = 3; i < n; i += 2) {
        col(i);
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            cout << a[i][j] << " ";
            a[i][j] = 0;
        }
        cout << "\n";
    }

    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3532kb

input:

5

output:

2 2 2 1 0 
2 0 1 2 1 
2 1 0 1 2 
1 2 1 0 2 
0 1 2 2 2 

1 1 0 0 0 
1 1 1 1 0 
0 1 1 1 0 
0 1 1 1 1 
0 0 0 1 1 

0 1 1 0 0 
1 1 1 0 0 
1 1 1 1 1 
0 0 1 1 1 
0 0 1 1 0 

result:

ok ok

Test #2:

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

input:

2

output:

2 3 
3 2 

1 1 
1 0 

0 1 
1 1 

result:

ok ok

Test #3:

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

input:

3

output:

2 2 2 
2 0 2 
2 2 2 

1 1 0 
1 1 1 
0 1 1 

0 1 1 
1 1 1 
1 1 0 

result:

ok ok

Test #4:

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

input:

4

output:

2 2 2 1 
2 0 1 2 
2 1 0 2 
1 2 2 2 

1 1 0 0 
1 1 1 1 
0 1 1 1 
0 1 1 0 

0 1 1 0 
1 1 1 0 
1 1 1 1 
0 0 1 1 

result:

ok ok

Test #5:

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

input:

10

output:

2 2 2 1 0 0 0 0 0 0 
2 0 1 2 1 0 0 0 0 0 
2 1 0 1 2 1 0 0 0 0 
1 2 1 0 1 2 1 0 0 0 
0 1 2 1 0 1 2 1 0 0 
0 0 1 2 1 0 1 2 1 0 
0 0 0 1 2 1 0 1 2 1 
0 0 0 0 1 2 1 0 1 2 
0 0 0 0 0 1 2 1 0 2 
0 0 0 0 0 0 1 2 2 2 

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

result:

ok ok

Test #6:

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

input:

19

output:

2 2 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
2 0 1 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
2 1 0 1 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 
1 2 1 0 1 2 1 0 0 0 0 0 0 0 0 0 0 0 0 
0 1 2 1 0 1 2 1 0 0 0 0 0 0 0 0 0 0 0 
0 0 1 2 1 0 1 2 1 0 0 0 0 0 0 0 0 0 0 
0 0 0 1 2 1 0 1 2 1 0 0 0 0 0 0 0 0 0 
0 0 0 0 1 2 1 0 1 2 1 0 0 0...

result:

ok ok

Test #7:

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

input:

20

output:

2 2 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
2 0 1 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
2 1 0 1 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
1 2 1 0 1 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 1 2 1 0 1 2 1 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 1 2 1 0 1 2 1 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 1 2 1 0 1 2 1 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 1 2 1...

result:

ok ok