QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#21738 | #2827. Autobiography | DoorKickers# | WA | 3ms | 3536kb | C++20 | 1.1kb | 2022-03-08 14:47:54 | 2022-05-08 04:00:37 |
Judging History
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: ''