Submission #3081373
Source Code Expand
#include<cstdio> #include<cstring> #include<cmath> #include<bitset> #include<iostream> #include<algorithm> #include<string> #include<utility> #include<tuple> #include<vector> #include<list> #include<map> #include<set> #include<queue> #include<stack> #include<numeric> #include<functional> #include<iomanip> #include<random> #define IOS ios::sync_with_stdio(false),cin.tie(0) #define REP(i,n) for(int i = 0;i < n;i++) #define FOR(i,a,b) for(int i = a;i < b;i++) #define MEM(a,b) memset(a,b,sizeof(a)) #define ALL(x) (x).begin(),(x).end() #define LMAX 9223372036854775807 #define LMIN -9223372036854775808 using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<ll, ll> P; struct UnionFind { vector<int> data; UnionFind(int size) : data(size, -1) {} void unionSet(int x, int y) { x = root(x), y = root(y); if (x != y) { if (data[y] < data[x])swap(x, y); data[x] += data[y]; data[y] = x; } } bool findSet(int x, int y) { return root(x) == root(y); } int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); } int size(int x) { return -data[root(x)]; } }; ll gcd(ll a, ll b) { if (a < b)swap(a, b); int k = a % b; if (k == 1)return 1; if (k == 0)return b; int ans = gcd(b, k); return ans; } ll digisum(ll a) { int sum = 0; while (a) { sum += a % 10; a /= 10; } return sum; } ll countpow(ll a, ll b) { int ans = 0; if (b == 0)return -1; while (1) { if (a % b == 0) { a /= b; ans++; } else break; } return ans; } int to_num(char c) { if (c >= '0' && c <= '9')return (c - '0'); else return -1; } int main() { IOS; int n, a, b; cin >> n >> a >> b; int ans = 0; REP(i, n) { string s; int d; cin >> s >> d; if (s == "East") { if (d < a)ans += a; else if (d > b) ans += b; else ans += d; } else { if (d < a)ans -= a; else if (d > b) ans -= b; else ans -= d; } } if (ans == 0)cout << 0 << endl; else { if (ans > 0)cout << "East " << ans << endl; else cout << "West " << -ans << endl; } }
Submission Info
Submission Time | |
---|---|
Task | B - 双子とスイカ割り |
User | jgvt5ti |
Language | C++14 (GCC 5.4.1) |
Score | 100 |
Code Size | 2147 Byte |
Status | AC |
Exec Time | 1 ms |
Memory | 256 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 100 / 100 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample-01.txt, sample-02.txt, sample-03.txt |
All | sample-01.txt, sample-02.txt, sample-03.txt, test-01.txt, test-02.txt, test-03.txt, test-04.txt, test-05.txt, test-06.txt, test-07.txt, test-08.txt, test-09.txt, test-10.txt, test-11.txt, test-12.txt, test-13.txt, test-14.txt, test-15.txt, test-16.txt, test-17.txt, test-18.txt, test-19.txt, test-20.txt, test-21.txt, test-22.txt, test-23.txt, test-24.txt, test-25.txt, test-26.txt, test-27.txt, test-28.txt, test-29.txt, test-30.txt, sample-01.txt, sample-02.txt, sample-03.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample-01.txt | AC | 1 ms | 256 KB |
sample-02.txt | AC | 1 ms | 256 KB |
sample-03.txt | AC | 1 ms | 256 KB |
test-01.txt | AC | 1 ms | 256 KB |
test-02.txt | AC | 1 ms | 256 KB |
test-03.txt | AC | 1 ms | 256 KB |
test-04.txt | AC | 1 ms | 256 KB |
test-05.txt | AC | 1 ms | 256 KB |
test-06.txt | AC | 1 ms | 256 KB |
test-07.txt | AC | 1 ms | 256 KB |
test-08.txt | AC | 1 ms | 256 KB |
test-09.txt | AC | 1 ms | 256 KB |
test-10.txt | AC | 1 ms | 256 KB |
test-11.txt | AC | 1 ms | 256 KB |
test-12.txt | AC | 1 ms | 256 KB |
test-13.txt | AC | 1 ms | 256 KB |
test-14.txt | AC | 1 ms | 256 KB |
test-15.txt | AC | 1 ms | 256 KB |
test-16.txt | AC | 1 ms | 256 KB |
test-17.txt | AC | 1 ms | 256 KB |
test-18.txt | AC | 1 ms | 256 KB |
test-19.txt | AC | 1 ms | 256 KB |
test-20.txt | AC | 1 ms | 256 KB |
test-21.txt | AC | 1 ms | 256 KB |
test-22.txt | AC | 1 ms | 256 KB |
test-23.txt | AC | 1 ms | 256 KB |
test-24.txt | AC | 1 ms | 256 KB |
test-25.txt | AC | 1 ms | 256 KB |
test-26.txt | AC | 1 ms | 256 KB |
test-27.txt | AC | 1 ms | 256 KB |
test-28.txt | AC | 1 ms | 256 KB |
test-29.txt | AC | 1 ms | 256 KB |
test-30.txt | AC | 1 ms | 256 KB |