QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#354232#7857. (-1,1)-Sumpleteucup-team1198#AC ✓151ms83452kbC++202.5kb2024-03-15 00:18:432024-03-15 00:18:44

Judging History

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

  • [2024-03-15 00:18:44]
  • 评测
  • 测评结果:AC
  • 用时:151ms
  • 内存:83452kb
  • [2024-03-15 00:18:43]
  • 提交

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 = 4e3 + 100;
int r[MAXN], c[MAXN];
string ans[MAXN];


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int n;
    cin >> n;
    vector<array<int, 2>> minus;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < n; ++j) {
            if (s[j] == '-') {
                minus.push_back({i, j});
                ++r[i];
                ++c[j];
            }
        }
        ans[i].resize(n, '0');
    }

    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        r[i] += x;
    }
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        c[i] += x;
    }

    int sumr = 0, sumc = 0;
    for (int i = 0; i < n; ++i) {
        if (r[i] < 0 || r[i] > n || c[i] < 0 || c[i] > n) {
            cout << "No\n";
            return 0;
        }
        sumr += r[i];
        sumc += c[i];
    }
    if (sumr != sumc) {
        cout << "No\n";
        return 0;
    }

    vector<int> ordr(n);
    vector<int> ordc(n);
    iota(ordr.begin(), ordr.end(), 0);
    ordc = ordr;

    sort(ordr.begin(), ordr.end(), [](int i, int j) { return r[i] > r[j]; });
    sort(ordc.begin(), ordc.end(), [](int i, int j) { return c[i] > c[j]; });

    for (int i : ordr) {
        /// cerr << i << endl;
        for (int j = 0; j < r[i]; ++j) {
            ans[i][ordc[j]] = '1';
            --c[ordc[j]];
            if (c[ordc[j]] < 0) {
                cout << "No\n";
                return 0;
            }
        }
        if (r[i] != n && r[i] != 0 && c[ordc[r[i]]] > c[ordc[r[i] - 1]]) {
            int L = r[i] - 1;
            int R = r[i];
            while (R + 1 < n && c[ordc[R + 1]] == c[ordc[R]]) ++R;
            while (L - 1 >= 0 && c[ordc[L - 1]] == c[ordc[L]]) --L;
            rotate(ordc.begin() + L, ordc.begin() + r[i], ordc.begin() + R + 1);
        }
    }

    cout << "Yes\n";
    for (auto elem : minus) {
        ans[elem[0]][elem[1]] = '0' + '1' - ans[elem[0]][elem[1]];
    }

    for (int i = 0; i < n; ++i) {
        cout << ans[i] << "\n";
    }

    return 0;
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

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

input:

3
+-+
-++
+-+
1 1 1
1 -1 3

output:

Yes
111
001
001

result:

ok n=3

Test #2:

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

input:

3
---
-++
+++
-2 -1 0
-2 -1 0

output:

Yes
110
100
000

result:

ok n=3

Test #3:

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

input:

3
+-+
-++
++-
1 0 2
2 2 -1

output:

No

result:

ok n=3

Test #4:

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

input:

1
-
-1
1

output:

No

result:

ok n=1

Test #5:

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

input:

1
-
0
0

output:

Yes
0

result:

ok n=1

Test #6:

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

input:

20
+-------+-----+++-++
-+-++++----++-++-++-
-+++--+---+--+-++---
-+++-+--+----++---+-
+++-+-++++++-+-+---+
-++-----+----++++++-
+-++--+++++-++-+----
+-+----+---+-+++--+-
+++++-+++++----+--+-
------++++---+--++--
++++--------++++--+-
-+-+-++++-+-++-++--+
---+-++---+-++-++---
+-++++-++----+-+++--
+-+...

output:

Yes
11110011001000101010
10101111010110100010
11110111111110011101
11110001111110001001
01101000100101010100
00011010101001001101
00110111000100111111
01000100110001110110
10000101110011100011
01111000010001010010
00001011110111101101
11010010010100111101
11110111011011011100
11001110101001001101
11...

result:

ok n=20

Test #7:

score: 0
Accepted
time: 1ms
memory: 4092kb

