QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#360270#7857. (-1,1)-SumpleteawayyyAC ✓676ms128940kbC++201.9kb2024-03-21 16:38:292024-03-21 16:38:30

Judging History

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

  • [2024-03-21 16:38:30]
  • 评测
  • 测评结果:AC
  • 用时:676ms
  • 内存:128940kb
  • [2024-03-21 16:38:29]
  • 提交

answer

#include <bits/stdc++.h>

int n;
int m[4000][4000], s[4000][4000], r[4000], c[4000];

void select(int i, int j) {
    s[i][j] ^= 1;
    r[i] += m[i][j], c[j] += m[i][j];
    m[i][j] = -m[i][j];
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin >> n;
    for(int i = 0; i < n; ++i) {
        std::string s; std::cin >> s;
        for(int j = 0; j < n; ++j)
            m[i][j] = (s[j] == '+' ? 1 : -1);
    }
    
    for(int i = 0; i < n; ++i) std::cin >> r[i], r[i] = -r[i];
    for(int i = 0; i < n; ++i) std::cin >> c[i], c[i] = -c[i];

    for(int i = 0; i < n; ++i) for(int j = 0; j < n; ++j)
        if(m[i][j] > 0) select(i, j);

    for(int i = 0; i < n; ++i) if(c[i] < 0 || r[i] < 0)
        return std::cout << "No\n", 0;
    
    // for(int i = 0; i < n; ++i) {
    //     for(int j = 0; j < n; ++j) std::cout << s[i][j];
    //     std::cout << "\n";
    // }

    std::vector<int> rr(n), cc(n);
    for(int i = 0; i < n; ++i) rr[i] = cc[i] = i;
    std::sort(rr.begin(), rr.end(), [](int x, int y) {
        return r[x] > r[y];
    });

    for(int i: rr) {
        std::sort(cc.begin(), cc.end(), [](int x, int y) {
            return c[x] > c[y];
        });
        for(int j: cc) {
            if(r[i] <= 0) break;
            if(c[j] > 0) select(i, j);
        }
    }

    // for(int i = 0; i < n; ++i) {
    //     for(int j = 0; j < n; ++j) std::cout << s[i][j];
    //     std::cout << "\n";
    // }
    // for(int i = 0; i < n; ++i) std::cerr << c[i] << char(i == n - 1 ? 10 : 32); 
    // for(int i = 0; i < n; ++i) std::cerr << r[i] << char(i == n - 1 ? 10 : 32);

    for(int i = 0; i < n; ++i) if(c[i] || r[i]) return std::cout << "No\n", 0;

    std::cout << "Yes\n";
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) std::cout << s[i][j];
        std::cout << "\n";
    }

    return 0;
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

Yes
111
001
001

result:

ok n=3

Test #2:

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

input:

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

output:

Yes
110
100
000

result:

ok n=3

Test #3:

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

input:

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

output:

No

result:

ok n=3

Test #4:

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

input:

1
-
-1
1

output:

No

result:

ok n=1

Test #5:

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

input:

1
-
0
0

output:

Yes
0

result:

ok n=1

Test #6:

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

input:

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

output:

Yes
11100101100111011001
00101101100110010100
00101011101110111010
10000111011001110111
01101111100101001101
11000010111011100011
01000100000011000101
00100111011101101111
00000000100000010101
11100000101000011001
00000111111111000111
11001010011101001101
00011111001100011001
00110101111001000001
01...

result:

ok n=20

Test #7:

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

input:

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

output:

Yes
0111010100100011010110001011101111000101100101010111101110001100101100111000100010010010110000010011
1110011010111101000101101110000010001001010110001100010000000110000010110010100111111010111111001111
0000011111100110111000100010111110000000100001001010011110111011000111101010101010101010011001...

result:

ok n=100

Test #8:

score: 0
Accepted
time: 14ms
memory: 9452kb

input:

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

output:

Yes
01011101011110101001001000011101011111100101100010010101111011100101000011001111110011101101001101111110101011111011101101010110001000111000001101100010111100000110001110110101011011000100100011000111111001100011101001011010100101110100010010001110011000000101011001111001000101111101100001110010...

result:

ok n=500

Test #9:

score: 0
Accepted
time: 606ms
memory: 128688kb

input:

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

output:

Yes
10000010001011011000110000000101001011010001110101011011110011001111000000010111111001011001110000010000110111000010111100010001100000100001010110010011110010011111000011100010111101011011011010011011000101111011000000110100000011111101000100011101011000100110000101110011011100111101001010000001...

result:

ok n=4000

Test #10:

score: 0
Accepted
time: 600ms
memory: 128636kb

input:

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

output:

Yes
10101010110010011000010001100010100001110001010000010000010100000100110001100011011011000111001101100110001101010001011111010010110110001011001010000111101011001100100110011111000101101011001000001111010010000010001100110100010101000011001101111101000101000110110101010010100000100000000101110101...

result:

ok n=4000

Test #11:

score: 0
Accepted
time: 633ms
memory: 128888kb

input:

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

output:

Yes
01000000010110011011000000010001011111101010111000001100111001000100011010001110110110100010011100101101111110011011111000111001111101110100001101010111100001110001101101110110001001000000110101110111101001001001001110110000000010001011010010110010010010100100011100100110111101001100111011001000...

