Skip to content

Commit 8b3bd7a

Browse files
author
hir12111
committed
Easy one using bitsets
1 parent 6eabc5f commit 8b3bd7a

6 files changed

+268
-0
lines changed

acpcteam.cpp

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
typedef long long ll;
4+
typedef pair<int, int> ii;
5+
typedef tuple<int, int, int> iii;
6+
typedef vector<ii > vii;
7+
typedef vector<iii > viii;
8+
9+
int main()
10+
{
11+
ios::sync_with_stdio(false);
12+
int n, m;
13+
bitset<512> people[512];
14+
cin >> n >> m;
15+
string input;
16+
for(int i=0; i < n; i++) {
17+
cin >> input;
18+
for(int j=0; j < m; j++) {
19+
if (input[j] == '1')
20+
people[i].set(j);
21+
}
22+
}
23+
size_t maxtopics = 0;
24+
size_t maxnum = 0;
25+
for(int i=0; i < n; i++) {
26+
for(int j=i+1; j < n; j++) {
27+
bitset<512> current = people[i] | people[j];
28+
if (current.count() == maxtopics)
29+
maxnum++;
30+
else if (current.count() > maxtopics) {
31+
maxnum = 1;
32+
maxtopics = current.count();
33+
}
34+
}
35+
}
36+
cout << maxtopics << endl << maxnum << endl;
37+
return 0;
38+
}

drazilanddate.rs

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
struct Scan {
2+
buffer: std::collections::VecDeque<String>,
3+
}
4+
5+
impl Scan {
6+
fn new() -> Scan {
7+
Scan {
8+
buffer: std::collections::VecDeque::new(),
9+
}
10+
}
11+
12+
fn next<T: std::str::FromStr>(&mut self) -> T {
13+
loop {
14+
if let Some(token) = self.buffer.pop_front() {
15+
break token.parse::<T>().ok().unwrap();
16+
}
17+
let mut line = String::new();
18+
std::io::stdin().read_line(&mut line).expect("Fail to read");
19+
self.buffer = line.split_whitespace().map(String::from).collect();
20+
}
21+
}
22+
}
23+
24+
fn _main() {
25+
let mut scan = Scan::new();
26+
let a: isize = scan.next();
27+
let b: isize = scan.next();
28+
let s: isize = scan.next();
29+
let x = a.abs() + b.abs();
30+
let result: bool = s >= x && (s - x) % 2 == 0;
31+
println!("{}", if result { "Yes" } else { "No" });
32+
}
33+
34+
fn main() {
35+
std::thread::Builder::new()
36+
.stack_size(1 << 23)
37+
.spawn(_main)
38+
.unwrap()
39+
.join()
40+
.unwrap();
41+
}

game23.rs

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
struct Scan {
2+
buffer: std::collections::VecDeque<String>,
3+
}
4+
5+
impl Scan {
6+
fn new() -> Scan {
7+
Scan {
8+
buffer: std::collections::VecDeque::new(),
9+
}
10+
}
11+
12+
fn next<T: std::str::FromStr>(&mut self) -> T {
13+
loop {
14+
if let Some(token) = self.buffer.pop_front() {
15+
break token.parse::<T>().ok().unwrap();
16+
}
17+
let mut line = String::new();
18+
std::io::stdin().read_line(&mut line).expect("Fail to read");
19+
self.buffer = line.split_whitespace().map(String::from).collect();
20+
}
21+
}
22+
}
23+
24+
fn _main() {
25+
let mut scan = Scan::new();
26+
let n: usize = scan.next();
27+
let m: usize = scan.next();
28+
if n == m {
29+
println!("0");
30+
} else if m % n != 0 {
31+
println!("-1");
32+
} else {
33+
let mut rem = m / n;
34+
let mut steps = 0usize;
35+
while rem % 2 == 0 {
36+
steps += 1;
37+
rem /= 2;
38+
}
39+
while rem % 3 == 0 {
40+
steps += 1;
41+
rem /= 3;
42+
}
43+
if rem == 1 {
44+
println!("{}", steps);
45+
} else {
46+
println!("-1");
47+
}
48+
}
49+
}
50+
51+
fn main() {
52+
std::thread::Builder::new()
53+
.stack_size(1 << 23)
54+
.spawn(_main)
55+
.unwrap()
56+
.join()
57+
.unwrap();
58+
}

