QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#774071#7857. (-1,1)-Sumpleteguodong#AC ✓845ms77220kbC++171.9kb2024-11-23 11:35:112024-11-23 11:35:12

Judging History

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

  • [2024-11-23 11:35:12]
  • 评测
  • 测评结果:AC
  • 用时:845ms
  • 内存:77220kb
  • [2024-11-23 11:35:11]
  • 提交

answer

#include <bits/stdc++.h>
#define rep(x, l, r) for(int x = l; x <= r; x++)
using namespace std;

const int MAXN = 4005;
int a1[MAXN], a2[MAXN], b1[MAXN], b2[MAXN], ans[MAXN][MAXN];
char st[MAXN];
struct node{
    int num, id;
} c[MAXN], d[MAXN];
stack<int> sta[MAXN], sta2[MAXN];

bool cmp(node a, node b){
    return a.num > b.num;
}

int main(){
    // freopen("1.in", "r", stdin);
    int n;
    scanf("%d", &n);
    rep(i, 1, n){
        scanf("%s", st);
        rep(j, 1, n){
            if(st[j - 1] == '-') a1[i]--, b1[j]--, ans[i][j] = 1;
        }
    }
    rep(i, 1, n) scanf("%d", &a2[i]);
    rep(i, 1, n) scanf("%d", &b2[i]);
    int flag = 1;
    rep(i, 1, n){
        c[i].num = a2[i] - a1[i];
        d[i].num = b2[i] - b1[i];
        c[i].id = d[i].id = i;
        if(c[i].num > n || c[i].num < 0) flag = 0;
        if(d[i].num > n || d[i].num < 0){
            flag = 0;
            break;
        }
        sta[d[i].num].push(d[i].id);
    }
    if(!flag){
        puts("NO");
        return 0;
    }
    sort(c + 1, c + n + 1, cmp);
    rep(i, 1, n){
        for(int j = n, k = c[i].num; k > 0; k--){
            while(j > 0 && sta[j].empty()) j--;
            if(!j){
                flag = 0;
                break;
            }
            int x = sta[j].top();
            // printf("%d :: %d %d %d\n", i, k, j, x);
            sta[j].pop();
            ans[c[i].id][x] = 1 - ans[c[i].id][x];
            sta2[j - 1].push(x);
        }
        rep(i, 0, n - 1){
            while(!sta2[i].empty()){
                sta[i].push(sta2[i].top());
                sta2[i].pop();
            }
        }
        if(!flag) break;
    }
    rep(i, 1, n) if(!sta[i].empty()) flag = 0;
    if(!flag) puts("NO");
    else{
        puts("YES");
        rep(i, 1, n){
            rep(j, 1, n) printf("%d", ans[i][j]);
            puts("");
        }
    }
    return 0;
}

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

详细

Test #1:

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

input:

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

output:

YES
111
001
001

result:

ok n=3

Test #2:

score: 0
Accepted
time: 2ms
memory: 9512kb

input:

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

output:

YES
110
100
000

result:

ok n=3

Test #3:

score: 0
Accepted
time: 2ms
memory: 9100kb

input:

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

output:

NO

result:

ok n=3

Test #4:

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

input:

1
-
-1
1

output:

NO

result:

ok n=1

Test #5:

score: 0
Accepted
time: 2ms
memory: 10816kb

input:

1
-
0
0

output:

YES
0

result:

ok n=1

Test #6:

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

input:

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

output:

YES
11110011001000101010
10101111010110100010
11110111110110011100
01110001111110001101
01101000100101010100
00011010101001001101
00110111000100111111
01000100110001110110
10000001110111100011
11111000010001010110
00001111111011101100
11010010011100111100
11110111011011011100
11001110101001001101
01...

result:

ok n=20

Test #7:

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

input:

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

output:

YES
1111010111111111100000101010110010110010010001010010101010000100001100101100110011110110010010011011
0111011010100101001010101101101011111001010010011100010001000010000010000110101111110110110011101111
1010100001100101111000001010010100001101100001001010010110100000011111001100101011100110011000...

result:

ok n=100

Test #8:

score: 0
Accepted
time: 12ms
memory: 17604kb

input:

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

output:

YES
10010101001111100011010000011101010111110001100000010110011010100001000011001100110001011101000101110010011111111010111011000010000000111100001010000010110100000000001100011001011001011100000000000110111011111011100101111010000011111101010110011110011100000101001010100100010101111101100011111000...

result:

ok n=500

Test #9:

score: 0
Accepted
time: 797ms
memory: 73636kb

input:

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

output:

YES
01001100000100111001101000010011000110110100011001101111001011110010011010100110110111011110101101101011000110110000110110010110100111100010111100101110100110100101000000100101010111010010001001100011101000001001110000010001100010100101001111110110011000100101110100100011100001100011011111110110...

result:

ok n=4000

Test #10:

score: 0
Accepted
time: 777ms
memory: 72940kb

input:

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

output:

YES
01110011011011101000110001000110001000110101001010110010010101000000110011000001011001001110110111101111101011001011111100010111010011011001001011010001011100110001001010010110011111101011110010000110000011000101001101000111110010001100110111001110101101010000111001010110100110110100000110011111...

result:

ok n=4000

Test #11:

score: 0
Accepted
time: 826ms
memory: 74260kb

