Skip to content

Commit eddcbcd

Browse files
authored
GH-42: Solve codeforces 282A (#91)
1 parent dbccf79 commit eddcbcd

File tree

11 files changed

+173
-0
lines changed

11 files changed

+173
-0
lines changed

problems/codeforces282A/.gitginore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
solution

problems/codeforces282A/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Problem
2+
3+
## Usage
4+
5+
Run program with an example
6+
7+
```
8+
bazel run src/main:solution < tests/data/1.in
9+
```
10+
11+
Test program
12+
13+
```
14+
# Run all tests
15+
bazel test --test_output=all tests:solution_test
16+
bazel test --test_output=all --cache_test_results=no tests:solution_test
17+
# Run test with pecific test id
18+
bazel test --test_output=all tests:solution_test --test_arg=1
19+
```

problems/codeforces282A/run_tests.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
for f in $(cd tests/; ls *.in); do
2+
test_id=$(echo $f | cut -d'.' -f1)
3+
./solution < tests/$test_id.in | diff -aur tests/$test_id.out -
4+
done
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
load("@rules_cc//cc:defs.bzl", "cc_binary")
2+
3+
cc_binary(
4+
name = "solution",
5+
srcs = ["solution.cpp"],
6+
visibility = ["//visibility:public"],
7+
)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include <cmath>
2+
#include <vector>
3+
#include <map>
4+
#include <algorithm>
5+
#include <string>
6+
#include <iostream>
7+
8+
using namespace std;
9+
10+
int main(){
11+
ios::sync_with_stdio(false);
12+
cin.tie(0);
13+
int tt;
14+
int x = 0;
15+
cin >> tt;
16+
string s;
17+
while(tt--){
18+
cin >> s;
19+
if(s[1] == '+'){
20+
x++;
21+
} else {
22+
x--;
23+
}
24+
}
25+
cout << x << endl;
26+
return 0;
27+
}

problems/codeforces282A/tests/BUILD

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_test")
2+
3+
cc_test(
4+
name = "solution_test",
5+
srcs = ["solution_test.cpp"],
6+
deps = [
7+
"//problems/codeforces282A/src/main:solution",
8+
"@com_google_googletest//:gtest_main",
9+
],
10+
data = ["data"]
11+
)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1
2+
++X
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2
2+
X++
3+
--X
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0

0 commit comments

Comments
 (0)