よじろめ覚書

私の理解度重視のソースコードです。

2019-09-01から1ヶ月間の記事一覧

ABC077A - Rotation

ABC

問題:A - Rotation #include <algorithm> #include <iostream> #include <string> using namespace std; int main(void) { string c1, c2; cin.tie(0); ios::sync_with_stdio(false); cin >> c1; cin >> c2; reverse(c2.begin(), c2.end()); cout << (c1 == c2? "YES" : "NO") << "\n"; r</string></iostream></algorithm>…

ABC076B - Addition and Multiplication

ABC

#include <algorithm> #include <iostream> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void) { int n, k, ans = 1; cin.tie(0); ios::sync_with_stdio(false); cin >> n; cin >> k; REP(i, n) { ans = min(ans * 2, ans + k); } cout << an</iostream></algorithm>…

ABC076A - Rating Goal

ABC

問題:A - Rating Goal #include <iostream> using namespace std; int main(void) { int r, g; cin.tie(0); ios::sync_with_stdio(false); cin >> r; cin >> g; cout << (g * 2) - r << "\n"; return 0; }</iostream>

ABC075B - Minesweeper

ABC

問題:B - Minesweeper #include <iostream> #include <string> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int h, w; string s[50]; bool isRange(int y, int x) { if (y < 0 || h <= y || x < 0 || w <= x || s[y][x] == '#') { return false; }</string></iostream>…

ABC075A - One out of Three

ABC

問題:A - One out of Three #include <iostream> using namespace std; int main(void) { int a, b, c, ans; cin.tie(0); ios::sync_with_stdio(false); cin >> a >> b >> c; if (a == b) { ans = c; } else if(b == c) { ans = a; } else { ans = b; } cout << ans <</iostream>…

ABC074B - Collecting Balls (Easy Version)

ABC

問題:B - Collecting Balls (Easy Version) #include <iostream> using namespace std; #define REP(i, n) for (int i = 0; i <(n); ++i) int main(void) { int n, k, x[100], ans = 0; cin.tie(0); ios::sync_with_stdio(false); cin >> n; cin >> k; REP(i, n) { ci</iostream>…

ABC074A - Bichrome Cells

ABC

問題:A - Bichrome Cells #include <iostream> using namespace std; int main(void) { int n, a; cin.tie(0); ios::sync_with_stdio(false); cin >> n; cin >> a; cout << n * n - a << "\n"; return 0; }</iostream>

ABC073B - Theater

ABC

問題:B - Theater #include <iostream> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void) { int n, l, r, ans = 0; cin.tie(0); ios::sync_with_stdio(false); cin >> n; REP(i, n) { cin >> l >> r; ans += (r - l) + 1; } cou</iostream>…

ABC073A - September 9

ABC

問題:A - September 9 #include <iostream> using namespace std; int main(void) { int n; cin.tie(0); ios::sync_with_stdio(false); cin >> n; cout << (n / 10 == 9 || n % 10 == 9? "Yes" : "No") << "\n"; return 0; }</iostream>

ABC072B - OddString

ABC

問題:B - OddString #include <iostream> #include <string> using namespace std; int main(void) { string s, ans = ""; cin.tie(0); ios::sync_with_stdio(false); cin >> s; for (int i = 0; i < s.length(); i += 2) { ans += s[i]; } cout << ans << "\n"; return 0; }</string></iostream>

ABC072A - Sandglass2

ABC

問題:A - Sandglass2 #include <algorithm> #include <iostream> using namespace std; int main(void) { int x, t; cin.tie(0); ios::sync_with_stdio(false); cin >> x >> t; cout << max(0, x - t) << "\n"; return 0; }</iostream></algorithm>

ABC071B - Not Found

ABC

問題:B - Not Found #include <iostream> #include <string> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void) { string s, ans = ""; int cnt[26] = {0}, pos = 26; cin.tie(0); ios::sync_with_stdio(false); cin >> s; REP(i, s.leng</string></iostream>…

ABC071A - Meal Delivery

ABC

問題:A - Meal Delivery #include <algorithm> #include <cstdlib> #include <iostream> using namespace std; int main(void) { int x, a, b; cin.tie(0); ios::sync_with_stdio(false); cin >> x >> a >> b; cout << (abs(x - a) < abs(x - b)? "A" : "B") << "\n"; return 0; }</iostream></cstdlib></algorithm>

ABC070B - Two Switches

ABC

問題:B - Two Switches #include <algorithm> #include <iostream> using namespace std; int main(void) { int a, b, c, d; cin.tie(0); ios::sync_with_stdio(false); cin >> a >> b >> c >> d; cout << max(0, min(b, d) - max(a, c)) << "\n"; return 0; }</iostream></algorithm>