grasshoperandthestring.rs

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
fn is_vowel(c: char) -> bool {
2+
return c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U' || c == 'Y';
3+
}
4+
fn _main() {
5+
let mut line = String::new();
6+
std::io::stdin().read_line(&mut line).expect("Fail to read");
7+
let mut result = 0usize;
8+
let mut index = 0usize;
9+
for c in line.trim().chars() {
10+
index += 1;
11+
if is_vowel(c) {
12+
result = result.max(index);
13+
index = 0;
14+
}
15+
}
16+
index += 1;
17+
result = result.max(index);
18+
println!("{}", result);
19+
}
20+
21+
fn main() {
22+
std::thread::Builder::new()
23+
.stack_size(1 << 23)
24+
.spawn(_main)
25+
.unwrap()
26+
.join()
27+
.unwrap();
28+
}

presentfromlena.rs

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
struct Scan {
2+
buffer: std::collections::VecDeque<String>,
3+
}
4+
5+
impl Scan {
6+
fn new() -> Scan {
7+
Scan {
8+
buffer: std::collections::VecDeque::new(),
9+
}
10+
}
11+
12+
fn next<T: std::str::FromStr>(&mut self) -> T {
13+
loop {
14+
if let Some(token) = self.buffer.pop_front() {
15+
break token.parse::<T>().ok().unwrap();
16+
}
17+
let mut line = String::new();
18+
std::io::stdin().read_line(&mut line).expect("Fail to read");
19+
self.buffer = line.split_whitespace().map(String::from).collect();
20+
}
21+
}
22+
}
23+
24+
fn printseq(x: usize, n: usize) {
25+
let spaces = " ".repeat(n - x);
26+
print!("{}", spaces);
27+
for i in 0..x {
28+
print!("{} ", i);
29+
}
30+
print!("{}", x);
31+
for i in (0..x).rev() {
32+
print!(" {}", i);
33+
}
34+
println!();
35+
}
36+
37+
fn _main() {
38+
let mut scan = Scan::new();
39+
let n: usize = scan.next();
40+
for i in 0..n {
41+
printseq(i, n);
42+
}
43+
printseq(n, n);
44+
for i in (0..n).rev() {
45+
printseq(i, n);
46+
}
47+
}
48+
49+
fn main() {
50+
std::thread::Builder::new()
51+
.stack_size(1 << 23)
52+
.spawn(_main)
53+
.unwrap()
54+
.join()
55+
.unwrap();
56+
}

systemofequations.rs

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
struct Scan {
2+
buffer: std::collections::VecDeque<String>,
3+
}
4+
5+
impl Scan {
6+
fn new() -> Scan {
7+
Scan {
8+
buffer: std::collections::VecDeque::new(),
9+
}
10+
}
11+
12+
fn next<T: std::str::FromStr>(&mut self) -> T {
13+
loop {
14+
if let Some(token) = self.buffer.pop_front() {
15+
break token.parse::<T>().ok().unwrap();
16+
}
17+
let mut line = String::new();
18+
std::io::stdin().read_line(&mut line).expect("Fail to read");
19+
self.buffer = line.split_whitespace().map(String::from).collect();
20+
}
21+
}
22+
}
23+
24+
fn _main() {
25+
let mut scan = Scan::new();
26+
let mut res = 0usize;
27+
let n: usize = scan.next();
28+
let m: usize = scan.next();
29+
let limit: usize = n.max(m);
30+
for i in 0..=limit {
31+
for j in 0..=limit {
32+
if i * i + j == n && i + j * j == m {
33+
res += 1;
34+
}
35+
}
36+
}
37+
println!("{}", res);
38+
}
39+
40+
fn main() {
41+
std::thread::Builder::new()
42+
.stack_size(1 << 23)
43+
.spawn(_main)
44+
.unwrap()
45+
.join()
46+
.unwrap();
47+
}

0 commit comments

Comments
 (0)