QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#21738#2827. AutobiographyDoorKickers#WA 3ms3536kbC++201.1kb2022-03-08 14:47:542022-05-08 04:00:37

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-08 04:00:37]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3536kb
  • [2022-03-08 14:47:54]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, m; cin >> n >> m;
    string s; cin >> s;
    vector<vector<int>> vec(n + 1);
    vector<bool> vis(n + 1);
    for (int i = 1; i <= m; i++) {
        int u, v; cin >> u >> v;
        vec[u].push_back(v);
        vec[v].push_back(u);
    }
    s = ' ' + s;
    int ans = 0;
    char check[] = {0, 'b', 'o', 'b', 'o'};
    function<void(int, int)> dfs = [&] (int x, int now) {
        // cout << "x = " << x << '\n';
        // cout << "now = " << now << '\n';
        if (now == 4) {
            ans++;
            return;
        }
        for (int i = 0; i < vec[x].size(); i++) {
            int y = vec[x][i];
            if (vis[y]) continue;
            vis[y] = 1;
            if (check[now + 1] == s[y]) dfs(y, now + 1);
            vis[y] = 0;
        }
    };
    for (int i = 1; i <= n; i++) {
        if (s[i] == 'b') {
            vis[i] = 1;
            dfs(i, 1);
            vis[i] = 0;
        }
    }
    cout << ans << '\n';
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 3536kb

input:

5 4
bbobo
1 3
2 3
3 4
4 5
4 6
bobo
1 2
1 3
1 4
2 3
2 4
3 4
4 0
bobo

output:

2

result:

wrong answer 2nd lines differ - expected: '4', found: ''