ABC070A - Palindromic Number

ABC

問題:A - Palindromic Number #include <iostream> using namespace std; int main(void) { int n; cin.tie(0); ios::sync_with_stdio(false); cin >> n; cout << (n / 100 == n % 10? "Yes" : "No") << "\n"; return 0; }</iostream>

ABC069B - i18n

ABC

問題:B - i18n #include <iostream> #include <string> using namespace std; int main(void) { string s; cin.tie(0); ios::sync_with_stdio(false); cin >> s; cout << s[0] << s.length() - 2 << s[s.length() - 1] << "\n"; return 0; }</string></iostream>

ABC069A - K-City

ABC

問題:A - K-City #include <iostream> using namespace std; int main(void) { int n, m; cin.tie(0); ios::sync_with_stdio(false); cin >> n >> m; cout << (n - 1) * (m - 1) << "\n"; return 0; }</iostream>

ABC068B - Break Number

ABC

問題:B - Break Number #include <algorithm> #include <iostream> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) #define BYTE 8 int main(void) { int n, ans = 0; cin.tie(0); ios::sync_with_stdio(false); cin >> n; REP(i, BYTE) { if (n >= (1 <</iostream></algorithm>…

ABC068A - ABCxxx

ABC

問題:A - ABCxxx #include <iostream> using namespace std; int main(void) { int n; cin.tie(0); ios::sync_with_stdio(false); cin >> n; cout << "ABC" << n << "\n"; return 0; }</iostream>

ABC067B - Snake Toy

ABC

問題:B - Snake Toy #include <algorithm> #include <functional> #include <iostream> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void) { int n, k, l[50], ans = 0; cin.tie(0); ios::sync_with_stdio(false); cin >> n >> k; REP(i, n) { cin >> l[</iostream></functional></algorithm>…

ABC067A - Sharing Cookies

ABC

問題:A - Sharing Cookies #include <iostream> using namespace std; int main(void) { int a, b; cin.tie(0); ios::sync_with_stdio(false); cin >> a >> b; cout << ((a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)? "Possible" : "Impossible") << "\n"; return</iostream>…

ABC066B - ss

ABC

問題:B - ss #include <iostream> #include <string> using namespace std; int main(void) { string s; int ans = 0; cin.tie(0); ios::sync_with_stdio(false); cin >> s; for (int i = s.length() - 2; i >= 0; i -= 2) { if (s.substr(0, i / 2) == s.substr(i / 2, i / 2</string></iostream>…

ABC066A - ringring

ABC

問題:A - ringring #include <algorithm> #include <iostream> using namespace std; int main(void) { int a, b, c; cin.tie(0); ios::sync_with_stdio(false); cin >> a >> b >> c; cout << min(a + b, min(b + c, c + a)) << "\n"; return 0; }</iostream></algorithm>

ABC065B - Trained?

ABC

問題:B - Trained? #include <iostream> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) #define MAX (int)1e+5 int main(void) { int n, a[MAX], cnt = -1, pos = 0; cin.tie(0); ios::sync_with_stdio(false); cin >> n; REP(i, n) { cin ></iostream>…

ABC065A - Expired?

ABC

問題:A - Expired? #include <iostream> using namespace std; int main(void) { const string result[3] = {"dangerous", "safe", "delicious"}; int x, a, b, taste = 0; cin.tie(0); ios::sync_with_stdio(false); cin >> x >> a >> b; if (x < b - a) { taste = 0</iostream>…

ABC064B - Traveling AtCoDeer Problem

ABC

問題:B - Traveling AtCoDeer Problem #include <algorithm> #include <iostream> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) #define INF (1 << 30) int main(void) { int n, a, min_a = INF, max_a = 0; cin.tie(0); ios::sync_with_stdio(false);</iostream></algorithm>…

ABC064A - RGB Cards

ABC

問題:A - RGB Cards #include <iostream> using namespace std; int main(void) { int r, g, b; cin.tie(0); ios::sync_with_stdio(false); cin >> r >> g >> b; cout << ((r * 100 + g * 10 + b) % 4 == 0? "YES" : "NO") << "\n"; return 0; }</iostream>

ABC063B - Varied

ABC

問題:B - Varied #include <iostream> #include <string> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void) { string s; bool findFlg = false, usedFlg[26] = {false}; cin.tie(0); ios::sync_with_stdio(false); cin >> s; REP(i, s.l</string></iostream>…

ABC063A - Restricted

ABC

問題:A - Restricted #include <iostream> using namespace std; int main(void) { int a, b; cin.tie(0); ios::sync_with_stdio(false); cin >> a >> b; if (a + b >= 10) { cout << "error" << "\n"; } else { cout << a + b << "\n"; } return 0; }</iostream>