input:

100
++++-+-+--++++++-+--+--++-+-+--+++++-+++---+-+-+-++-+-+++-------+-++--+-++--+--+++++-++-+---+--+--++
-++--++-+-++++-+---++-+-+-+-+-+-+-+-+--+-+--+--+++---+--+-----+-----+-++-++-+-++++++--+-+++-+++-++++
--+---++-++--++-+++-------+--+-++------+-----+--+----++++++++-+--+++++--++--+-+-+++---+--+++-+...

output:

Yes
1110010111111110110011000010100011111010000001110010101110100000001001001100100001110110100110010011
0110011110100101001010101001101011111001010010010100010001000010000010000110101111110110110011101111
0000101101100100111000100000000100100101000001001010010101101100011111001000001011100010111111...

result:

ok n=100

Test #8:

score: 0
Accepted
time: 3ms
memory: 4540kb

input:

500
--+-+-+-++-----+++--+-+++-+---+-+-------+++--++++++-+--++--+-+-++++-++++--++--+---++--++----++--+---++-++--+-----+-+---++-++++-+++++++---++-++--+-++++-+----++-+++-+++---+--+++-+--++-++--+++++++-+++--+---+---+-+---++-+-+--+-+++-++-----+++-++-+++-+-++--++++++-+-++-+++---++-+++-++----+--+++----++++...

output:

Yes
01010111001111001011001001110101011110110001101010010100010011111001001111000101110001001011001111110010011011111100111011000010000001111100011011010010111100100010011110010001011001001100010001010010111011001110100101111011001011111101010110001010111100100001001011111001000101111101100011110000...

result:

ok n=500

Test #9:

score: 0
Accepted
time: 134ms
memory: 81832kb

input:

4000
-++-+-+-+--+-++++---+-++------++---+-+++--+++--+++++++---+-++-+++++++----+---+++-++--++---+-++--+----+---+--++-+-+-+-----+-+---++-++--+---+++-++++-+-----++--++-++---++-+--+++-+--+--+-+-++-+++--++---+++-+-+---+++-++-+-++-+-+++---+++---+-+--++---+-+---+--+++--+----+-+--++---+-----+-+--+----+-+++-...

output:

Yes
10111101110001010001010010000100010011010011101100000000001111000011100001100001000110001111110001111111001000010111011110110111111010100011001010101101001100000111111000010110110111101100001101111010111101101101100010011001011010100101001111110011011001011010011011101110100100100010010110110110...

result:

ok n=4000

Test #10:

score: 0
Accepted
time: 137ms
memory: 81796kb

input:

4000
+---+--++-+--++-+-++--+++--++--+++-+-+-+--++++++-++-+-+++-+---++++-+-+++----++-+---++--++--+++-----++---++-+--++++----++--++--+-+-++--+--+++++-+---+++-+++--++++-++-+++++++----+++-----+--++-+++-++-++-+++-+--++++++-+--++--+-+---++--------+-+--++----+-++-+-++---+--++--+-+--+-+++-+--+--++++-++----+...

output:

Yes
11010010010111111000110011001100101110101000010000000001100001000111100011111000101100000010101111100100101101011111010110110101011011011000001111100000111101100001100100011110011111100000100010110101000111001011000111100101100011110111010101011101100101000110110000010110100111111101000100010011...

result:

ok n=4000

Test #11:

score: 0
Accepted
time: 144ms
memory: 82800kb

input:

4000
-+--+------+--+++-++-----++--+-++-++-++-+-+-++++++--++--+-++-+-+++---++-+-+++++-++++++-+-++-++-++-+-++---+-+-------++-+++-++-+-++++-++-+-+-----+----+--+----++++-------++-+--+++----+++++++-+--+-+---+-+++++-+-----++-------++++--+-+-++---++++-++++-++-+++-+-++---+--+---+-++++++--++---+-++++++-+-+--...

output:

Yes
00101110001010101011100100100101001111001010111101111001111000101000111110101110100101111100100111001100010100101110001010110000101010101110010001111011000011101010100111100111011011011100010101000001111100011100000010101010111010010010111110110010111010101101010100111111100101010101110111101110...