input:

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

output:

YES
00100011001000010111100001101001100111101111110110000101101001000101010010111110001110010100000100001000011110100000101010000100110011111100110000001001100011001100000110100111110011101110010111000111110100111111110100001110111010011001101111011100111000110100001101101011000001000111111110000001...

result:

ok n=4000

Test #12:

score: 0
Accepted
time: 797ms
memory: 73268kb

input:

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

output:

YES
10110100100101011111010000100111000000011011011000010001000111101011001110011011101000010001110001011100110100110001010110100111101110111111000111110100000010111001000001010101001101110101111011001000110100101010001110100000011101100010000100011101001110001100100000110111011000000101101001110001...

result:

ok n=4000

Test #13:

score: 0
Accepted
time: 825ms
memory: 74108kb

input:

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

output:

YES
01111100110011010111111010110100010000100000000001111011100110010011000001010100100000000101100110010010011010001001111110011111100011100100010010010011101001110111111111001010011100011110100010000101011011001111100110111111110110010110011111101001110110111000111001101011100101111010101100110111...

result:

ok n=4000

Test #14:

score: 0
Accepted
time: 755ms
memory: 72124kb

input:

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

output:

YES
01100000110011110101000010101011001101110000111100101011011111101111101101000110110100010001111110001100001011010011110110000010101100001000000000010100101010111111000001100100101010010011110010001110010010110110111100010010100101110100100100101010101001001110111101100101111111111100011000110011...

result:

ok n=4000

Test #15:

score: 0
Accepted
time: 833ms
memory: 74792kb

input:

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

output:

YES
10011011010100001101111010110000001111011110110110010100000101011110011011001111100110010101001110001101110101111011111111100011100100101100001000010010100100111111010001111110111100001010111000100010110100011101110000011001000010001000000101100011111110011011111001110101111111110011011110011100...

result:

ok n=4000

Test #16:

score: 0
Accepted
time: 835ms
memory: 72216kb

input:

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

output:

YES
10011000000100110011110001111011011110010000011110010001111001000001111110000001000100000010101000001011100111010101110000011000101000101111101001011001101000001101010001110101001111001110010110101101001110011100000011011111100100110110111011010011000001000100110101110110100110110100110101010110...

result:

ok n=4000

Test #17:

score: 0
Accepted
time: 843ms
memory: 71892kb

input:

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

output:

YES
10100010101111100110100011001001011101001011100010001011100000010010001011101111101000010110010001101000011010101010110100011101101110110110010101100101001100111111010110000110010110111100101010111000001100101001000110010100001010110100100101011011101110101100001110100001011001111110001000001010...

result:

ok n=3999

Test #18:

score: 0
Accepted
time: 839ms
memory: 71904kb

input:

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

output:

YES
11111110011000110001110000010110001000110100111101110110000111000100001000101000001010101100001111110001001001011100100000110010101001101011001101110110011110100001100110010111010010100001011111011000100010110001100000001110011001011010111001111011000000010110101001010001000110100000100110000010...

result:

ok n=3998

Test #19:

score: 0
Accepted
time: 201ms
memory: 71876kb

input:

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

output:

NO

result:

ok n=4000

Test #20:

score: 0
Accepted
time: 187ms
memory: 71792kb

input:

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

output:

NO

result:

ok n=3999

Test #21:

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

input:

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

output:

NO

result:

ok n=3998

Test #22:

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

input:

2
+-
--
0 -1
-1 2

output:

NO

result:

ok n=2

Test #23:

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

input:

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

output:

NO

result:

ok n=20

Test #24:

score: 0
Accepted
time: 90ms
memory: 71652kb

input:

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

output:

NO

result:

ok n=4000

Test #25:

score: 0
Accepted
time: 746ms
memory: 72196kb

input:

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

output:

YES
10011010110001001101110011011100110001110011001110010110011101100001110001110011001000001111001010111110011000110011001011010000100001100001111111111100010000000100110011011111001011111000011000001000101011000010011001101100010101010010011110111000001100010111001110110100001010010101011100111111...

result:

ok n=3999

Test #26:

score: 0
Accepted
time: 750ms
memory: 71924kb

input:

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

output:

YES
00111000100010000001111001010111101011110101011101101011111010110000001001000010011110100111000000110000011000110000101000100001011000100010110101000101010100010100100100001001010011110000100000011010111001100010010101111000110101100111101000101111111000100110001011010011110111111110000110110100...

result:

ok n=4000

Test #27:

score: 0
Accepted
time: 845ms
memory: 76904kb

input:

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

output:

YES
01100101001110110010001100100011001110001100110001101001100010011110001110001100110111110000110101000001100111001100110100101111011110011110000000000011101111111011001100100000110100000111100111110111010100111101100110010011101010101101100001000111110011101000110001001011110101101010100011000000...

result:

ok n=3999

Test #28:

score: 0
Accepted
time: 844ms
memory: 77220kb

input:

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

output:

YES
11000111011101111110000110101000010100001010100010010100000101001111110110111101100001011000111111001111100111001111010111011110100111011101001010111010101011101011011011110110101100001111011111100101000110011101101010000111001010011000010111010000000111011001110100101100001000000001111001001011...

result:

ok n=4000

Extra Test:

score: 0
Extra Test Passed