QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#368109#2827. Autobiographyhshshs#WA 2ms9696kbC++14800b2024-03-26 20:31:052024-03-26 20:31:05

Judging History

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

  • [2024-03-26 20:31:05]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:9696kb
  • [2024-03-26 20:31:05]
  • 提交

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: ''