result:

ok n=4000

Test #12:

score: 0
Accepted
time: 151ms
memory: 83452kb

input:

4000
+-+-----++++-----++++-+-++-+----+++---++--+---+++-+-++------+-+-++++----+-++++--+-++----+-+---+--+-----+-++--++-+++---+---+++---++-+++---++++---++----+++--+---+---+++-++-+-+-+--+++--++----++-+------+++-++-++--+--+++---+-------++++-+-++--++-+--+------+++++---+---++-++++-+++-++++-+---++-++++----+...

output:

Yes
10001010100101001000001100101011000000001010001101100100100101001001001000000011000100101001000000101000110011001011111100100000011000011110111010010100010011110011000100110011001011000101011000001100110100111001000101001000111001001111000000101111111010111100100001101001011010101111011101111111...

result:

ok n=4000

Test #13:

score: 0
Accepted
time: 135ms
memory: 83224kb

input:

4000
-+++---+-------+-++++-+++-++-+--++----++++++---+---++-++++-+++-++++-+---+--+++-----+-+--++-+--+-++++--+--++-+---+++++++++-+++++++-+++--+-+---++-+-++----+-++--++-++++++++++++++-+++-++-+++-++-++---+---+++-+-+++++++--+-+++-++-+-----+++-++--+++------+++--+++---+--+----++-+--+-+---+--+---+-+-+--++++...

output:

Yes
01101000111010110010001110110100011111101011000011111011000110001011000000010000100101001100110110010100010010101010011110010111101000000000000010110001010100110011101111011100110010011100111110010111111001000111100000111111111110010101100010101010111111111001011001101011010000100010101110110111...

result:

ok n=4000

Test #14:

score: 0
Accepted
time: 105ms
memory: 81616kb

input:

4000
+--+++++--++--+-+++-++-+-+-+-+--++------++++---+++-+-+--+------++-+--++-+-+++-----+-+++++-+------++++-++++-+--+------++--+++++-+-+--+-+++++++++++++++-+--+-+-+---+-+-+++++-++--+-+---++-++--+--+-+++-+-+++++-+--++-+----+++-++-++++-+---+--+-++-++-+-+-+---++-++-+-+----++-++++-----------+++--++++-++-...

output:

Yes
01100000110111010001001010101011001101110000111000101011011111100101101001000101110100001101111110000100001011011111100110100111101101000000000000000001101010111010100000100110101110010011011010011010000010110011111100010000000101110110100100101010111001001000111101100001111111111100010000010010...

result:

ok n=4000

Test #15:

score: 0
Accepted
time: 132ms
memory: 81508kb

input:

4000
---++-++-+-+----++-++++-----------+++--++++-++-++--+-+--+--+-+-++++--++-++--+++++--++--+-+----+-+---++-+++-+--+-++++++++-++---++++-+--+-+++---+-+--+--+-+--+--++++++-+---++++++-++++----+-+-+-++--+---+--+-+++--++++++-+++-+---+--+-----------++-+++--+++++++--++-+++++--+++-+-+++++++++--+---+++--+-+-...

output:

Yes
00011011010100000001111010000000001111011100110100110110100101011110011011001111100110010100001010001101110100110111111101100011010100100110001001110000100110111111010001110110111110001010111100101010010111001110110111010001001100000000001101010011110110011111111001110101011111110010011110010100...

result:

ok n=4000

Test #16:

score: 0
Accepted
time: 121ms
memory: 81688kb

input:

4000
++-+-------+--++-++-++--++-+++++-++++--+-----++-+--+---++++--+-----++++++---+--+---+------+++-+-----+-+++--+++-+-+-+++-----++---+-+---+-+++++-+--+-++--++-+-----++-+-+---+++-+----++++---++--+-+-++-++-+--++---+++------++-+-++++--+--++-++-+++-++-+--++----++---+-+++-+-+++-++-+--++-++++--++-+-+-+-+-...

output:

Yes
10011000000100110011110001111011011110010000011110010001111001000001111110000001000100000010101000001011100111010101110000011000101000101111101001011001101000001101010001110101001111001110010110101101001110011100000011011111100100110110111011010011000001000100110101110110100110110100110101010110...

