QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#299318#7857. (-1,1)-Sumpleteucup-team134#WA 1ms7780kbC++142.9kb2024-01-06 18:56:102024-01-06 18:56:10

Judging History

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

  • [2024-01-06 18:56:10]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7780kb
  • [2024-01-06 18:56:10]
  • 提交

answer

#include<bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
using namespace std;
using u128=__uint128_t;
typedef pair<int,int> pii;

const int mod=998244353;
inline int add(int x,int y){int ret=x+y;if(ret>=mod)ret-=mod;return ret;}
inline int sub(int x,int y){int ret=x-y;if(ret<0)ret+=mod;return ret;}
inline int mul(int x,int y){return ((ll)x*y)%mod;}
inline int step(int base,int pw){int ret=1;while(pw){if(pw&1)ret=mul(ret,base);base=mul(base,base);pw>>=1;}return ret;}
inline int invv(int x){return step(x,mod-2);}

const int maxn=4000+10;

int n,a[maxn][maxn];
pii r[maxn];
int c[maxn],rez[maxn][maxn],orr[maxn],oc[maxn];


int main(){

    ///freopen("test.txt","r",stdin);

    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        string s;
        cin>>s;
        for(int j=0;j<n;j++){
            a[i][j+1]=(s[j]=='+')?1:-1;
        }
    }

    for(int i=1;i<=n;i++){
        scanf("%d",&r[i].ff);
        r[i].ss=i;

        orr[i]=r[i].ff;
    }

    for(int i=1;i<=n;i++){
        scanf("%d",&c[i]);

        oc[i]=c[i];
    }

    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(a[i][j]==1){
                rez[i][j]=1;
            }
            else{
                r[i].ff++;
                c[j]++;
            }
        }
    }


    sort(r+1,r+n+1);


    int e=1;
    int sum=0;
    for(int i=1;i<=n;i++){
        if(r[i].ff<0 || c[i]<0){
            e=0;
            break;
        }
        sum+=r[i].ff-c[i];
    }
    if(!e || sum!=0){
        printf("No\n");
        return 0;
    }

    for(int i=1;i<=n;i++){

        vector<pii>pom;

        for(int j=1;j<=c[i];j++){
            pom.pb(r[n-j+1]);
            if(r[n-j+1].ff==0){
                e=0;
                break;
            }
        }
        if(!e)break;

        for(int j=0;j<pom.size();j++){
            rez[pom[j].ss][i]^=1;
            pom[j].ff--;
        }

        vector<pii>pom2;
        int pt1=1;
        int pt2=0;
        for(int j=1;j<=n;j++){

            pii v1,v2;
            v1={1e9,-1};
            v2={1e9,-1};

            if(pt1<=n-c[i])v1=r[pt1];
            if(pt2<pom.size())v2=pom[pt2];

            if(v1<v2){
                pom2.pb(v1);
                pt1++;
            }
            else{
                pom2.pb(v2);
                pt2++;
            }

        }

        for(int j=0;j<pom2.size();j++)r[j+1]=pom2[j];

    }
    if(!e){
        printf("No\n");
        return 0;
    }

    printf("Yes\n");
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            printf("%d",(rez[i][j]^1));

            if(rez[i][j]==0)oc[j]-=a[i][j];
            if(rez[i][j]==0)orr[i]-=a[i][j];
        }
        printf("\n");
    }

    int pe=1;
    for(int i=1;i<=n;i++){
        if(oc[i]!=0 || orr[i]!=0)pe=0;
    }
    if(pe==0)while(1){}

    return 0;
}

詳細信息

Test #1:

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

input:

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

output:

Yes
001
001
111

result:

ok n=3

Test #2:

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

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

input:

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

output:

No

result:

ok n=3

Test #4:

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

input:

1
-
-1
1

output:

No

result:

ok n=1

Test #5:

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

input:

1
-
0
0

output:

Yes
0

result:

ok n=1

Test #6:

score: -100
Wrong Answer
time: 0ms
memory: 5716kb

input:

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

output:

No

result:

wrong answer Jury has the answer but participant has not