Skip to content

Commit

Permalink
Testing Round #16 (Unrated)
Browse files Browse the repository at this point in the history
  • Loading branch information
ganghe74 committed May 7, 2020
1 parent 063434b commit d32b104
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 0 deletions.
2 changes: 2 additions & 0 deletions codeforces/T16/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Testing Round #16 (Unrated)
https://codeforces.com/contest/1351
11 changes: 11 additions & 0 deletions codeforces/T16/a.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <bits/stdc++.h>
using namespace std;

int main() {
int t, a, b;
scanf("%d", &t);
while (t--) {
scanf("%d%d", &a, &b);
printf("%d\n", a+b);
}
}
19 changes: 19 additions & 0 deletions codeforces/T16/b.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <bits/stdc++.h>
using namespace std;

int main() {
int t;
scanf("%d", &t);
while (t--) {
int a[2], b[2];
scanf("%d%d%d%d", &a[0], &a[1], &b[0], &b[1]);
bool flag = false;
for (int i=0;i<2;++i) {
for (int j=0;j<2;++j) {
if (a[i] == b[j] && (a[1-i] + b[1-j] == a[i]))
flag = true;
}
}
puts(flag ? "YES" : "NO");
}
}
32 changes: 32 additions & 0 deletions codeforces/T16/c.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include <bits/stdc++.h>
using namespace std;
using lint = long long;

int main() {
ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
int t;
cin >> t;
while (t--) {
int ans = 0;
string s;
cin >> s;

unordered_map<lint, unordered_map<lint, bool>> m;
int r = 10000, c = 10000;
for (char x : s) {
lint u = 1LL * r * 20000 + c;
if (x == 'N') r += 1;
else if (x == 'S') r -= 1;
else if (x == 'W') c -= 1;
else if (x == 'E') c += 1;
lint v = 1LL * r * 20000 + c;
if (u > v) swap(u, v);
if (m[u][v]) ans++;
else {
m[u][v] = 1;
ans += 5;
}
}
cout << ans << '\n';
}
}

0 comments on commit d32b104

Please sign in to comment.