result:

ok n=4000

Test #17:

score: 0
Accepted
time: 115ms
memory: 82844kb

input:

3999
-+-+++---+-----++-++-+++--++-++-----+-++-+---+++-+++-+-+--+++++-++-+++-+---+-----+-++++-+--++-+++--+-++++--+-+-+-+-+----++----+--+---+--+--++-+++--++-+-++--++------+-+--++++--++-+--+----++---+-+---+++++--++-+-++-+++--++---++++-+-+--+-+++++-+-+--+---+---+-+--++++---+-++++-+--++------+++-+++-+-+-...

output:

Yes
10100010101111100110100011001001011101001011100010001011100000010010001011101111101000010110010001101000011010101010110100011101101110110110010101100101001100111111010110000110010110111100101010111000001100101001000110010100001010110100100101011011101110101100001110100001011001111110001000001010...

result:

ok n=3999

Test #18:

score: 0
Accepted
time: 123ms
memory: 81976kb

input:

3998
--------+++--++-++++--+-+-++---+--++---++-+-++--+----++++---+-++-+-++++++++-+-+++---++++++-+--+-------+--+----++--+--+-+--+++---++-+++---+++-++-+++--++-+----+---+--+-++++--++++-++-+-+---+---+-++----+++++++++++--++--+++++-+++++++-+-+--+-+---+++-++-+++++-+-+-+-+++-+-++-+-+--+-+----+++-+-+--++-+--...

output:

Yes
11111110011000110001110000010110001000110100111101110110000111000100001000101000001010101100001111110001001001011100100000110010101001101011001101110110011110100001100110010111010010100001011111011000100010110001100000001110011001011010111001111011000000010110101001010001000110100000100110000010...

result:

ok n=3998

Test #19:

score: 0
Accepted
time: 96ms
memory: 82296kb

input:

4000
++-+-------+--++-++-++--++-+++++-++++--+-----++-+--+---++++--+-----++++++---+--+---+------+++-+-----+-+++--+++-+-+-+++-----++---+-+---+-+++++-+--+-++--++-+-----++-+-+---+++-+----++++---++--+-+-++-++-+--++---+++------++-+-++++--+--++-++-+++-++-+--++----++---+-+++-+-+++-++-+--++-++++--++-+-+-+-+-...

output:

No

result:

ok n=4000

Test #20:

score: 0
Accepted
time: 111ms
memory: 82976kb

input:

3999
-+-+++---+-----++-++-+++--++-++-----+-++-+---+++-+++-+-+--+++++-++-+++-+---+-----+-++++-+--++-+++--+-++++--+-+-+-+-+----++----+--+---+--+--++-+++--++-+-++--++------+-+--++++--++-+--+----++---+-+---+++++--++-+-++-+++--++---++++-+-+--+-+++++-+-+--+---+---+-+--++++---+-++++-+--++------+++-+++-+-+-...

output:

No

result:

ok n=3999

Test #21:

score: 0
Accepted
time: 99ms
memory: 82344kb

input:

3998
--------+++--++-++++--+-+-++---+--++---++-+-++--+----++++---+-++-+-++++++++-+-+++---++++++-+--+-------+--+----++--+--+-+--+++---++-+++---+++-++-+++--++-+----+---+--+-++++--++++-++-+-+---+---+-++----+++++++++++--++--+++++-+++++++-+-+--+-+---+++-++-+++++-+-+-+-+++-+-++-+-+--+-+----+++-+-+--++-+--...

output:

No

result:

ok n=3998

Test #22:

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

input:

2
+-
--
0 -1
-1 2

output:

No

result:

ok n=2

Test #23:

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

input:

20
--+--------+---++-++
--+++-+----+--++-+++
-+-+-++++---+-+---++
+++-++--++-++-++--++
+---+----+-+++-++++-
----+++++--++----+-+
+-++++----++--++----
++++++-+-+-++-++--+-
-+--+-++++-+-+-+-+-+
--++-+-+--++-++--++-
+---+++-+++-+-+-++-+
+++-+--+++-++-+++-+-
--++--+-++-+--+-+-++
----++-+--+-+-++++-+
--+...

