QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#368109 | #2827. Autobiography | hshshs# | WA | 2ms | 9696kb | C++14 | 800b | 2024-03-26 20:31:05 | 2024-03-26 20:31:05 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 9;
int n, m;
char s[N];
int cnt[N];
int U[N], V[N];
vector<int> G[N];
int main() {
freopen("1.in", "r", stdin);
while(~scanf("%d %d", &n, &m)) {
for (int i = 1; i <= n; ++i)cnt[i]=0;
scanf("%s", s+1);
long long ans = 0;
for (int i = 1; i <= n; ++i) G[i].clear();
for(int i = 1; i <= m; ++i ) {
scanf("%d %d", &U[i], &V[i]);
G[U[i]].push_back(V[i]);
G[V[i]].push_back(U[i]);
}
for (int i = 1; i <= n; ++i) {
for (int j : G[i]) {
if (s[j] != s[i])
cnt[i]++;
}
}
for(int i = 1; i <= m; ++i ) {
int u = U[i], v = V[i];
if (s[u] != s[v] ) {
ans += 1LL * (cnt[u]- 1) * (cnt[v] - 1);
}
}
printf("%lld\n", ans);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 9696kb
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:
result:
wrong answer 1st lines differ - expected: '2', found: ''