QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#775171#7857. (-1,1)-Sumplete123456zmy#AC ✓1485ms97172kbC++141.5kb2024-11-23 14:57:352024-11-23 14:57:35

Judging History

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

  • [2024-11-23 14:57:35]
  • 评测
  • 测评结果:AC
  • 用时:1485ms
  • 内存:97172kb
  • [2024-11-23 14:57:35]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

signed main()
{
    int n,sum=0;
    cin>>n;
    vector<string>a(n);
    vector<vector<int>>ans(n,vector<int>(n));
    vector<pair<int,int>>r(n),c(n);
    for(int i=0;i<n;i++)cin>>a[i],r[i].second=c[i].second=i;
    for(int i=0;i<n;i++)cin>>r[i].first,sum+=r[i].first;
    for(int i=0;i<n;i++)cin>>c[i].first,sum-=c[i].first;
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            if(a[i][j]=='-')++r[i].first,++c[j].first;
    if(sum!=0)puts("no");
    else
    {
        vector<vector<int>>cnt(n+1);
        for(int i=0;i<n;i++)
        {
            if(r[i].first<0||r[i].first>n)puts("No"),exit(0);
            cnt[r[i].first].push_back(r[i].second);
        }
        sort(c.begin(),c.end());
        for(int i=n-1;i>=0;i--)
        {
            int cnt1=0,j=n;
            for(;j>0;j--)if((cnt1+=cnt[j].size())>=c[i].first)break;
            if(j==0)puts("nO"),exit(0);
            for(int k=cnt1-c[i].first;k<cnt[j].size();k++)
                cnt[j-1].push_back(cnt[j][k]),ans[cnt[j][k]][c[i].second]=1;
            cnt[j].resize(cnt1-c[i].first);
            for(j+=1;j<=n;j++)
            {
                for(int x:cnt[j])cnt[j-1].push_back(x),ans[x][c[i].second]=1;
                vector<int>().swap(cnt[j]);
            }
        }
        puts("YES");
        for(int i=0;i<n;i++,puts(""))
            for(int j=0;j<n;j++)
                printf("%d",ans[i][j]^(a[i][j]=='-'));
    }
    return 0;
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

YES
001
001
111

result:

ok n=3

Test #2:

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

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: 3600kb

input:

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

output:

nO

result:

ok n=3

Test #4:

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

input:

1
-
-1
1

output:

no

result:

ok n=1

Test #5:

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

input:

1
-
0
0

output:

YES
0

result:

ok n=1

Test #6:

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

input:

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

output:

YES
11000101111100101110
01101101110110100010
11101101010001111001
10110000111110111111
11011010100101010100
10011011000001001110
10000000001000101110
00110110001001110111
00111111100101001101
11000111101100011011
00011111100100011001
10110000001101011010
11110101000011011000
01111101011001001001
10...

result:

ok n=20

Test #7:

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

input:

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

output:

YES
1111010101011101010010100001010011110010000101011100101110000000101100101101010111110111110001010111
0111011110110100010110101010100010111001011010111100110110100010000011100110101111110010011111101111
0010000101100100110010100110110100010101010101000000011111111010010011011000101101100111011101...

result:

ok n=100

Test #8:

score: 0
Accepted
time: 16ms
memory: 5248kb

input:

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

output:

YES
11000100011111100011111001101100010111110001100100010010010010111001001011001001110001001111001101111010110011111110110111000110100000111001001101100011111100000010001100110111100000000100000001001110111010101010110111101010100101101100010000000110011010010101001000101101100110010001110011100100...

result:

ok n=500

Test #9:

score: 0
Accepted
time: 975ms
memory: 97052kb

input:

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

output:

YES
01110011011001101000010001110110000001101100110111110011001000100011111111100110101000001001110011001010011100010101111101111101000110000100111001001101010111000101110011011110010011110101100100010011111000111001010110100001001100000000101001111001100110111010000100010010100010011010101110101100...

result:

ok n=4000

Test #10:

score: 0
Accepted
time: 989ms
memory: 96808kb

input:

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

output:

YES
10010111110110010110111111101110011011001000001010110111000101000011011010111010111010000111010111100001010011010001110010010101010010110001111011111010001100000101000100011111001101111010100111110110011000001001111100111001101011101111000101000101110101010000011000010110000000110111001100110101...

result:

ok n=4000

Test #11:

score: 0
Accepted
time: 1038ms
memory: 96812kb

input:

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

output:

YES
01001010011111111110000101111110110101101010101111000110010001111100011100101100011011101111000100101000001001000000001100101000000111000111010100011010000100000100000100010011100100101010100101100001011111000011010010001111000010001110101100010111001110110001000001101111101011000101111100000001...

result:

ok n=4000

Test #12:

score: 0
Accepted
time: 995ms
memory: 96812kb

input:

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

output:

YES
11111111100011100100110010100011110101000011111011011001100111010001010110001101110100010101010101101111000101011011111011000011111001101011001100011111011110100011101110101000100001000101001010110010000110111011100110110101011001101100010100110001101111100000010110100100010001101011010111010111...

result:

ok n=4000

Test #13:

score: 0
Accepted
time: 1029ms
memory: 96904kb

input:

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

output:

YES
01101000011101000111001011001110111011011101011110111001111010111110101011011000001100000101011011100001011010101110001001010100111110000100111010010001001111010011010001111110101111011000110101010001110110111010111001001110100001001011000101100111011110010101110100101100111000001000101101001111...

result:

ok n=4000

Test #14:

score: 0
Accepted
time: 925ms
memory: 97052kb

input:

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

output:

YES
01100000110001010001001011101010001111110000111000111011010111100101100101000111110000000101111111000101001011011101100010000010101101000000000000000101101010111010100000100110101110011011001010001010000010010010111100010010000111110111100100111010111001101010111000001001110101101100011000010010...

result:

ok n=4000

Test #15:

score: 0
Accepted
time: 1082ms
memory: 97172kb

input:

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

output:

YES
00011011010100101101011000000001001110011110111010011100100111011110010011001111100110010100001010001101110100111111111101000011010100111110001010010010100100111011010010111110111100001010101100000010010101011111110111010001011001110000101101110010111111011011011001110111011111110000001111010001...

result:

ok n=4000

Test #16:

score: 0
Accepted
time: 1485ms
memory: 96932kb

input:

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

output:

YES
10011000000100110011110001111011011110010000011110010001111001000001111110000001000100000010101000001011100111010101110000011000101000101111101001011001101000001101010001110101001111001110010110101101001110011100000011011111100100110110111011010011000001000100110101110110100110110100110101010110...

result:

ok n=4000

Test #17:

score: 0
Accepted
time: 1431ms
memory: 97100kb

input:

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

output:

YES
10100010101111100110100011001001011101001011100010001011100000010010001011101111101000010110010001101000011010101010110100011101101110110110010101100101001100111111010110000110010110111100101010111000001100101001000110010100001010110100100101011011101110101100001110100001011001111110001000001010...

result:

ok n=3999

Test #18:

score: 0
Accepted
time: 1463ms
memory: 96764kb

input:

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

output:

YES
11111110011000110001110000010110001000110100111101110110000111000100001000101000001010101100001111110001001001011100100000110010101001101011001101110110011110100001100110010111010010100001011111011000100010110001100000001110011001011010111001111011000000010110101001010001000110100000100110000010...

result:

ok n=3998

Test #19:

score: 0
Accepted
time: 244ms
memory: 96664kb

input:

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

output:

nO

result:

ok n=4000

Test #20:

score: 0
Accepted
time: 238ms
memory: 96708kb

input:

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

output:

nO

result:

ok n=3999

Test #21:

score: 0
Accepted
time: 238ms
memory: 96560kb

input:

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

output:

nO

result:

ok n=3998

Test #22:

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

input:

2
+-
--
0 -1
-1 2

output:

no

result:

ok n=2

Test #23:

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

input:

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

output:

no

result:

ok n=20

Test #24:

score: 0
Accepted
time: 268ms
memory: 96168kb

input:

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

output:

no

result:

ok n=4000

Test #25:

score: 0
Accepted
time: 899ms
memory: 96496kb

input:

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

output:

YES
10011010110001001101110011011100110001110011001110010110011101100001110001110011001000001111001010111110011000110011001011010000100001100001111111111100010000000100110011011111001011111000011000001000101011000010011001101100010101010010011110111000001100010111001110110100001010010101011100111111...

result:

ok n=3999

Test #26:

score: 0
Accepted
time: 889ms
memory: 96516kb

input:

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

output:

YES
00111000100010000001111001010111101011110101011101101011111010110000001001000010011110100111000000110000011000110000101000100001011000100010110101000101010100010100100100001001010011110000100000011010111001100010010101111000110101100111101000101111111000100110001011010011110111111110000110110100...

result:

ok n=4000

Test #27:

score: 0
Accepted
time: 1030ms
memory: 96672kb

input:

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

output:

YES
01100101001110110010001100100011001110001100110001101001100010011110001110001100110111110000110101000001100111001100110100101111011110011110000000000011101111111011001100100000110100000111100111110111010100111101100110010011101010101101100001000111110011101000110001001011110101101010100011000000...

result:

ok n=3999

Test #28:

score: 0
Accepted
time: 1002ms
memory: 96680kb

input:

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

output:

YES
11000111011101111110000110101000010100001010100010010100000101001111110110111101100001011000111111001111100111001111010111011110100111011101001010111010101011101011011011110110101100001111011111100101000110011101101010000111001010011000010111010000000111011001110100101100001000000001111001001011...

result:

ok n=4000

Extra Test:

score: 0
Extra Test Passed