output:

No

result:

ok n=20

Test #24:

score: 0
Accepted
time: 79ms
memory: 82952kb

input:

4000
++---+++-+++-++++++----++-+-+----+-+----+-+-+---+--+-+-----+-+--++++++-++-++++-++----+-++---++++++--+++++--+++--++++-+-+++-++++-+--+++-+++-+--+-+-+++-+-+-+-+++-+-++-++-++++-++-+-++----++++-++++++--+-+---++--+++-++-+-+----+++--+-+--++----+-+++-+-------+++-++--+++-+--+-++----+--------++++--+--+-+...

output:

No

result:

ok n=4000

Test #25:

score: 0
Accepted
time: 95ms
memory: 82968kb

input:

3999
-++--+-+--+++-++--+---++--+---++--+++---++--++---++-+--++---+--++++---+++---++--++-+++++----++-+-+-----++--+++--++--++-+--+-++++-++++--++++-----------+++-+++++++-++--++--+-----++-+-----++++--+++++-+++-+-+--++++-++--++--+--+++-+-+-+-++-++----+---+++++--+++-+---++---+--+-++++-+-++-+-+-+---++-----...

output:

Yes
10011010110001001101110011011100110001110011001110010110011101100001110001110011001000001111001010111110011000110011001011010000100001100001111111111100010000000100110011011111001011111000011000001000101011000010011001101100010101010010011110111000001100010111001110110100001010010101011100111111...

result:

ok n=3999

Test #26:

score: 0
Accepted
time: 98ms
memory: 81512kb

input:

4000
++---+++-+++-++++++----++-+-+----+-+----+-+-+---+--+-+-----+-+--++++++-++-++++-++----+-++---++++++--+++++--+++--++++-+-+++-++++-+--+++-+++-+--+-+-+++-+-+-+-+++-+-++-++-++++-++-+-++----++++-++++++--+-+---++--+++-++-+-+----+++--+-+--++----+-+++-+-------+++-++--+++-+--+-++----+--------++++--+--+-+...

output:

Yes
00111000100010000001111001010111101011110101011101101011111010110000001001000010011110100111000000110000011000110000101000100001011000100010110101000101010100010100100100001001010011110000100000011010111001100010010101111000110101100111101000101111111000100110001011010011110111111110000110110100...

result:

ok n=4000

Test #27:

score: 0
Accepted
time: 120ms
memory: 82616kb

input:

3999
-++--+-+--+++-++--+---++--+---++--+++---++--++---++-+--++---+--++++---+++---++--++-+++++----++-+-+-----++--+++--++--++-+--+-++++-++++--++++-----------+++-+++++++-++--++--+-----++-+-----++++--+++++-+++-+-+--++++-++--++--+--+++-+-+-+-++-++----+---+++++--+++-+---++---+--+-++++-+-++-+-+-+---++-----...

output:

Yes
01100101001110110010001100100011001110001100110001101001100010011110001110001100110111110000110101000001100111001100110100101111011110011110000000000011101111111011001100100000110100000111100111110111010100111101100110010011101010101101100001000111110011101000110001001011110101101010100011000000...

result:

ok n=3999

Test #28:

score: 0
Accepted
time: 116ms
memory: 82912kb

input:

4000
++---+++-+++-++++++----++-+-+----+-+----+-+-+---+--+-+-----+-+--++++++-++-++++-++----+-++---++++++--+++++--+++--++++-+-+++-++++-+--+++-+++-+--+-+-+++-+-+-+-+++-+-++-++-++++-++-+-++----++++-++++++--+-+---++--+++-++-+-+----+++--+-+--++----+-+++-+-------+++-++--+++-+--+-++----+--------++++--+--+-+...

output:

Yes
11000111011101111110000110101000010100001010100010010100000101001111110110111101100001011000111111001111100111001111010111011110100111011101001010111010101011101011011011110110101100001111011111100101000110011101101010000111001010011000010111010000000111011001110100101100001000000001111001001011...

result:

ok n=4000

Extra Test:

score: 0
Extra Test Passed