QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#206569#5161. Last Guesswillow#WA 1ms4020kbC++173.1kb2023-10-07 21:20:482023-10-07 21:20:49

Judging History

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

  • [2023-10-07 21:20:49]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4020kb
  • [2023-10-07 21:20:48]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int g, l, least[26], most[26], cnt[26], cant[505][26], id, match[505], vis[505], clk, must[505], to[505];
char word[505], op[505], ans[505], ch[1005];
vector<int> G[505], need;
int Dfs(int u) {
    for(auto v : G[u]) {
        if(vis[v] != clk) {
            vis[v] = clk;
            if(!match[v] || Dfs(match[v])) {
                match[v] = u;
                to[u] = v;
                return 1;
            }
        }
    }
    return 0;
}
int main() {
    scanf("%d%d", &g, &l);
    fill(most, most + 26, l + 1);
    for(int i = 1; i <= l; ++ i)
        ans[i] = ' ';
    for(int i = 1; i < g; ++ i) {
        scanf("%s%s", word + 1, op + 1);
        fill(cnt, cnt + 26, 0);
        for(int j = 1; j <= l; ++ j) {
            int c = word[j] - 'a';
            if(op[j] == 'G') {
                ++ cnt[c];
                ans[j] = word[j];
            }
        }
        for(int j = 1; j <= l; ++ j) {
            int c = word[j] - 'a';
            if(op[j] == 'Y') {
                ++ cnt[c];
                cant[j][c] = 1;
            }
            else if(op[j] == 'B') {
                most[c] = min(most[c], cnt[c]);
                cant[j][c] = 1;
            }
        }
        for(int j = 0; j < 26; ++ j)
            least[j] = max(least[j], cnt[j]);
    }
    for(int i = 1; i <= l; ++ i)
        if(ans[i] != ' ')
            -- least[ans[i] - 'a'], -- most[ans[i] - 'a'];
    for(int i = 1; i <= l; ++ i) {
        if(ans[i] == ' ') {
            must[i] = 1;
            for(int j = 0; j < 26; ++ j) {
                if(least[j] < most[j]) {
                    must[i] = 0;
                    break;
                }
            }
            need.push_back(i);
        }
    }
    for(int i = 0; i < 26; ++ i) {
        assert(least[i] >= 0);
        for(int k = id + 1; k <= id + least[i]; ++ k) {
            ch[k] = i + 'a';
        }
        for(int j = 1; j <= l; ++ j) {
            if(ans[j] == ' ' && !cant[j][i]) {
                for(int k = id + 1; k <= id + least[i]; ++ k) {
                    // G[k].push_back(j);
                    G[j].push_back(k);
                }
            }
        }
        id += least[i];
    }
    sort(need.begin(), need.end(), [](int x, int y) {
        return must[x] > must[y];
    });
// cerr << id << endl;
// for(int i = 1; i <= id; ++ i)
//     cerr << ch[i] << " ";
// cerr << endl;
    int matcnt = 0;
    for(auto w : need) {
        ++ clk;
        // assert(Dfs(w));
        matcnt += Dfs(w);
    }
    assert(matcnt == id);
    for(int i = 1; i <= l; ++ i) {
        if(ans[i] == ' ') {
            if(to[i]) {
                ans[i] = ch[to[i]];
            }
            else {
                for(int j = 0; j < 26; ++ j) {
                    if(!cant[i][j] && least[j] < most[j]) {
                        ans[i] = j + 'a';
                        ++ least[j];
                        break;
                    }
                }
            }
        }
    }
    for(int i = 1; i <= l; ++ i)
        putchar(ans[i]);
    puts("");
}

詳細信息

Test #1:

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

input:

4 5
reply YYGBB
refer BBBGG
puppy YYGBB

output:

upper

result:

ok 

Test #2:

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

input:

2 12
aabbccddeeff GGGYGBYYYBBB

output:

aabdcdebaaaa

result:

ok 

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 4020kb

input:

25 500
qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqoqqqqqqqqqqqqqqqqqqqqqqoqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqjq...

output:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaa...

result:

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