QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#201622#5161. Last GuessRd_rainydays#WA 1ms5936kbC++142.0kb2023-10-05 15:35:272023-10-05 15:35:28

Judging History

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

  • [2023-10-05 15:35:28]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5936kb
  • [2023-10-05 15:35:27]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#define N 1005
using namespace std;
int n,m;
char s[N][N],t[N][N];
char ans[N],mp[N][N];
int ban[N];
int up[N],lw[N];
int cnt[N],aux[N];
vector<int> G[N];
int vis[N],match[N],col[N];
bool dfs(int x,int t){
   for(int y:G[x]){
    if(vis[y]!=t){
      vis[y]=t;
      if(!match[y]||dfs(match[y],t))return match[y]=x,true;
    }
   }
  return false;
}
int main(){
  scanf("%d%d",&n,&m);
  for(int i=1;i<n;i++){
    scanf("%s%s",s[i]+1,t[i]+1);
  }
  for(int i='a';i<='z';i++)up[i]=m,lw[i]=0;
  for(int i=1;i<n;i++){
    for(int r=1;r<=m;r++)if(t[i][r]=='G')ans[r]=s[i][r],ban[r]=1;
  }
  for(int i=1;i<=m;i++)if(ban[i])aux[ans[i]]++;
  for(int i='a';i<='z';i++)lw[i]=aux[i];
  for(int i=1;i<n;i++){
    for(int r='a';r<='z';r++)cnt[r]=0;
    for(int r=1;r<=m;r++)if(t[i][r]=='G')cnt[s[i][r]]++;
    for(int r=1;r<=m;r++){
      if(ban[r])continue;
      else {
        if(t[i][r]=='Y'){
          cnt[s[i][r]]++;
          lw[s[i][r]]=max(lw[s[i][r]],cnt[s[i][r]]);
          mp[s[i][r]][r]=1;
        }
        else if(t[i][r]=='B'){
          up[s[i][r]]=min(up[s[i][r]],cnt[s[i][r]]);
          mp[s[i][r]][r]=1;
        }
      }
    }
  }
  for(int i='a';i<='z';i++){
    lw[i]-=aux[i],up[i]-=aux[i];
    // if(lw[i]!=0||up[i]!=m)cout<<(char)i<<" "<<lw[i]<<" "<<up[i]<<endl;
  }
  int idx=0;
  for(int i='a';i<='z';i++){
    for(int r=1;r<=lw[i];r++){
      idx++;col[idx]=i;
      for(int p=1;p<=m;p++){
        if(mp[i][p]==0&&ban[p]==0)G[idx].push_back(p);
      }
    }
  }
  int deg=0;
  for(int i=1;i<=idx;i++){
    deg+=int(dfs(i,i));
  }
  // cout<<"debug:"<<idx<<" "<<deg<<endl;
  for(int i=1;i<=m;i++){
    if(ban[i])continue;
    if(match[i])ans[i]=(char)col[match[i]];
    else {
      for(int r='a';r<='z';r++){
        if(lw[r]<up[r]){
          ans[i]=r;
          lw[r]++;
          break;
        }
      }
    }
  }
  puts(ans+1);

}

详细

Test #1:

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

input:

4 5
reply YYGBB
refer BBBGG
puppy YYGBB

output:

upper

result:

ok 

Test #2:

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

input:

2 12
aabbccddeeff GGGYGBYYYBBB

output:

aabecdbadaaa

result:

ok 

Test #3:

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

input:

25 500
qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqoqqqqqqqqqqqqqqqqqqqqqqoqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqjq...

output:

zyxwvutsrpooonmlkjihgfedcbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

result:

FAIL Wrong answer: does not fit word 8