result:

ok n=4000

Test #12:

score: 0
Accepted
time: 629ms
memory: 128716kb

input:

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

output:

Yes
01011100011011011001010000001011001011101001100110101111101011010001110101100110100010001001110111111100100101010000110111010101000101100000000010111110101011101111011000111111001010010110101110101000110110110010001110011001110001101001100111010101001011101011010100110100000000101010101101010100...

result:

ok n=4000

Test #13:

score: 0
Accepted
time: 611ms
memory: 128636kb

input:

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

output:

Yes
10101001111001101001001111100101000100100000011101111010110100010110011010111101010010011101001000100101110111111111111010010111011100110001101011111100111001011011111010011000100010011110100100010010110110011010010110010101111001100011110101101101100010001101011100101100101011010010110110100110...

result:

ok n=4000

Test #14:

score: 0
Accepted
time: 618ms
memory: 128688kb

input:

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

output:

Yes
01100000000011010001101010101011101111110000111100101001011111100111100111000101110100000101111110000100001011011111100110100010101101000000000000010001011010111010111100100100101110000101111000001010000010110010111100011010010100110110100100101010111001011010111100100101111111111100011000010011...

result:

ok n=4000

Test #15:

score: 0
Accepted
time: 593ms
memory: 128672kb

input:

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

output:

Yes
00011011010100011101111100000000001110011100100110000100100101010110011010000111100110000100001010001101111100101111111101000011110100001110001010010011111100101011011001111110111100101010101000101010010111001110110011110001001000000100101010110001111110011011111011110101111101101010001110010100...

result:

ok n=4000

Test #16:

score: 0
Accepted
time: 618ms
memory: 128688kb

input:

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

output:

Yes
10011000000100110011110001111011011110010000011110010001111001000001111110000001000100000010101000001011100111010101110000011000101000101111101001011001101000001101010001110101001111001110010110101101001110011100000011011111100100110110111011010011000001000100110101110110100110110100110101010110...

result:

ok n=4000

Test #17:

score: 0
Accepted
time: 633ms
memory: 128580kb

input:

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

output:

Yes
10100010101111100110100011001001011101001011100010001011100000010010001011101111101000010110010001101000011010101010110100011101101110110110010101100101001100111111010110000110010110111100101010111000001100101001000110010100001010110100100101011011101110101100001110100001011001111110001000001010...

result:

ok n=3999

Test #18:

score: 0
Accepted
time: 610ms
memory: 128688kb

input:

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

output:

Yes
11111110011000110001110000010110001000110100111101110110000111000100001000101000001010101100001111110001001001011100100000110010101001101011001101110110011110100001100110010111010010100001011111011000100010110001100000001110011001011010111001111011000000010110101001010001000110100000100110000010...

result:

ok n=3998

Test #19:

score: 0
Accepted
time: 212ms
memory: 128672kb

input:

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

output:

No

result:

ok n=4000

Test #20:

score: 0
Accepted
time: 224ms
memory: 128628kb

input:

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

output:

No

result:

ok n=3999

Test #21:

score: 0
Accepted
time: 202ms
memory: 128592kb

input:

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

output:

No

result:

ok n=3998

Test #22:

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

input:

2
+-
--
0 -1
-1 2

output:

No

result:

ok n=2

Test #23:

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

input:

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

output:

No

result:

ok n=20

Test #24:

score: 0
Accepted
time: 75ms
memory: 128644kb

input:

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

output:

No

result:

ok n=4000

Test #25:

score: 0
Accepted
time: 639ms
memory: 128656kb

input:

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

output:

Yes
10011010110001001101110011011100110001110011001110010110011101100001110001110011001000001111001010111110011000110011001011010000100001100001111111111100010000000100110011011111001011111000011000001000101011000010011001101100010101010010011110111000001100010111001110110100001010010101011100111111...

result:

ok n=3999

Test #26:

score: 0
Accepted
time: 676ms
memory: 128940kb

input:

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

output:

Yes
00111000100010000001111001010111101011110101011101101011111010110000001001000010011110100111000000110000011000110000101000100001011000100010110101000101010100010100100100001001010011110000100000011010111001100010010101111000110101100111101000101111111000100110001011010011110111111110000110110100...

result:

ok n=4000

Test #27:

score: 0
Accepted
time: 597ms
memory: 128584kb

input:

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

output:

Yes
01100101001110110010001100100011001110001100110001101001100010011110001110001100110111110000110101000001100111001100110100101111011110011110000000000011101111111011001100100000110100000111100111110111010100111101100110010011101010101101100001000111110011101000110001001011110101101010100011000000...

result:

ok n=3999

Test #28:

score: 0
Accepted
time: 592ms
memory: 128868kb

input:

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

output:

Yes
11000111011101111110000110101000010100001010100010010100000101001111110110111101100001011000111111001111100111001111010111011110100111011101001010111010101011101011011011110110101100001111011111100101000110011101101010000111001010011000010111010000000111011001110100101100001000000001111001001011...

result:

ok n=4000

Extra Test:

score: 0
Extra Test Passed