QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#90045#5162. 种花ChatGPT5 112ms3464kbC++232.6kb2023-03-22 03:04:132023-03-22 03:04:17

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-22 03:04:17]
  • 评测
  • 测评结果:5
  • 用时:112ms
  • 内存:3464kb
  • [2023-03-22 03:04:13]
  • 提交

answer

#include <iostream>
#include <vector>
#include <string>

using namespace std;

const int MOD = 998244353;

int countC(const vector<string> &grid) {
    int n = grid.size();
    int m = grid[0].size();
    int count = 0;

    for (int x1 = 0; x1 < n; ++x1) {
        for (int x2 = x1 + 2; x2 < n; ++x2) {
            for (int y0 = 0; y0 < m; ++y0) {
                for (int y1 = y0 + 1; y1 < m; ++y1) {
                    for (int y2 = y1; y2 < m; ++y2) {
                        bool isValid = true;
                        for (int i = y0; i <= y1; ++i) {
                            if (grid[x1][i] == '1') isValid = false;
                        }
                        for (int i = y0; i <= y2; ++i) {
                            if (grid[x2][i] == '1') isValid = false;
                        }
                        for (int i = x1; i <= x2; ++i) {
                            if (grid[i][y0] == '1') isValid = false;
                        }
                        if (isValid) count++;
                    }
                }
            }
        }
    }

    return count;
}

int countF(const vector<string> &grid) {
    int n = grid.size();
    int m = grid[0].size();
    int count = 0;

    for (int x1 = 0; x1 < n; ++x1) {
        for (int x2 = x1 + 2; x2 < n; ++x2) {
            for (int x3 = x2 + 1; x3 < n; ++x3) {
                for (int y0 = 0; y0 < m; ++y0) {
                    for (int y1 = y0 + 1; y1 < m; ++y1) {
                        for (int y2 = y1; y2 < m; ++y2) {
                            bool isValid = true;
                            for (int i = y0; i <= y1; ++i) {
                                if (grid[x1][i] == '1') isValid = false;
                            }
                            for (int i = y0; i <= y2; ++i) {
                                if (grid[x2][i] == '1') isValid = false;
                            }
                            for (int i = x1; i <= x3; ++i) {
                                if (grid[i][y0] == '1') isValid = false;
                            }
                            if (isValid) count++;
                        }
                    }
                }
            }
        }
    }

    return count;
}

int main() {
    int T, id;
    cin >> T >> id;

    while (T--) {
        int n, m, c, f;
        cin >> n >> m >> c >> f;

        vector<string> grid(n);
        for (int i = 0; i < n; ++i) {
            cin >> grid[i];
        }

        int cntC = countC(grid);
        int cntF = countF(grid);

        cout << cntC * c % MOD << ' ' << cntF * f % MOD << endl;
    }

    return 0;
}

详细

Test #1:

score: 0
Time Limit Exceeded

input:

1 1
998 1000 0 0
0000100000100001000000000000011100000000010100100010000001100000000100011010000000011010001000100010000010001000011110010000000000010100000000001000000010000000100001000000101000010010010000000010010010000010001000010000000010000100001001001111010000000000010000000000100001111010011...

output:


result:


Test #2:

score: 2
Accepted
time: 2ms
memory: 3400kb

input:

3 2
3 2 1 1
00
00
00
3 2 1 1
00
01
00
3 2 1 1
00
00
01

output:

1 0
1 0
0 0

result:

ok 3 lines

Test #3:

score: 3
Accepted
time: 2ms
memory: 3464kb

input:

5 3
4 2 1 1
00
00
00
00
4 2 1 1
00
01
00
00
4 2 1 1
00
00
01
00
4 2 1 1
00
00
00
01
4 2 1 1
00
00
00
10

output:

3 1
2 1
2 0
1 1
1 0

result:

ok 5 lines

Test #4:

score: 0
Time Limit Exceeded

input:

5 4
997 2 1 1
10
00
00
00
00
00
00
00
00
00
00
10
00
00
10
00
00
00
00
00
00
00
00
00
00
01
00
00
00
00
00
00
00
00
10
00
00
00
01
11
00
00
00
00
00
00
00
00
10
00
00
00
00
00
10
01
00
00
00
00
00
00
00
01
01
00
00
00
10
00
00
00
00
00
00
00
00
00
10
00
00
00
00
00
00
00
00
00
10
00
00
00
00
00
00
0...

output:


result:


Test #5:

score: 0
Time Limit Exceeded

input:

