QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#591927#2827. Autobiographylonelywolf#TL 0ms0kbC++20781b2024-09-26 19:09:292024-09-26 19:09:31

Judging History

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

  • [2024-09-26 19:09:31]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-09-26 19:09:29]
  • 提交

answer

#include <bits/stdc++.h>  
using namespace std;  

#define int long long  

signed main() {  
    ios::sync_with_stdio(false);
    cin.tie(nullptr);  

    while (true) {
 		int n, m;
 		cin >> n >> m;
		vector<int> col(n + 1);
		for (int i = 1; i <= n; i++) {
			char c;
			cin >> c;

			col[i] = c == 'o' ? 0 : 1;
		}

		vector cnt(n + 1, vector<int>(2));
		vector<pair<int, int>> e(m);
		for (int i = 0; i < m; i++) {
			int x, y;
			cin >> x >> y;
			e[i] = {x, y};

			if (col[x] != col[y]) {
				cnt[x][col[y]]++;
				cnt[y][col[x]]++;
			}
		}

		int ans = 0;
		for (auto [x, y] : e) {
			if (col[x] != col[y]) {
				ans += (cnt[x][col[y]] - 1) * (cnt[y][col[x]] - 1);
			}
		}

		cout << ans << "\n";
    }

    return 0;
}  
  

详细

Test #1:

score: 0
Time Limit Exceeded

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
4
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result: