-
Notifications
You must be signed in to change notification settings - Fork 2
/
games_268A.rs
47 lines (35 loc) · 963 Bytes
/
games_268A.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// https://codeforces.com/problemset/problem/268/A
// brute force
use std::io;
fn main() {
let mut n = String::new();
io::stdin()
.read_line(&mut n)
.unwrap();
let n: i64 = n.trim().parse().unwrap();
let mut teams = Vec::<Vec<i64>>::new();
for _ in 0..n {
let mut line = String::new();
io::stdin()
.read_line(&mut line)
.unwrap();
let words: Vec<i64> =
line
.split_whitespace()
.map(|x| x.parse().unwrap())
.collect();
teams.push(words);
}
let mut answer = 0;
for (i, _team) in teams.clone().iter().enumerate() {
// home uniform color
let color = teams[i][0];
for (j, _item) in teams.clone().iter().enumerate() {
// guest uniform color
if teams[j][1] == color {
answer += 1;
}
}
}
println!("{}", answer);
}