QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#201814#5161. Last GuessRd_rainydays#WA 2ms12240kbC++142.1kb2023-10-05 16:54:512023-10-05 16:54:52

Judging History

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

  • [2023-10-05 16:54:52]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:12240kb
  • [2023-10-05 16:54:51]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#define N 5005
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=1;i<n;i++){
    for(int r='a';r<='z';r++)cnt[r]=0;
    for(int r=1;r<=m;r++)if(ban[r]&&t[i][r]!='G')cnt[ans[r]]--;
    for(int r=1;r<=m;r++){
        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;
        }
    }
    for(int r=1;r<=m;r++){
        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]<<" "<<aux[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]&&mp[r][i]==0){
          ans[i]=r;
          lw[r]++;
          break;
        }
      }
    }
  }
  puts(ans+1);

}
/*
8 6
source GYBYBB
slower GBYBBY
slowly GBYBBB
sorted GYGYBB
scream GBGBBB
scattr GBBYBY
strooo GGGGBB
*/

详细

Test #1:

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

input:

4 5
reply YYGBB
refer BBBGG
puppy YYGBB

output:

upper

result:

ok 

Test #2:

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

input:

2 12
aabbccddeeff GGGYGBYYYBBB

output:

aabecdbadaaa

result:

ok 

Test #3:

score: -100
Wrong Answer
time: 2ms
memory: 12240kb

input:

25 500
qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqoqqqqqqqqqqqqqqqqqqqqqqoqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqjq...

output:

zyxwvutsrpooonmlkjihgfedcbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

result:

FAIL Condition failed: "answer.size() == n"