5 5
999 998 1 1
00100100100100101100100100100100100100100100110100110100101100100100110100100100100101100100110100100100101100101100101100100100100100100100101100101100110100100100110100100100100100100110100101110100101110100100110100100100100101100100100100100100101100100100100100100100100100100100...

output:


result:


Test #6:

score: 0
Time Limit Exceeded

input:

5 6
995 1000 1 1
0000000000100101000000000000000000001010000100000000000000000100100000000001000000000000000000100000000101000000000000000000000000000000000000000000000001000000000000000100100000001000000000010000000000000000000000000100000000100000001011000100000000110000000000000000000000000000000...

output:


result:


Test #7:

score: 0
Wrong Answer
time: 3ms
memory: 3412kb

input:

5 7
10 10 1 1
0000000000
0000000100
0000100000
0000000000
0000000000
0000000000
0000000001
0000000000
0010000001
0000000000
9 10 1 1
1000000000
0000100000
0000010100
0001000001
0000000000
1001000001
0111010011
0000000100
0100001000
9 10 1 1
1100000001
0101100010
0010010000
0111010110
1001000110
1110...

output:

3547 7775
257 282
8 10
28 16
5 0

result:

wrong answer 1st lines differ - expected: '5890 12768', found: '3547 7775'

Test #8:

score: 0
Wrong Answer
time: 112ms
memory: 3388kb

input:

5 8
20 18 1 1
010010000010000000
000000000010000110
000000101000000000
000000000000001000
000000000000000000
000000010000000000
010000000010100000
000100000100000001
000000000000001010
000000000100000000
000000100000000001
000001000000100000
000000000100001010
100000000000000000
000000000000000100
0...

output:

19632 73774
6807 24174
251 230
100 72
43 40

result:

wrong answer 1st lines differ - expected: '32999 126558', found: '19632 73774'

Test #9:

score: 0
Time Limit Exceeded

input:

5 9
28 29 1 1
01000000000001000000000000100
00001000010000000000010000001
00000000000000000000000000001
00000100000000100001100100100
00001110100010100011000000000
00000000000000010000100010010
00001000000000000000000000000
00000000000000000010000000000
01000000000010000001001000010
0000100000001010...

output:

63699 291411
6633 14105

result:


Test #10:

score: 0
Time Limit Exceeded

input:

5 10
48 50 1 1
01001000001000001000000000001000010000000000000000
00000000000000100000100101000000000000000001000000
00001000000100000100000000110000000000000000000000
00000000000000000000000000000001000100000000001001
00100000000000000000000100010000000010000000000100
001000000000000100000000101000...

output:


result:


Test #11:

score: 0
Time Limit Exceeded

input:

5 11
95 90 1 1
001100000100000011000000000000000100000000000001000000000000000100000010000000000000000000
000000000000000000000000000000100000000000000000000100000000000000000000100000000010000000
000000000100000000011000000010001000000000000000000001100000010000000000100001000010000000
000000000000...

output:


result:


Test #12:

score: 0
Time Limit Exceeded

input:

5 12
187 184 1 1
0000000010101000000010000000000000100001000000000000000001000000010000000000000100100000000100000000010000000000000000100000000000010000010000000000000010000001000000100000000101000000
00000000000000000000000000000000000000010000000100000100000000000000000000000000000001010000000010...

output:


result:


Test #13:

score: 0
Time Limit Exceeded

input:

5 13
271 300 1 1
0000000100000010000000100000000110000000000100000001001000100100000000000000100001000100000001001000000000000000000000001000000000000000010100000000000000000000000100000000010000000000000000000000000001001000000000010000000000010000000001000000000000000000000010000000000010000000000...

output:


result:


Test #14:

score: 0
Time Limit Exceeded

input:

5 14
500 476 1 1
0000000000000000001110000000010001000000000000000010000000000100000000000000100000000000001000000001000000000000100000001000001001101000000001000000000101000000000010000001100100000100000010100000000000000100100000000000000000001011000000000000011000000000000000000000000000010100001...

output:


result:


Test #15:

score: 0
Time Limit Exceeded

input:

5 15
995 999 1 0
0100000000000000000010000000000000000001000000000000000000000110000100000000000000000000000100000000000000000000001000000000000100000000100000000010000000010010000000000010000100100110000010000000000000000100000100000000000000001000010100000000000000000000000000010000000001000000000...

output:


result:


Test #16:

score: 0
Time Limit Exceeded

input:

5 16
1000 998 1 1
010001000000000101000000100101000000000000000000100000000000000000000100000110010010000000100000000100000000000000000001000000000001000000010000000010000100000011000000000000000000010000000000000100000100000001000000010000000000000000000000000000000000000000000000000111001000000000...

output:


result: