buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
change_count
int64
0
100
#include <algorithm> #include <bitset> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> #define REP(i, b, n) for (int i = b; i < n; ++i) #define REPR(i, b, n) for (int i = n - 1; i >= b; --i) #define CLR(mat) memset(mat, 0, sizeof(mat)) #define NCLR(mat) memset(mat, -1, sizeof(mat)) #define EACH(i, c) \ for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i) #define EXIST(s, e) ((s).find(e) != (s).end()) #define BIT(n, b) ((n >> b) & 1) #define PI acos(-1.0) using namespace std; static const double EPS = 1e-9; typedef pair<int, int> pii; typedef long long ll; int mday[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; string week[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}; int main() { int m, d; while (cin >> m >> d, (m || d)) { int dsum = 3; for (int i = 0; i < m; ++i) { dsum += mday[i]; } cout << week[dsum % 7] << endl; } return 0; }
#include <algorithm> #include <bitset> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> #define REP(i, b, n) for (int i = b; i < n; ++i) #define REPR(i, b, n) for (int i = n - 1; i >= b; --i) #define CLR(mat) memset(mat, 0, sizeof(mat)) #define NCLR(mat) memset(mat, -1, sizeof(mat)) #define EACH(i, c) \ for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i) #define EXIST(s, e) ((s).find(e) != (s).end()) #define BIT(n, b) ((n >> b) & 1) #define PI acos(-1.0) using namespace std; static const double EPS = 1e-9; typedef pair<int, int> pii; typedef long long ll; int mday[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; string week[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}; int main() { int m, d; while (cin >> m >> d, (m || d)) { int dsum = d + 2; for (int i = 0; i < m; ++i) { dsum += mday[i]; } cout << week[dsum % 7] << endl; } return 0; }
[["-", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 31, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 17, 72], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13]]
1
258
4
#include <iostream> using namespace std; int day(int month) { switch (month) { case 4: case 6: case 9: case 11: return 30; break; case 1: case 3: case 5: case 7: case 8: case 10: case 12: return 31; break; case 2: return 18; break; } } int main() { int m, d, num; while (cin >> m >> d, m || d) { num = 0; for (int i = 1; i < m; i++) { num += day(i); } num += d; switch (num % 7) { case 1: cout << "Thursday" << endl; break; case 2: cout << "Friday" << endl; break; case 3: cout << "Saturday" << endl; break; case 4: cout << "Sunday" << endl; break; case 5: cout << "Monday" << endl; break; case 6: cout << "Tuesday" << endl; break; case 0: cout << "Wednesday" << endl; } } }
#include <iostream> using namespace std; int day(int month) { switch (month) { case 4: case 6: case 9: case 11: return 30; break; case 1: case 3: case 5: case 7: case 8: case 10: case 12: return 31; break; case 2: return 29; break; } } int main() { int m, d, num; while (cin >> m >> d, m || d) { num = 0; for (int i = 1; i < m; i++) { num += day(i); } num += d; switch (num % 7) { case 1: cout << "Thursday" << endl; break; case 2: cout << "Friday" << endl; break; case 3: cout << "Saturday" << endl; break; case 4: cout << "Sunday" << endl; break; case 5: cout << "Monday" << endl; break; case 6: cout << "Tuesday" << endl; break; case 0: cout << "Wednesday" << endl; } } }
[["-", 0, 99, 8, 9, 0, 100, 0, 37, 0, 13], ["+", 0, 99, 8, 9, 0, 100, 0, 37, 0, 13]]
1
226
2
#include <cmath> #include <iostream> #include <vector> using namespace std; typedef long long ll; const int MNUM = 12, leapMNUM = 12; const int ML[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; // day/month in usual year const int leapML[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; // day/month in leap year const string days[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursay", "Friday", "Saturday"}; struct date { int y, m, d; date(void) : y(0), m(1), d(1) {} date(int a, int b, int c) : y(a), m(b), d(c) {} bool isLeap(void) { if (y % 400 == 0) return true; if (y % 100 == 0) return false; if (y % 4 == 0) return true; return false; } date next(void) { d++; if (isLeap()) { if (leapML[m - 1] < d) { d = 1; m++; } if (leapMNUM < m) { m = 1; y++; } } else { if (ML[m - 1] < d) { d = 1; m++; } if (MNUM < m) { m = 1; y++; } } return *this; } bool operator==(const date x) const { return (y == x.y && m == x.m && d == x.d); } bool operator<(const date x) const { if (y != x.y) return y < x.y; if (m != x.m) return m < x.m; return d < x.d; } bool operator<=(const date x) const { return (*this == x || *this < x); } bool operator>(const date x) const { return !(*this <= x); } bool operator>=(const date x) const { return !(*this < x); } ll dayCount(void) const { date tmp; for (ll res = 0;; res++) { if (tmp == *this) return res; tmp.next(); } return 0; } ll operator-(const date x) const { return dayCount() - x.dayCount(); } // calculate days from Julian Day(-4713/01/01) using Fliegel's formula. ll Fliegel(void) { int a = (14 - m) / 12, Y = y + 4800 - a, M = m + 12 * a - 3; return (ll)d + (153 * M + 2) / 5 + 365 * Y + Y / 4 - Y / 100 + Y / 400 - 32045; } // calculate day of week using Zeller congruence. int Zeller(void) { int Y = y, M = m; if (M < 3) { Y--; M += 12; } return (Y + Y / 4 - Y / 100 + Y / 400 + (13 * M + 8) / 5 + d) % 7; } }; int main() { int m, d; while (cin >> m >> d, m || d) cout << days[date(2004, m, d).Zeller()] << endl; }
#include <cmath> #include <iostream> #include <vector> using namespace std; typedef long long ll; const int MNUM = 12, leapMNUM = 12; const int ML[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; // day/month in usual year const int leapML[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; // day/month in leap year const string days[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; struct date { int y, m, d; date(void) : y(0), m(1), d(1) {} date(int a, int b, int c) : y(a), m(b), d(c) {} bool isLeap(void) { if (y % 400 == 0) return true; if (y % 100 == 0) return false; if (y % 4 == 0) return true; return false; } date next(void) { d++; if (isLeap()) { if (leapML[m - 1] < d) { d = 1; m++; } if (leapMNUM < m) { m = 1; y++; } } else { if (ML[m - 1] < d) { d = 1; m++; } if (MNUM < m) { m = 1; y++; } } return *this; } bool operator==(const date x) const { return (y == x.y && m == x.m && d == x.d); } bool operator<(const date x) const { if (y != x.y) return y < x.y; if (m != x.m) return m < x.m; return d < x.d; } bool operator<=(const date x) const { return (*this == x || *this < x); } bool operator>(const date x) const { return !(*this <= x); } bool operator>=(const date x) const { return !(*this < x); } ll dayCount(void) const { date tmp; for (ll res = 0;; res++) { if (tmp == *this) return res; tmp.next(); } return 0; } ll operator-(const date x) const { return dayCount() - x.dayCount(); } // calculate days from Julian Day(-4713/01/01) using Fliegel's formula. ll Fliegel(void) { int a = (14 - m) / 12, Y = y + 4800 - a, M = m + 12 * a - 3; return (ll)d + (153 * M + 2) / 5 + 365 * Y + Y / 4 - Y / 100 + Y / 400 - 32045; } // calculate day of week using Zeller congruence. int Zeller(void) { int Y = y, M = m; if (M < 3) { Y--; M += 12; } return (Y + Y / 4 - Y / 100 + Y / 400 + (13 * M + 8) / 5 + d) % 7; } }; int main() { int m, d; while (cin >> m >> d, m || d) cout << days[date(2004, m, d).Zeller()] << endl; }
[["-", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6], ["+", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6]]
1
712
2
#include <iostream> using namespace std; main() { int month[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; string day[7] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"}; int n[2]; while (cin >> n[0] >> n[1], n[0], n[1]) { int sum = 0; for (int i = 0; i < n[0] - 1; ++i) { sum += month[i]; } sum += n[1]; cout << sum << endl << day[sum % 7] << endl; } }
#include <iostream> using namespace std; main() { int month[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; string day[7] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"}; int n[2]; while (cin >> n[0] >> n[1], n[0], n[1]) { int sum = 0; for (int i = 0; i < n[0] - 1; ++i) { sum += month[i]; } sum += n[1]; cout << day[sum % 7] << endl; } }
[["-", 0, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["-", 0, 1, 0, 16, 31, 16, 31, 16, 17, 151], ["-", 0, 1, 0, 16, 31, 16, 31, 16, 12, 22], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 17, 151]]
1
166
4
#include <fstream> #include <iostream> #include <stdio.h> #include <stdlib.h> #define _USE_MATH_DEFINES #include <algorithm> #include <cmath> #include <complex> #include <map> #include <math.h> #include <queue> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define li long long int #define rep(i, to) for (int i = 0; i < ((int)(to)); i++) #define repp(i, start, to) for (int i = (int)(start); i < ((int)(to)); i++) #define pb push_back #define sz(v) ((li)(v).size()) #define bgn(v) ((v).begin()) #define eend(v) ((v).end()) #define allof(v) (v).begin(), (v).end() #define dodp(v, n) memset(v, (li)n, sizeof(v)) #define bit(n) (1ll << (li)(n)) #define mp(a, b) make_pair(a, b) #define rin rep(i, n) #define EPS 1e-10 #define ETOL 1e-8 #define MOD 1000000007 #define F first #define S second #define p2(a, b) cout << a << "\t" << b << endl #define p3(a, b, c) cout << a << "\t" << b << "\t" << c << endl string yobi[7] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}; int main() { li m, d; li acum = 3; li day[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; while (1) { cin >> m >> d; if (min(m, d) == 0) break; rep(i, m - 1) acum += day[i]; acum += d - 1; cout << yobi[acum % 7] << endl; } return 0; }
#include <fstream> #include <iostream> #include <stdio.h> #include <stdlib.h> #define _USE_MATH_DEFINES #include <algorithm> #include <cmath> #include <complex> #include <map> #include <math.h> #include <queue> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define li long long int #define rep(i, to) for (int i = 0; i < ((int)(to)); i++) #define repp(i, start, to) for (int i = (int)(start); i < ((int)(to)); i++) #define pb push_back #define sz(v) ((li)(v).size()) #define bgn(v) ((v).begin()) #define eend(v) ((v).end()) #define allof(v) (v).begin(), (v).end() #define dodp(v, n) memset(v, (li)n, sizeof(v)) #define bit(n) (1ll << (li)(n)) #define mp(a, b) make_pair(a, b) #define rin rep(i, n) #define EPS 1e-10 #define ETOL 1e-8 #define MOD 1000000007 #define F first #define S second #define p2(a, b) cout << a << "\t" << b << endl #define p3(a, b, c) cout << a << "\t" << b << "\t" << c << endl string yobi[7] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}; int main() { li m, d; li acum = 3; li day[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; while (1) { acum = 3; cin >> m >> d; if (min(m, d) == 0) break; rep(i, m - 1) acum += day[i]; acum += d - 1; cout << yobi[acum % 7] << endl; } return 0; }
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
284
4
#include <iostream> using namespace std; int main(void) { int month; int day; int day2; while (1) { day2 = 0; cin >> month >> day; if (month == 0 && day == 0) break; for (int i = 1; i < month; i++) { switch (i) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: day2 += 31; break; case 2: day2 += 29; break; case 4: case 6: case 11: day2 += 30; break; } } day2 += day; switch (day2 % 7) { case 1: cout << "Thursday" << endl; break; case 2: cout << "Friday" << endl; break; case 3: cout << "Saturday" << endl; break; case 4: cout << "Sunday" << endl; break; case 5: cout << "Monday" << endl; break; case 6: cout << "Tuesday" << endl; break; case 0: cout << "Wednesday" << endl; } } return 0; }
#include <iostream> using namespace std; int main(void) { int month; int day; int day2; while (1) { day2 = 0; cin >> month >> day; if (month == 0 && day == 0) break; for (int i = 1; i < month; i++) { switch (i) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: day2 += 31; break; case 2: day2 += 29; break; case 4: case 6: case 9: case 11: day2 += 30; break; } } day2 += day; switch (day2 % 7) { case 1: cout << "Thursday" << endl; break; case 2: cout << "Friday" << endl; break; case 3: cout << "Saturday" << endl; break; case 4: cout << "Sunday" << endl; break; case 5: cout << "Monday" << endl; break; case 6: cout << "Tuesday" << endl; break; case 0: cout << "Wednesday" << endl; } } return 0; }
[["+", 8, 9, 0, 99, 8, 9, 0, 100, 51, 13], ["+", 8, 9, 0, 99, 8, 9, 0, 100, 0, 102], ["+", 8, 9, 0, 99, 8, 9, 0, 100, 0, 173]]
1
227
3
#include <iostream> using namespace std; const string str[] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"}; const int m[] = {0, 31, 29, 31, 29, 31, 30, 31, 31, 30, 31, 30, 31}; int main() { int mon, day; while (cin >> mon >> day, mon + day) { for (int i = 0; i < mon; i++) { day += m[i]; } cout << str[day % 7] << endl; } return 0; }
#include <iostream> using namespace std; const string str[] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"}; const int m[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int main() { int mon, day; while (cin >> mon >> day, mon + day) { for (int i = 0; i < mon; i++) { day += m[i]; } cout << str[day % 7] << endl; } return 0; }
[["-", 0, 30, 0, 43, 49, 50, 51, 83, 0, 13], ["+", 0, 30, 0, 43, 49, 50, 51, 83, 0, 13]]
1
138
2
#include <iostream> using namespace std; int main(void) { while (1) { int mon, day; cin >> mon; if (cin.eof()) break; cin >> day; for (int i = 1; i < mon; i++) { switch (i) { case 2: day += 29; break; case 4: case 6: case 9: case 11: day += 30; break; default: day += 31; break; } } switch (day % 7) { case 0: cout << "Wednesday" << endl; break; case 1: cout << "Thursday" << endl; break; case 2: cout << "Friday" << endl; break; case 3: cout << "Saturday" << endl; break; case 4: cout << "Sunday" << endl; break; case 5: cout << "Monday" << endl; break; case 6: cout << "Tuesday" << endl; break; } } return 0; }
#include <iostream> using namespace std; int main(void) { while (1) { int mon, day; cin >> mon; if (mon == 0) break; cin >> day; for (int i = 1; i < mon; i++) { switch (i) { case 2: day += 29; break; case 4: case 6: case 9: case 11: day += 30; break; default: day += 31; break; } } switch (day % 7) { case 0: cout << "Wednesday" << endl; break; case 1: cout << "Thursday" << endl; break; case 2: cout << "Friday" << endl; break; case 3: cout << "Saturday" << endl; break; case 4: cout << "Sunday" << endl; break; case 5: cout << "Monday" << endl; break; case 6: cout << "Tuesday" << endl; break; } } return 0; }
[["-", 0, 57, 15, 339, 51, 2, 63, 118, 28, 22], ["-", 0, 57, 15, 339, 51, 2, 63, 118, 17, 131], ["-", 0, 57, 15, 339, 51, 2, 63, 118, 119, 120], ["-", 0, 57, 15, 339, 51, 2, 3, 4, 0, 24], ["-", 0, 57, 15, 339, 51, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
201
8
#include <stdio.h> int main() { int y, d, m; int h; char *date[] = {"Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday"}; for (;;) { int Y, C, G; y = 2004; scanf("%d %d", &m, &d); if (d == 0 || m == 0) break; if (m == 1 || m == 2) { m += 12; y--; } Y = y % 100; C = y / 100; G = (-2 * C) + (C / 4); h = (d + (26 * (m + 1) / 10) + Y + Y / 4 + G) % 7; printf("%s\n", date[h]); } return 0; }
#include <stdio.h> int main() { int y, d, m; int h; char *date[] = {"Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday"}; for (;;) { int Y, C, G; y = 2004; scanf("%d %d", &m, &d); if (d == 0 || m == 0) break; if (m == 1 || m == 2) { m += 12; y--; } Y = y % 100; C = y / 100; G = 5 * C + C / 4; h = (d + (26 * (m + 1) / 10) + Y + Y / 4 + G) % 7; printf("%s\n", date[h]); } return 0; }
[["-", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["-", 0, 11, 12, 16, 31, 23, 0, 16, 31, 13], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 31, 13], ["-", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25], ["-", 0, 1, 0, 11, 12, 16, 12, 23, 0, 24], ["-", 0, 1, 0, 11, 12, 16, 12, 23, 0, 25]]
1
186
6
#include <iostream> #include <string> using namespace std; int main() { string youbi[7] = {"Wednesday", "Thursday", "Friday", "Suturday", "Sunday", "Monday", "Tuesday"}; int month[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int gathu, nichi; while (cin >> gathu >> nichi, gathu) { int keika = 0; for (int i = 0; i < gathu - 1; i++) { keika += month[i]; } keika += nichi; cout << youbi[keika % 7] << endl; } return 0; }
#include <iostream> #include <string> using namespace std; int main() { string youbi[7] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"}; int month[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int gathu, nichi; while (cin >> gathu >> nichi, gathu) { int keika = 0; for (int i = 0; i < gathu - 1; i++) { keika += month[i]; } keika += nichi; cout << youbi[keika % 7] << endl; } return 0; }
[["-", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6], ["+", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6]]
1
147
2
#include <iostream> #include <string> int day(int m, int d) { if (m == 1) return d; if (m == 2) return 31 + d; if (m == 3) return 60 + d; if (m == 4) return 91 + d; if (m == 5) return 121 + d; if (m == 6) return 152 + d; if (m == 7) return 182 + d; if (m == 8) return 213 + d; if (m == 9) return 244 + d; if (m == 10) return 274 + d; if (m == 11) return 305 + d; if (m == 12) return 366 - d; } int main() { while (1) { int m, d; std::cin >> m >> d; if (m == 0) return 0; std::string s; if (day(m, d) % 7 == 1) s = "Thursday"; if (day(m, d) % 7 == 2) s = "Friday"; if (day(m, d) % 7 == 3) s = "Saturday"; if (day(m, d) % 7 == 4) s = "Sunday"; if (day(m, d) % 7 == 5) s = "Monday"; if (day(m, d) % 7 == 6) s = "Tuesday"; if (day(m, d) % 7 == 0) s = "Wednesday"; std::cout << s << std::endl; } }
#include <iostream> #include <string> int day(int m, int d) { if (m == 1) return d; if (m == 2) return 31 + d; if (m == 3) return 60 + d; if (m == 4) return 91 + d; if (m == 5) return 121 + d; if (m == 6) return 152 + d; if (m == 7) return 182 + d; if (m == 8) return 213 + d; if (m == 9) return 244 + d; if (m == 10) return 274 + d; if (m == 11) return 305 + d; if (m == 12) return 335 + d; } int main() { while (1) { int m, d; std::cin >> m >> d; if (m == 0) return 0; std::string s; if (day(m, d) % 7 == 1) s = "Thursday"; if (day(m, d) % 7 == 2) s = "Friday"; if (day(m, d) % 7 == 3) s = "Saturday"; if (day(m, d) % 7 == 4) s = "Sunday"; if (day(m, d) % 7 == 5) s = "Monday"; if (day(m, d) % 7 == 6) s = "Tuesday"; if (day(m, d) % 7 == 0) s = "Wednesday"; std::cout << s << std::endl; } }
[["-", 8, 9, 0, 57, 64, 37, 0, 16, 31, 13], ["-", 8, 9, 0, 57, 64, 37, 0, 16, 17, 33], ["+", 8, 9, 0, 57, 64, 37, 0, 16, 31, 13], ["+", 8, 9, 0, 57, 64, 37, 0, 16, 17, 72]]
1
327
4
#include <cstdio> #include <iostream> int main(int argc, const char *argv[]) { int month[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int m, d; while (scanf("%d %d", &m, &d) != 0) { int cnt = 0; if (m == 0 && d == 0) { return 0; } for (int i = 0; i < m - 1; i++) { cnt += month[m - 2]; } cnt += d; if (cnt % 7 == 0) { printf("Wednesday\n"); } if (cnt % 7 == 1) { printf("Thursday\n"); } if (cnt % 7 == 2) { printf("Friday\n"); } if (cnt % 7 == 3) { printf("Saturday\n"); } if (cnt % 7 == 4) { printf("Sunday\n"); } if (cnt % 7 == 5) { printf("Monday\n"); } if (cnt % 7 == 6) { printf("Tuesday\n"); } } return 0; }
#include <cstdio> #include <iostream> int main(int argc, const char *argv[]) { int month[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int m, d; while (scanf("%d %d", &m, &d) != 0) { int cnt = 0; if (m == 0 && d == 0) { return 0; } for (int i = 0; i < m - 1; i++) { cnt += month[i]; } cnt += d; if (cnt % 7 == 0) { printf("Wednesday\n"); } if (cnt % 7 == 1) { printf("Thursday\n"); } if (cnt % 7 == 2) { printf("Friday\n"); } if (cnt % 7 == 3) { printf("Saturday\n"); } if (cnt % 7 == 4) { printf("Sunday\n"); } if (cnt % 7 == 5) { printf("Monday\n"); } if (cnt % 7 == 6) { printf("Tuesday\n"); } } return 0; }
[["-", 0, 11, 12, 69, 341, 342, 0, 16, 31, 22], ["-", 0, 11, 12, 69, 341, 342, 0, 16, 17, 33], ["-", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13], ["+", 0, 1, 0, 11, 12, 69, 341, 342, 0, 22]]
1
255
4
#include <stdio.h> int main() { int m, d; int i; int Days; while (1) { Days = 0; scanf("%d %d", &m, &d); if (m == 0 && d == 0) break; for (i = 1, Days += d; i < m; i++) { if (i == 2) { Days += 29; } else if (i == 4 || i == 6 || i == 9 || i == 11) { Days += 30; } else { Days += 31; } } switch (Days % 7) { case 0: printf("Wednesday\n"); break; case 1: printf("Thusrday\n"); break; case 2: printf("Friday\n"); break; case 3: printf("Saturday\n"); break; case 4: printf("Sunday\n"); break; case 5: printf("Monday\n"); break; case 6: printf("Tuesday\n"); break; } } return 0; }
#include <stdio.h> int main() { int m, d; int i; int Days; while (1) { Days = 0; scanf("%d %d", &m, &d); if (m == 0 && d == 0) break; for (i = 1, Days += d; i < m; i++) { if (i == 2) { Days += 29; } else if (i == 4 || i == 6 || i == 9 || i == 11) { Days += 30; } else { Days += 31; } } switch (Days % 7) { case 0: printf("Wednesday\n"); break; case 1: printf("Thursday\n"); break; case 2: printf("Friday\n"); break; case 3: printf("Saturday\n"); break; case 4: printf("Sunday\n"); break; case 5: printf("Monday\n"); break; case 6: printf("Tuesday\n"); break; } } return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
219
2
loop{ input = gets.chomp h = 20.0 y = 4.0 m,d = input.split(" ").map{|e| e.to_f} exit if m==0 and d==0 if m==1 or m==2 then m+=12 y-=1 end w=y+(y/4).floor+(h/4).floor-2*h+(13*(m+1)/5).floor+d w=w.to_i r=w % 7 case r when 1 then puts "Sunday" when 2 then puts "Monday" when 3 then puts "Trueday" when 4 then puts "Wednesday" when 5 then puts "Thursday" when 6 then puts "Friday" when 0 then puts "Saturday" end }
loop{ input = gets.chomp h = 20.0 y = 4.0 m,d = input.split(" ").map{|e| e.to_f} exit if m==0 and d==0 if m==1 or m==2 then m+=12 y-=1 end w=y+(y/4).floor+(h/4).floor-2*h+(13*(m+1)/5).floor+d w=w.to_i r=w % 7 case r when 1 then puts "Sunday" when 2 then puts "Monday" when 3 then puts "Tuesday" when 4 then puts "Wednesday" when 5 then puts "Thursday" when 6 then puts "Friday" when 0 then puts "Saturday" end }
[["-", 8, 749, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 8, 749, 0, 652, 3, 4, 0, 557, 0, 6]]
4
162
2
require "date" YEAR = 2004 WDAY = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"] while true m, d = gets.split.map(&:to_i) break if m == 0 && d == 0 puts WDAY[Date.new(YEAR, m, d).wday] end
require "date" YEAR = 2004 WDAY = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] while true m, d = gets.split.map(&:to_i) break if m == 0 && d == 0 puts WDAY[Date.new(YEAR, m, d).wday] end
[["+", 0, 493, 0, 662, 12, 516, 0, 557, 0, 6], ["+", 0, 493, 0, 662, 12, 516, 0, 557, 0, 62], ["+", 36, 36, 0, 493, 0, 662, 12, 516, 0, 21], ["-", 0, 493, 0, 662, 12, 516, 0, 557, 0, 62], ["-", 36, 36, 0, 493, 0, 662, 12, 516, 0, 21], ["-", 0, 493, 0, 662, 12, 516, 0, 557, 0, 6]]
4
79
8
class WhatDayIsToday def initialize init_ndays init_week init_calendar end def init_ndays @ndays = Array.new(12, 31) @ndays[1] = 29 @ndays[3] = @ndays[5] = @ndays[8] = @ndays[10] = 31 end def init_week @week = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"] end def init_calendar c = 3 @calendar = [] 12.times do |i| temp = [] @ndays[i].times do |j| temp.push @week[c % 7] c += 1 end @calendar.push temp end end def what_day(month, day) @calendar[month - 1][day - 1] end end calendar = WhatDayIsToday.new while line = gets do month, day = line.chomp.split(" ").map(&:to_i) break if month == 0 puts calendar.what_day(month, day) end
class WhatDayIsToday def initialize init_ndays init_week init_calendar end def init_ndays @ndays = Array.new(12, 31) @ndays[1] = 29 @ndays[3] = @ndays[5] = @ndays[8] = @ndays[10] = 30 end def init_week @week = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"] end def init_calendar c = 3 @calendar = [] 12.times do |i| temp = [] @ndays[i].times do |j| temp.push @week[c % 7] c += 1 end @calendar.push temp end end def what_day(month, day) @calendar[month - 1][day - 1] end end calendar = WhatDayIsToday.new while line = gets do month, day = line.chomp.split(" ").map(&:to_i) break if month == 0 puts calendar.what_day(month, day) end
[["-", 0, 662, 12, 662, 12, 662, 12, 662, 12, 612], ["+", 0, 662, 12, 662, 12, 662, 12, 662, 12, 612]]
4
196
2
#!/usr/bin/ruby Time.new(2004, *$_.split.map(&:to_i)).strftime("%A") while gets != "0 0\n"
#!/usr/bin/ruby puts Time.new(2004, *$_.split.map(&:to_i)).strftime("%A") while gets != "0 0\n"
[["+", 36, 36, 0, 493, 0, 740, 8, 652, 735, 22]]
4
32
1
require "date" arr = Array.new until (line = gets) == "0 0\n" arr << line end arr.each do |i| a = i.split(" ") a.map!{|j| j.to_i} m = a[0] d = a[1] wday = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Satarday"] day = Date::new(2004, m, d) puts wday[day.wday] end
require "date" arr = Array.new until (line = gets) == "0 0\n" arr << line end arr.each do |i| a = i.split(" ") a.map!{|j| j.to_i} m = a[0] d = a[1] wday = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] day = Date::new(2004, m, d) puts wday[day.wday] end
[["-", 8, 736, 0, 662, 12, 516, 0, 557, 0, 6], ["+", 8, 736, 0, 662, 12, 516, 0, 557, 0, 6]]
4
115
2
# AOJ 0027 What day is today? days_in_a_month = [31, 29, 30, 30, 31, 30, 31, 31, 30, 31, 30, 31] offset = [] days_in_a_month.each.with_index do |d, m| offset[m] = m.zero? ? 0 : days_in_a_month[0..(m - 1)].reduce(0, :+) end the_day = %w[Thursday Friday Saturday Sunday Monday Tuesday Wednesday] loop do month, day = gets.split.map(&:to_i) break if month.zero? && day.zero? days = offset[month - 1] + (day - 1) puts the_day[days % 7] end
# AOJ 0027 What day is today? days_in_a_month = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] offset = [] days_in_a_month.each.with_index do |d, m| offset[m] = m.zero? ? 0 : days_in_a_month[0..(m - 1)].reduce(0, :+) end the_day = %w[Thursday Friday Saturday Sunday Monday Tuesday Wednesday] loop do month, day = gets.split.map(&:to_i) break if month.zero? && day.zero? days = offset[month - 1] + (day - 1) puts the_day[days % 7] end
[["-", 36, 36, 0, 493, 0, 662, 12, 516, 0, 612], ["+", 36, 36, 0, 493, 0, 662, 12, 516, 0, 612]]
4
129
2
days=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'] dom=[31,29,31,30,31,60,31,31,30,31,30,31] while True: try: try: (m,d)=list(map(int,input().split())) except: break if m==0 and d==0: break day=4-1 for i in range(m-1): day+=dom[i] day+=d print(days[day%7]) except EOFError: break
days=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'] dom=[31,29,31,30,31,30,31,31,30,31,30,31] while True: try: try: (m,d)=list(map(int,input().split())) except: break if m==0 and d==0: break day=4-1 for i in range(m-1): day+=dom[i] day+=d print(days[day%7]) except EOFError: break
[["-", 0, 656, 0, 1, 0, 662, 12, 634, 0, 612], ["+", 0, 656, 0, 1, 0, 662, 12, 634, 0, 612]]
5
136
2
days_sum={1:31,2:29,3:31,4:30,5:31,6:30,7:31,8:31,9:30, 10:31,11:30,12:31} days2month={1:'Thursday',2:'Friday',3:'Saturday',4:'Sunday', 5:'Monday',6:'Tuesday',7:'Wednesday'} while True: month,day=list(map(int,input().split(" "))) if month==0 and day==0: break keika=0 for i in range(1,month): keika += days_sum[i] keika+=day print(days2month[keika%7])
days_sum={1:31,2:29,3:31,4:30,5:31,6:30,7:31,8:31,9:30, 10:31,11:30,12:31} days2month={1:'Thursday',2:'Friday',3:'Saturday',4:'Sunday', 5:'Monday',6:'Tuesday',0:'Wednesday'} while True: month,day=list(map(int,input().split(" "))) if month==0 and day==0: break keika=0 for i in range(1,month): keika += days_sum[i] keika+=day print(days2month[keika%7])
[["-", 0, 1, 0, 662, 12, 680, 0, 569, 448, 612], ["+", 0, 1, 0, 662, 12, 680, 0, 569, 448, 612]]
5
162
2
import sys import math dayy = [0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] def days(a, day): if a == 0: return day else: return days(a-1, day + dayy[a]) while True: inp = input().split() ii = int(inp[0]) jj = int(inp[1]) if ii == 0 and jj== 0: break ans = days(ii-1, 0) + jj print(ans) ans = ans % 7 if ans == 1: print("Thursday") continue if ans == 2: print("Friday") continue if ans == 3: print("Saturday") continue if ans == 4: print("Sunday") continue if ans == 5: print("Monday") continue if ans == 6: print("Tuesday") continue if ans == 0: print("Wedneday") continue
import sys import math dayy = [0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] def days(a, day): if a == 0: return day else: return days(a-1, day + dayy[a]) while True: inp = input().split() ii = int(inp[0]) jj = int(inp[1]) if ii == 0 and jj== 0: break ans = days(ii-1, 0) + jj ans = ans % 7 if ans == 1: print("Thursday") continue if ans == 2: print("Friday") continue if ans == 3: print("Saturday") continue if ans == 4: print("Sunday") continue if ans == 5: print("Monday") continue if ans == 6: print("Tuesday") continue if ans == 0: print("Wednesday") continue
[["-", 0, 52, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25], ["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6]]
5
209
6
month = [31, 30, 29, 30, 31, 30, 31, 31, 30, 31, 30, 31] day = ['Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday', 'Monday', 'Tuesday'] while True: m, d = map(int, input().split()) if m == 0: break print(day[(sum(month[:m - 1]) + d) % 7])
month = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30] day = ['Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday', 'Monday', 'Tuesday'] while True: m, d = map(int, input().split()) if m == 0: break print(day[(sum(month[:m - 1]) + d) % 7])
[["-", 0, 656, 0, 1, 0, 662, 12, 634, 0, 612], ["-", 0, 656, 0, 1, 0, 662, 12, 634, 0, 21], ["+", 0, 656, 0, 1, 0, 662, 12, 634, 0, 21], ["+", 0, 656, 0, 1, 0, 662, 12, 634, 0, 612]]
5
105
6
# -*- coding: utf-8 -*- import sys days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Satday"] while True: ans = 3 m, d = list(map(int, input().split())) if m == 0: break for i in range(1, m): if i == 2: ans = (ans+1)%7 elif i == 4 or i == 6 or i == 9 or i == 11: ans = (ans+2)%7 else: ans = (ans+3)%7 ans = (ans+d)%7 print(days[ans])
# -*- coding: utf-8 -*- import sys days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] while True: ans = 3 m, d = list(map(int, input().split())) if m == 0: break for i in range(1, m): if i == 2: ans = (ans+1)%7 elif i == 4 or i == 6 or i == 9 or i == 11: ans = (ans+2)%7 else: ans = (ans+3)%7 ans = (ans+d)%7 print(days[ans])
[["-", 0, 1, 0, 662, 12, 634, 0, 557, 0, 6], ["+", 0, 1, 0, 662, 12, 634, 0, 557, 0, 6]]
5
142
2
days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] nums = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] while True: try: m, d = map(int, input().split()) if not m: break except: break print(days[(sum(nums[:m - 1]) + d) % 7 + 2])
days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] nums = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] while True: try: m, d = map(int, input().split()) if not m: break except: break print(days[(sum(nums[:m - 1]) + d + 2) % 7])
[["+", 0, 206, 206, 657, 31, 23, 0, 657, 17, 72], ["+", 0, 206, 206, 657, 31, 23, 0, 657, 12, 612], ["-", 0, 652, 3, 4, 0, 206, 206, 657, 17, 72], ["-", 0, 652, 3, 4, 0, 206, 206, 657, 12, 612]]
5
111
4
import math def Wit(y,m,d): if m == 1 or m == 2: y -= 1 m += 12 e = math.floor((26 * (m + 1)) / 10) Y = y % 100 C = math.floor(y / 100) f = math.floor(C / 4) g = math.floor(Y / 4) h = d + e + Y + f + g - 2 * C h = int(h % 7) return h while True: y = 2004 m,d = map(int,input().split()) if m == 0 and d == 0: break You = Wit(y,m,d) if You == 1: print("Sunday") elif You == 2: print("Tuesday") elif You == 3: print("Monday") elif You == 4: print("Wednesday") elif You == 5: print("Thursday") elif You == 6: print("Friday") elif You == 0: print("Saturday")
import math def Wit(y,m,d): if m == 1 or m == 2: y -= 1 m += 12 e = math.floor((26 * (m + 1)) / 10) Y = y % 100 C = math.floor(y / 100) f = math.floor(C / 4) g = math.floor(Y / 4) h = d + e + Y + f + g + 5 * C h = int(h % 7) return h while True: y = 2004 m,d = map(int,input().split()) if m == 0 and d == 0: break You = Wit(y,m,d) if You == 1: print("Sunday") elif You == 3: print("Tuesday") elif You == 2: print("Monday") elif You == 4: print("Wednesday") elif You == 5: print("Thursday") elif You == 6: print("Friday") elif You == 0: print("Saturday")
[["-", 8, 196, 0, 1, 0, 662, 12, 657, 17, 33], ["-", 0, 1, 0, 662, 12, 657, 12, 657, 31, 612], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 17, 72], ["+", 0, 1, 0, 662, 12, 657, 12, 657, 31, 612], ["-", 8, 196, 0, 57, 75, 665, 15, 666, 0, 612], ["+", 8, 196, 0, 57, 75, 665, 15, 666, 0, 612]]
5
224
8
from datetime import date week=["Monday","Trueday","Wednesday","Thursday","Friday","Saturday","Sunday"] while True: a,b=map(int,input().split()) if a==0: break print(week[date(2004,a,b).weekday()])
from datetime import date week=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"] while True: a,b=map(int,input().split()) if a==0: break print(week[date(2004,a,b).weekday()])
[["-", 0, 1, 0, 662, 12, 634, 0, 557, 0, 6], ["+", 0, 1, 0, 662, 12, 634, 0, 557, 0, 6]]
5
78
2
month, day = list(map(int, input().split())) days = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] youbi = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] while month != 0: Days = 0 for i in range(month - 1): Days += days[i] Days += day print(youbi[(Days+4) % 7]) month, day = list(map(int, input().split()))
month, day = list(map(int, input().split())) days = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] youbi = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] while month != 0: Days = 0 for i in range(month - 1): Days += days[i] Days += day print(youbi[(Days + 3) % 7]) month, day = list(map(int, input().split()))
[["-", 0, 206, 206, 657, 31, 23, 0, 657, 12, 612], ["+", 0, 206, 206, 657, 31, 23, 0, 657, 12, 612]]
5
136
2
import datetime date_list = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"] while True: m, d = map(int, input().split()) if m == 0 and d == 0: break print(date_list[datetime.date(204, m, d).weekday()])
import datetime date_list = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"] while True: m, d = map(int, input().split()) if m == 0 and d == 0: break print(date_list[datetime.date(2004, m, d).weekday()])
[["-", 206, 652, 63, 319, 500, 652, 3, 4, 0, 612], ["+", 206, 652, 63, 319, 500, 652, 3, 4, 0, 612]]
5
82
2
s = (0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30) w = ("Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday") while True: m, d = map(int, input().split()) if m == 0:break print(w[(d + sum(s[:m])) % 7])
s = (0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30) w = ("Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday") while True: m, d = map(int, input().split()) if m == 0:break print(w[(d + sum(s[:m])) % 7])
[["+", 0, 656, 0, 1, 0, 662, 12, 660, 0, 21], ["+", 0, 1, 0, 662, 12, 660, 0, 557, 0, 654], ["+", 0, 1, 0, 662, 12, 660, 0, 557, 0, 6], ["+", 0, 1, 0, 662, 12, 660, 0, 557, 0, 655]]
5
99
4
def day(Y, m, d, Gregorian=True): from math import floor # ツェラーの公式 if m <= 2: Y -= 1 m += 12 y = Y%100 c = Y//100 g = 5*c+floor(c/4) if Gregorian else 5-c return (d + floor(26*(m+1)/10) + y + floor(y/4) + g) %7 # 0->土曜, 6->金曜 day_en = ["Saturday", "Sunday", "Minday", "Tuesday", "Wednesday", "Thursday", "Friday"] while True: m, d = map(int, input().split()) if m == 0: break print(day_en[day(2004, m, d)])
def day(Y, m, d, Gregorian=True): from math import floor # ツェラーの公式 if m <= 2: Y -= 1 m += 12 y = Y%100 c = Y//100 g = 5*c+floor(c/4) if Gregorian else 5-c return (d + floor(26*(m+1)/10) + y + floor(y/4) + g) %7 # 0->土曜, 6->金曜 day_en = ["Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday"] while True: m, d = map(int, input().split()) if m == 0: break print(day_en[day(2004, m, d)])
[["-", 0, 1, 0, 662, 12, 634, 0, 557, 0, 6], ["+", 0, 1, 0, 662, 12, 634, 0, 557, 0, 6]]
5
159
2
day = ["Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"] month = [31, 29, 30, 31, 30, 31, 31, 30, 31, 30, 31] while True: m, d = list(map(int, input().split())) if m == d == 0: break print(day[(sum(month[0:m-1]) + d - 1) % 7])
day = ["Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"] month = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] while True: m, d = list(map(int, input().split())) if m == d == 0: break print(day[(sum(month[0:m-1]) + d - 1) % 7])
[["+", 0, 656, 0, 1, 0, 662, 12, 634, 0, 612], ["+", 0, 656, 0, 1, 0, 662, 12, 634, 0, 21]]
5
111
2
wd=["Mon","Tues","Wednes","Thurs","Fri","Satur","Sun"] md=[0,31,29,31,30,31,30,31,31,30,31,30,31] while True: m,d = list(map(int, input().split())) if m==0: break s = sum([md[i] for i in range(month)]) + day + 2 s = wd[s % 7]+"day" print(s)
wd=["Mon","Tues","Wednes","Thurs","Fri","Satur","Sun"] md=[0,31,29,31,30,31,30,31,31,30,31,30,31] while True: m,d = list(map(int, input().split())) if m==0: break s = sum([md[i] for i in range(m)]) + d + 2 s = wd[s % 7]+"day" print(s)
[["-", 0, 658, 0, 659, 12, 652, 3, 4, 0, 22], ["+", 0, 658, 0, 659, 12, 652, 3, 4, 0, 22], ["-", 0, 1, 0, 662, 12, 657, 31, 657, 12, 22], ["+", 0, 1, 0, 662, 12, 657, 31, 657, 12, 22]]
5
126
4
y = [31,29,31,30,31,30,31,31,30,31,30,31] dow = {0:"Monday", 1:"Thuesday", 2:"Wednesday", 3:"Thursday", 4:"Friday", 5:"Saturday", 6:"Sunday"} while True: m, d = list(map(int, input().split())) if m == 0 and d == 0: break n = 0 for i in range(m): n += y[i] n -= (y[m-1]-d+1) print(dow[(n+3)%7])
y = [31,29,31,30,31,30,31,31,30,31,30,31] dow = {0:"Monday", 1:"Tuesday", 2:"Wednesday", 3:"Thursday", 4:"Friday", 5:"Saturday", 6:"Sunday"} while True: m, d = list(map(int, input().split())) if m == 0 and d == 0: break n = 0 for i in range(m): n += y[i] n -= (y[m-1]-d+1) print(dow[(n+3)%7])
[["-", 0, 662, 12, 680, 0, 569, 51, 557, 0, 6], ["+", 0, 662, 12, 680, 0, 569, 51, 557, 0, 6]]
5
148
2
#include <stdio.h> int main() { char ch; int num, max; int p[10] = {0}; int q[2][10] = {0}; while (scanf("%d", &num) != EOF) { p[num] += 1; } max = 0; for (int i = 0; i < 10; i++) { if (max < p[i]) max = p[i]; } for (int i = 0; i < 10; i++) { if (max == p[i]) printf("%d\n", i); } return 0; }
#include <stdio.h> int main() { char ch; int num, max; int p[101] = {0}; int q[2][10] = {0}; while (scanf("%d", &num) != EOF) { p[num] += 1; } max = 0; for (int i = 0; i < 101; i++) { if (max < p[i]) max = p[i]; } for (int i = 0; i < 101; i++) { if (max == p[i]) printf("%d\n", i); } return 0; }
[["-", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13], ["+", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]]
1
136
6
#include <iostream> #include <stdio.h> #include <string.h> using namespace std; int a[100]; int main(void) { int n; int max = 0; for (int i = 0; i < 100; i++) a[i] = 0; while (scanf("%d", &n) != EOF) { a[n]++; } for (int i = 0; i < 100; i++) { if (a[i] > max) max = a[i]; } for (int i = 0; i < 100; i++) { if (a[i] == max) max = printf("%d\n", i); } return 0; }
#include <iostream> #include <stdio.h> #include <string.h> using namespace std; int a[100]; int main(void) { int n; int max = 0; for (int i = 0; i < 100; i++) a[i] = 0; while (scanf("%d", &n) != EOF) { a[n]++; } for (int i = 0; i < 100; i++) { if (a[i] > max) max = a[i]; } for (int i = 0; i < 100; i++) { if (a[i] == max) printf("%d\n", i); } return 0; }
[["-", 8, 9, 0, 57, 64, 1, 0, 11, 31, 22], ["-", 8, 9, 0, 57, 64, 1, 0, 11, 17, 32]]
1
146
2
#include <bits/stdc++.h> using namespace std; int main() { int t[101] = {}, tmp, k = 0, i; while (cin >> tmp) { t[tmp + 1]++; if (t[tmp] > k) { k = t[tmp]; } } for (i = 1; i <= 101; i++) { if (t[i] == k) { cout << i - 1 << endl; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int t[102] = {}, tmp, k = 0, i; while (cin >> tmp) { t[tmp + 1]++; if (t[tmp + 1] > k) { k = t[tmp + 1]; } } for (i = 1; i <= 102; i++) { if (t[i] == k) { cout << i - 1 << endl; } } return 0; }
[["-", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13], ["+", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13], ["+", 51, 16, 31, 69, 341, 342, 0, 16, 17, 72], ["+", 51, 16, 31, 69, 341, 342, 0, 16, 12, 13], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 17, 72], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]]
1
100
8
#include <algorithm> #include <cassert> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <fstream> #include <functional> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define LOG(...) printf(__VA_ARGS__) //#define LOG(...) #define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i) #define REP(i, n) for (int i = 0; i < (int)(n); ++i) #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define EXIST(s, e) ((s).find(e) != (s).end()) #define SORT(c) sort((c).begin(), (c).end()) #define RSORT(c) sort((c).rbegin(), (c).rend()) #define CLR(a) memset((a), 0, sizeof(a)) typedef long long ll; typedef unsigned long long ull; typedef vector<bool> vb; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<vb> vvb; typedef vector<vi> vvi; typedef vector<vll> vvll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int dx[] = {-1, 0, 1, 0}; const int dy[] = {0, 1, 0, -1}; int main() { int a[100] = {0}; int n; while (cin >> n) a[n - 1]++; int ma = 0; REP(i, 100) { ma = max(ma, a[i]); } REP(i, 100) { if (a[i] == ma) cout << (a[i] + 1) << endl; } return 0; }
#include <algorithm> #include <cassert> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <fstream> #include <functional> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define LOG(...) printf(__VA_ARGS__) //#define LOG(...) #define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i) #define REP(i, n) for (int i = 0; i < (int)(n); ++i) #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define EXIST(s, e) ((s).find(e) != (s).end()) #define SORT(c) sort((c).begin(), (c).end()) #define RSORT(c) sort((c).rbegin(), (c).rend()) #define CLR(a) memset((a), 0, sizeof(a)) typedef long long ll; typedef unsigned long long ull; typedef vector<bool> vb; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<vb> vvb; typedef vector<vi> vvi; typedef vector<vll> vvll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int dx[] = {-1, 0, 1, 0}; const int dy[] = {0, 1, 0, -1}; int main() { int a[100] = {0}; int n; while (cin >> n) a[n - 1]++; int ma = 0; REP(i, 100) { ma = max(ma, a[i]); } REP(i, 100) { if (a[i] == ma) cout << (i + 1) << endl; } return 0; }
[["-", 31, 16, 12, 23, 0, 16, 31, 69, 28, 22], ["-", 12, 23, 0, 16, 31, 69, 341, 342, 0, 70], ["-", 12, 23, 0, 16, 31, 69, 341, 342, 0, 73]]
1
299
3
#include <cstdio> using namespace std; int main() { int data[101] = {0}; int n, max; while (scanf("%d", &n) != EOF) { data[n]++; } for (int i = 0; i < 101; i++) { if (max < data[i]) { max = data[i]; } } for (int i = 0; i < 101; i++) { if (max == data[i]) { printf("%d", i); } } return (0); }
#include <cstdio> using namespace std; int main() { int data[101] = {0}; int n, max = 0; while (scanf("%d", &n) != EOF) { data[n]++; } for (int i = 0; i < 101; i++) { if (max < data[i]) { max = data[i]; } } for (int i = 0; i < 101; i++) { if (max == data[i]) { printf("%d\n", i); } } return (0); }
[["+", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
1
124
3
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <string> #include <vector> #define rep(i, a, n) for (int i = a; i < n; i++) using namespace std; int main(void) { int n, a[101], m = 0; rep(i, 1, 101) { a[i] = 0; } while (cin >> n) { a[n]++; } rep(i, 1, 101) { if (m < a[i]) { m = a[i]; } } rep(i, 1, 101) { if (m == a[i]) { cout << a[i] << "\n"; } } return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <string> #include <vector> #define rep(i, a, n) for (int i = a; i < n; i++) using namespace std; int main(void) { int n, a[101], m = 0; rep(i, 1, 101) { a[i] = 0; } while (cin >> n) { a[n]++; } rep(i, 1, 101) { if (m < a[i]) { m = a[i]; } } rep(i, 1, 101) { if (m == a[i]) { cout << i << "\n"; } } return 0; }
[["-", 0, 1, 0, 16, 31, 16, 12, 69, 28, 22], ["-", 0, 16, 31, 16, 12, 69, 341, 342, 0, 70], ["-", 0, 16, 31, 16, 12, 69, 341, 342, 0, 73]]
1
142
3
#include <algorithm> #include <iostream> using namespace std; int main() { int n, m; int a[100] = {0}; while (cin >> n) a[n - 1]++; m = *max_element(a, a + 100); for (int i = 0; i < 10; i++) { if (m == a[i]) cout << i + 1 << endl; } return 0; }
#include <algorithm> #include <iostream> using namespace std; int main() { int n, m; int a[100] = {0}; while (cin >> n) a[n - 1]++; m = *max_element(a, a + 100); for (int i = 0; i < 100; i++) { if (m == a[i]) cout << i + 1 << endl; } return 0; }
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]]
1
91
2
#include <iostream> using namespace std; int main() { int count[101] = {0}; int a; while (cin >> a) count[a]++; int max_freq = 0; for (int i = 1; i <= 100; i++) { if (max_freq < count[i]) max_freq = count[i]; } for (int i = 1; i <= 100; i++) { if (count[i] == max_freq) cout << count[i] << endl; } return 0; }
#include <iostream> using namespace std; int main() { int count[101] = {0}; int a; while (cin >> a) count[a]++; int max_freq = 0; for (int i = 1; i <= 100; i++) { if (max_freq < count[i]) max_freq = count[i]; } for (int i = 1; i <= 100; i++) { if (count[i] == max_freq) cout << i << endl; } return 0; }
[["-", 64, 1, 0, 16, 31, 16, 12, 69, 28, 22], ["-", 0, 16, 31, 16, 12, 69, 341, 342, 0, 70], ["-", 0, 16, 31, 16, 12, 69, 341, 342, 0, 73]]
1
111
3
#include <stdio.h> int main() { int i; int seed, max = 0; int data[100] = {0}; int maxnum[100]; while ((scanf("%d", &seed)) != EOF) { data[seed] += 1; } for (i = 0; i < 100; i++) { if (data[i] > max) max = data[i]; } for (i = 0; i < 100; i++) { if (data[i] == max) printf("%d\n", i + 1); } return 0; }
#include <stdio.h> int main() { int i; int seed, max = 0; int data[100] = {0}; int maxnum[100]; while ((scanf("%d", &seed)) != EOF) { data[seed - 1] += 1; } for (i = 0; i < 100; i++) { if (data[i] > max) max = data[i]; } for (i = 0; i < 100; i++) { if (data[i] == max) printf("%d\n", i + 1); } return 0; }
[["+", 0, 11, 31, 69, 341, 342, 0, 16, 17, 33], ["+", 0, 11, 31, 69, 341, 342, 0, 16, 12, 13]]
1
129
2
#include <iostream> using namespace std; int list[101]; int main() { int n, i, max = 101; while (cin >> n) { list[n] += 1; } for (i = 1; i < 101; i++) { if (list[i] >= max) max = list[i]; } for (i = 1; i < 101; i++) { if (list[i] == max) cout << i << endl; } }
#include <iostream> using namespace std; int list[101]; int main() { int n, i, max = 0; while (cin >> n) { list[n] += 1; } for (i = 1; i < 101; i++) { if (list[i] >= max) max = list[i]; } for (i = 1; i < 101; i++) { if (list[i] == max) cout << i << endl; } }
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
103
2
#include <bits/stdc++.h> using namespace std; static const int MAX_N = 100; int a[MAX_N]; int main(void) { for (int i = 0; i < MAX_N; i++) { a[i] = 0; } int input; while (scanf("%d", &input) != EOF) { a[input]++; } int max_a = 0; for (int i = 0; i < MAX_N; i++) { if (a[i] > max_a) max_a = a[i]; } for (int i = 0; i < MAX_N; i++) { if (a[i] == max_a) printf("%d\n", a[i]); } return 0; }
#include <bits/stdc++.h> using namespace std; static const int MAX_N = 100; int a[MAX_N]; int main(void) { for (int i = 0; i <= MAX_N; i++) { a[i] = 0; } int input; while (scanf("%d", &input) != EOF) { a[input]++; } int max_a = 0; for (int i = 0; i < MAX_N; i++) { if (a[i] > max_a) max_a = a[i]; } for (int i = 0; i < MAX_N; i++) { if (a[i] == max_a) printf("%d\n", i); } return 0; }
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 64, 1, 0, 2, 3, 4, 0, 69, 28, 22], ["-", 0, 2, 3, 4, 0, 69, 341, 342, 0, 70], ["-", 0, 2, 3, 4, 0, 69, 341, 342, 0, 73]]
1
152
5
#include <stdio.h> int main() { int v, b[100] = {0}, c = 0; while (scanf("%d", &v) != EOF) { b[v - 1] += v; } for (int i = 0; i < 100; i++) { if (b[i] > c) { c = b[i]; } } for (int i = 0; i < 100; i++) { if (c == b[i]) { printf("%d\n", i + 1); } } return 0; }
#include <stdio.h> int main() { int v, b[100] = {0}, c = 0; while (scanf("%d", &v) != EOF) { b[v - 1] += 1; } for (int i = 0; i < 100; i++) { if (b[i] > c) { c = b[i]; } } for (int i = 0; i < 100; i++) { if (c == b[i]) { printf("%d\n", i + 1); } } return 0; }
[["-", 0, 52, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13]]
1
125
2
#include <iostream> using namespace std; int main() { int datas[100] = {0}; int num, biggest_num = 0; while (cin >> num) { datas[num + 1]++; } for (int i = 0; i < 100; i++) { if (biggest_num < datas[i]) { biggest_num = datas[i]; } } for (int i = 0; i < 100; i++) { if (biggest_num == datas[i]) { cout << i + 1 << endl; } } return 0; }
#include <iostream> using namespace std; int main() { int datas[100] = {0}; int num, biggest_num = 0; while (cin >> num) { datas[num - 1]++; } for (int i = 0; i < 100; i++) { if (biggest_num < datas[i]) { biggest_num = datas[i]; } } for (int i = 0; i < 100; i++) { if (biggest_num == datas[i]) { cout << i + 1 << endl; } } return 0; }
[["-", 0, 27, 28, 69, 341, 342, 0, 16, 17, 72], ["+", 0, 27, 28, 69, 341, 342, 0, 16, 17, 33]]
1
117
2
#include <iostream> int main() { int l[9999], i, f; for (i = 0; i < 999; i++) l[i] = 0; while (std::cin >> i) l[i - 1]++; for (i = 0, f = 0; i < 9999; i++) if (f < l[i]) f = l[i]; for (i = 0; i < 9999; i++) if (l[i] == f) std::cout << i + 1 << "\n"; }
#include <iostream> int main() { int l[999], i, f; for (i = 0; i < 999; i++) l[i] = 0; while (std::cin >> i) l[i - 1]++; for (i = 0, f = 0; i < 999; i++) if (f < l[i]) f = l[i]; for (i = 0; i < 999; i++) if (l[i] == f) std::cout << i + 1 << "\n"; }
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]]
1
121
6
#include <algorithm> #include <iostream> using namespace std; int main() { int input = 0; int a[100]; int b[100][2]; for (int i = 0; i < 100; i++) { for (int j = 0; j < 2; j++) { b[i][j] = 0; } } int n = 0; while (cin >> input) { a[n] = input; n++; } sort(a, a + n); int i = 0, j = 0; for (i = 0; i < n; i++) { if (i == 0) { b[0][0] = a[0]; b[0][1]++; } else if (b[j][2] == a[i]) { b[j][1]++; } else { b[++j][0] = a[i]; b[j][1]++; } } int max = b[0][1]; for (int k = 0; k <= j; k++) { if (max < b[k][1]) { max = b[k][1]; } } int out[100]; int m = 0; for (int k = 0; k <= j; k++) { if (max == b[k][1]) { out[m] = b[k][0]; m++; } } for (int p = 0; p < m; p++) { cout << out[p] << "\n"; } return 0; }
#include <algorithm> #include <iostream> using namespace std; int main() { int input = 0; int a[100]; int b[100][2]; for (int i = 0; i < 100; i++) { for (int j = 0; j < 2; j++) { b[i][j] = 0; } } int n = 0; while (cin >> input) { a[n] = input; n++; } sort(a, a + n); int i = 0, j = 0; for (i = 0; i < n; i++) { if (i == 0) { b[0][0] = a[0]; b[0][1]++; } else if (b[j][0] == a[i]) { b[j][1]++; } else { b[++j][0] = a[i]; b[j][1]++; } } int max = b[0][1]; for (int k = 0; k <= j; k++) { if (max < b[k][1]) { max = b[k][1]; } } int out[100]; int m = 0; for (int k = 0; k <= j; k++) { if (max == b[k][1]) { out[m] = b[k][0]; m++; } } for (int p = 0; p < m; p++) { cout << out[p] << "\n"; } return 0; }
[["-", 15, 339, 51, 16, 31, 69, 341, 342, 0, 13], ["+", 15, 339, 51, 16, 31, 69, 341, 342, 0, 13]]
1
353
2
#include <cstring> #include <iostream> #include <vector> using namespace std; int bucket[101]; int ma = 0; int main() { int a; memset(bucket, 0, sizeof(bucket)); while (cin >> a, !cin.eof()) { cin >> a; bucket[a]++; ma = max(bucket[a], ma); } for (int i = 0; i < 101; i++) { if (bucket[i] == ma) cout << i << endl; } return 0; }
#include <cstring> #include <iostream> #include <vector> using namespace std; int bucket[101]; int ma = 0; int main() { int a; memset(bucket, 0, sizeof(bucket)); while (cin >> a, !cin.eof()) { bucket[a]++; ma = max(bucket[a], ma); } for (int i = 0; i < 101; i++) { if (bucket[i] == ma) cout << i << endl; } return 0; }
[["-", 0, 52, 8, 9, 0, 1, 0, 16, 31, 22], ["-", 0, 52, 8, 9, 0, 1, 0, 16, 17, 152], ["-", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22], ["-", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
113
4
#include <iostream> using namespace std; int main(void) { int n; int a[10] = {0}; while (cin >> n) { a[n]++; } int max = 0; for (int i = 0; i < 10; i++) { if (a[i] > max) { max = a[i]; } } for (int i = 0; i < 10; i++) { if (a[i] == max) { cout << i << endl; } } return 0; }
#include <iostream> using namespace std; int main(void) { int n; int a[101] = {0}; while (cin >> n) { a[n]++; } int max = 0; for (int i = 0; i < 101; i++) { if (a[i] > max) { max = a[i]; } } for (int i = 0; i < 101; i++) { if (a[i] == max) { cout << i << endl; } } return 0; }
[["-", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13], ["+", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]]
1
115
6
#include <algorithm> #include <iostream> using namespace std; int main() { int a[101] = {0}; int input; while (cin >> input) { a[input]++; int m = 0; for (int i = 1; i < 101; i++) { if (m < a[i]) m = a[i]; // m = max(m, a[i]); } for (int i = 1; i < 101; i++) { if (m == a[i]) { cout << i << endl; } } } return 0; }
#include <algorithm> #include <iostream> using namespace std; int main() { int a[101] = {0}; int input; while (cin >> input) { a[input]++; } int m = 0; for (int i = 1; i < 101; i++) { if (m < a[i]) m = a[i]; // m = max(m, a[i]); } for (int i = 1; i < 101; i++) { if (m == a[i]) { cout << i << endl; } } return 0; }
[["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46], ["-", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46]]
1
115
2
#include <iostream> #include <math.h> #include <stdio.h> using namespace std; int main() { int counter[10] = {0}; int a; int MAX = 0; int i = 0; while (cin >> a) { counter[a]++; } for (int j = 1; j < 10; j++) { MAX = max(MAX, counter[j]); } for (int k = 1; k < 10; k++) { if (MAX == counter[k]) { cout << k << endl; } } return 0; }
#include <iostream> #include <math.h> #include <stdio.h> using namespace std; int main() { int counter[101] = {0}; int a; int MAX = 0; int i = 0; while (cin >> a) { counter[a]++; } for (int j = 1; j < 101; j++) { MAX = max(MAX, counter[j]); } for (int k = 1; k < 101; k++) { if (MAX == counter[k]) { cout << k << endl; } } return 0; }
[["-", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13], ["+", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]]
1
117
6
#include <algorithm> #include <cstdlib> #include <iostream> #include <map> #include <utility> using namespace std; int main() { map<int, int> iData; int iBuff, maxCount, maxElement[100]; pair<map<int, int>::iterator, bool> flag; while (cin >> iBuff) { flag = iData.insert(map<int, int>::value_type(iBuff, 1)); if (flag.second == false) { iData[iBuff]++; maxCount = max(maxCount, iData[iBuff]); } } for (map<int, int>::iterator it = iData.begin(); it != iData.end(); it++) { if (it->second == maxCount) cout << it->first << endl; } return EXIT_SUCCESS; }
#include <algorithm> #include <cstdlib> #include <iostream> #include <map> #include <utility> using namespace std; int main() { map<int, int> iData; int iBuff, maxCount = 0, maxElement[100]; pair<map<int, int>::iterator, bool> flag; while (cin >> iBuff) { flag = iData.insert(map<int, int>::value_type(iBuff, 1)); if (flag.second == false) { iData[iBuff]++; maxCount = max(maxCount, iData[iBuff]); } } for (map<int, int>::iterator it = iData.begin(); it != iData.end(); it++) { if (it->second == maxCount) cout << it->first << endl; } return EXIT_SUCCESS; }
[["+", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
160
2
#include <stdio.h> int main(void) { int i, n, num[101] = {0}; int max = 0; while (scanf("%d", &n) != EOF) { num[n]++; } for (i = 0; i < 101; i++) { if (num[i] > num[max]) { max = num[i]; } } for (i = 0; i < 101; i++) { if (num[i] == max) { printf("%d\n", i); } } return (0); }
#include <stdio.h> int main(void) { int i, n, num[101] = {0}; int max = 0; while (scanf("%d", &n) != EOF) { num[n]++; } for (i = 0; i < 101; i++) { if (num[i] > max) { max = num[i]; } } for (i = 0; i < 101; i++) { if (num[i] == max) { printf("%d\n", i); } } return (0); }
[["-", 0, 57, 15, 23, 0, 16, 12, 69, 28, 22], ["-", 0, 57, 15, 23, 0, 16, 12, 69, 0, 70], ["-", 0, 57, 15, 23, 0, 16, 12, 69, 0, 73]]
0
127
3
#include <stdio.h> int count[10]; int main(void) { int i = 0; int j; int n[100]; int mc; while (scanf("%d", &n[i]) != EOF) { count[n[i]]++; i++; } mc = count[0]; for (j = 1; j < 10; j++) { if (count[j] > mc) { mc = count[j]; } } for (i = 0; i < 10; i++) { if (mc == count[i]) { printf("%d\n", i); } } return (0); }
#include <stdio.h> int count[100]; int main(void) { int i = 0; int j; int n[100]; int mc; while (scanf("%d", &n[i]) != EOF) { count[n[i]]++; i++; } mc = count[0]; for (j = 1; j < 100; j++) { if (count[j] > mc) { mc = count[j]; } } for (i = 0; i < 100; i++) { if (mc == count[i]) { printf("%d\n", i); } } return (0); }
[["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]]
0
144
6
#include <stdio.h> #define N 100 int main(void) { int a[101], i = 0, j, max; // initializing for (j = 1; j <= N; j++) { a[j] = 0; } while (scanf("%d", &i) != EOF) { a[i] += 1; } for (i = 1; i < N; i++) { if (a[i] > max) max = a[i]; } for (i = 1; i < N; i++) { if (max == a[i]) printf("%d\n", a[i]); } return 0; }
#include <stdio.h> #define N 100 int main(void) { int a[101], i = 0, j, max = 0; // initializing for (j = 1; j <= N; j++) { a[j] = 0; } while (scanf("%d", &i) != EOF) { a[i] += 1; } for (i = 1; i < N; i++) { if (a[i] > max) max = a[i]; } for (i = 1; i < N; i++) { if (max == a[i]) printf("%d\n", i); } return 0; }
[["+", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["-", 64, 1, 0, 2, 3, 4, 0, 69, 28, 22], ["-", 64, 1, 0, 2, 3, 4, 0, 69, 0, 70], ["-", 64, 1, 0, 2, 3, 4, 0, 69, 0, 73]]
0
143
5
#include <stdio.h> int main(void) { int count[100] = {0}; int mode_n = 0; int data; int i; while (scanf("%d", &data) != EOF) count[data - 1]++; for (i = 0; i < 100; i++) if (mode_n < count[i]) mode_n = count[i]; for (i = 0; i < 100; i++) if (mode_n == count[i]) printf("%d", i + 1); return 0; }
#include <stdio.h> int main(void) { int count[100] = {0}; int mode_n = 0; int data; int i; while (scanf("%d", &data) != EOF) count[data - 1]++; for (i = 0; i < 100; i++) if (mode_n < count[i]) mode_n = count[i]; for (i = 0; i < 100; i++) if (mode_n == count[i]) printf("%d\n", i + 1); return 0; }
[["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
0
117
1
#include <stdio.h> int main() { int M[101] = {0}, cou, a, max = 0; while (scanf("%d", &a) != EOF) { M[a]++; } for (cou = 0; cou < 100; cou++) { if (M[a] > max) { max = M[a]; } } for (cou = 0; cou < 100; cou++) { if (M[cou] == max) { printf("%d\n", a + 1); } } return 0; }
#include <stdio.h> int main() { int M[101] = {0}, cou, a, max = 0; while (scanf("%d", &a) != EOF) { M[a]++; } for (cou = 0; cou < 100; cou++) { if (M[cou] > max) { max = M[cou]; } } for (cou = 0; cou < 100; cou++) { if (M[cou] == max) { printf("%d\n", cou); } } return 0; }
[["-", 0, 57, 15, 23, 0, 16, 31, 69, 71, 22], ["+", 0, 57, 15, 23, 0, 16, 31, 69, 71, 22], ["-", 64, 9, 0, 1, 0, 11, 12, 69, 71, 22], ["+", 64, 9, 0, 1, 0, 11, 12, 69, 71, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 64, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
0
122
8
#include <stdio.h> int main(void) { int a, i; int count[101] = {0}; int max = 0; while (scanf("%d", a) != EOF) count[a]++; for (i = 1; i <= 100; i++) { if (max < count[i]) max = count[i]; } for (i = 0; i <= 100; i++) { if (max == count[i]) printf("%d\n", i); } return 0; }
#include <stdio.h> int main(void) { int a, i; int count[101] = {0}; int max = 0; while (scanf("%d", &a) != EOF) count[a]++; for (i = 1; i <= 100; i++) { if (max < count[i]) max = count[i]; } for (i = 0; i <= 100; i++) { if (max == count[i]) printf("%d\n", i); } return 0; }
[["+", 0, 16, 31, 2, 3, 4, 0, 66, 17, 67]]
0
116
1
#include <stdio.h> int num[101] = {0}; int data = 0; int max = 0; int i = 0; int main(void) { while ((scanf("%d", &data)) != EOF) { num[data]++; if (max < num[data]) max = num[data]; } for (i = 1; i <= 100; i++) { if (num[i] == max) printf("\n%d\n", i); } return 0; }
#include <stdio.h> int num[100] = {0}; int data = 0; int max = 0; int i = 0; int main(void) { while ((scanf("%d", &data)) != EOF) { num[data]++; if (max < num[data]) max = num[data]; } for (i = 0; i < 100; i++) { if (num[i] == max) printf("%d\n", i); } return 0; }
[["-", 0, 30, 0, 43, 49, 50, 49, 80, 81, 13], ["+", 0, 30, 0, 43, 49, 50, 49, 80, 81, 13], ["-", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
0
112
7
#include <stdio.h> int log[110] = {0}; int main() { int inp_d; int current_max = 0; while ((scanf("%d", &inp_d)) == 1) { if (++log[inp_d] > current_max) current_max = log[inp_d]; } for (int i = 1; i <= 100; i++) { if (log[inp_d] == current_max) printf("%d\n", i); } return 0; }
#include <stdio.h> int log[110] = {0}; int main() { int inp_d; int current_max = 0; while ((scanf("%d", &inp_d)) == 1) { if (++log[inp_d] > current_max) current_max = log[inp_d]; } for (int i = 1; i <= 100; i++) { if (log[i] == current_max) printf("%d\n", i); } return 0; }
[["-", 0, 57, 15, 23, 0, 16, 31, 69, 71, 22], ["+", 0, 57, 15, 23, 0, 16, 31, 69, 71, 22]]
0
99
2
#include <stdio.h> void swap(int *a, int *b) { int tmp; tmp = *a; *a = *b; *b = tmp; } int main() { int data[100]; int count[100]; int i, j, youso, tmp; for (i = 0; i < 100; i++) { count[i] = 0; } i = 0; while (scanf("%d", data + i) != EOF) { i++; } youso = i; for (i = 0; i < youso; i++) { tmp = data[i]; for (j = i; j < youso; j++) { if (data[j] == tmp) count[j]++; } } for (i = 0; i < youso - 1; i++) { for (j = i + 1; j > 0; j--) { if (count[j - 1] < count[j]) { swap(data + j - 1, data + j); swap(count + j - 1, count + j); } } } youso = 0; for (i = 0; data[i] == data[0]; i++) { youso++; } for (i = 0; i < youso - 1; i++) { for (j = i + 1; j > 0; j--) { if (data[j - 1] > data[j]) { swap(data + j - 1, data + j); swap(count + j - 1, count + j); } } } for (i = 0; i < youso; i++) { printf("%d\n", data[i]); } return 0; }
#include <stdio.h> void swap(int *a, int *b) { int tmp; tmp = *a; *a = *b; *b = tmp; } int main() { int data[100]; int count[100]; int i, j, youso, tmp; for (i = 0; i < 100; i++) { count[i] = 0; } i = 0; while (scanf("%d", data + i) != EOF) { i++; } youso = i; for (i = 0; i < youso; i++) { tmp = data[i]; for (j = i; j < youso; j++) { if (data[j] == tmp) count[j]++; } } for (i = 0; i < youso - 1; i++) { for (j = i + 1; j > 0; j--) { if (count[j - 1] < count[j]) { swap(data + j - 1, data + j); swap(count + j - 1, count + j); } } } youso = 0; for (i = 0; count[i] == count[0]; i++) { youso++; } for (i = 0; i < youso - 1; i++) { for (j = i + 1; j > 0; j--) { if (data[j - 1] > data[j]) { swap(data + j - 1, data + j); swap(count + j - 1, count + j); } } } for (i = 0; i < youso; i++) { printf("%d\n", data[i]); } return 0; }
[["-", 8, 9, 0, 7, 15, 16, 31, 69, 28, 22], ["+", 8, 9, 0, 7, 15, 16, 31, 69, 28, 22], ["-", 8, 9, 0, 7, 15, 16, 12, 69, 28, 22], ["+", 8, 9, 0, 7, 15, 16, 12, 69, 28, 22]]
0
374
4
#include <iostream> using namespace std; int main() { int a[105] = {}, b, c = 0; while (cin >> b) { a[b]++; } for (int i = 0; i < 101; i++) { if (c < a[b]) { c = a[b]; } } for (int i = 0; i < 101; i++) { if (a[b] == c) cout << b << endl; } return 0; }
#include <iostream> using namespace std; int main() { int a[105] = {}, b, c = 0; while (cin >> b) { a[b]++; } for (int i = 0; i < 101; i++) { if (c < a[i]) { c = a[i]; } } for (int i = 0; i < 101; i++) { if (a[i] == c) cout << i << endl; } return 0; }
[["-", 15, 339, 51, 16, 12, 69, 341, 342, 0, 22], ["+", 15, 339, 51, 16, 12, 69, 341, 342, 0, 22], ["-", 0, 1, 0, 11, 12, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 11, 12, 69, 341, 342, 0, 22], ["-", 15, 339, 51, 16, 31, 69, 341, 342, 0, 22], ["+", 15, 339, 51, 16, 31, 69, 341, 342, 0, 22], ["-", 0, 57, 64, 1, 0, 16, 31, 16, 12, 22], ["+", 0, 57, 64, 1, 0, 16, 31, 16, 12, 22]]
1
109
8
//↓template↓ #include "bits/stdc++.h" using namespace std; #define Would #define you #define all(n) n.begin(), n.end() const long long INF = 1e18; const long long MOD = 1e9 + 7; const double pi = acos(-1); const int SIZE = 1 << 17; int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1}, alp[30]; long long fac[200005], finv[200005], inv[200005]; vector<long long> dij; struct edge { long long to, cost; }; vector<vector<edge>> G; long long mod_pow(long long a, long long b) { long long res = 1, mul = a; for (int i = 0; i < 31; ++i) { if (b >> i & 1) { res *= mul; res %= MOD; } mul = (mul * mul) % MOD; } return res; } void addedge(int from, int to, int cost) { G[from].push_back({to, cost}); G[to].push_back({from, cost}); } //↑template↑ int ans[105], mon; int main() { int n; while (cin >> n) { ++ans[n]; } for (int i = 0; i < 100; ++i) { mon = max(mon, ans[i]); } for (int i = 0; i < 100; ++i) { if (ans[i] == mon) { cout << i + 1 << endl; } } }
//↓template↓ #include "bits/stdc++.h" using namespace std; #define Would #define you #define all(n) n.begin(), n.end() const long long INF = 1e18; const long long MOD = 1e9 + 7; const double pi = acos(-1); const int SIZE = 1 << 17; int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1}, alp[30]; long long fac[200005], finv[200005], inv[200005]; vector<long long> dij; struct edge { long long to, cost; }; vector<vector<edge>> G; long long mod_pow(long long a, long long b) { long long res = 1, mul = a; for (int i = 0; i < 31; ++i) { if (b >> i & 1) { res *= mul; res %= MOD; } mul = (mul * mul) % MOD; } return res; } void addedge(int from, int to, int cost) { G[from].push_back({to, cost}); G[to].push_back({from, cost}); } //↑template↑ int ans[105], mon; int main() { int n; while (cin >> n) { ++ans[n]; } for (int i = 0; i < 100; ++i) { mon = max(mon, ans[i]); } for (int i = 0; i < 100; ++i) { if (ans[i] == mon) { cout << i << endl; } } }
[["-", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
1
338
2
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < (int)n; ++i) #define FOR(i, c) \ for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i) #define ALL(c) (c).begin(), (c).end() int main() { // 5, 9, 13 int dx1[] = {-1, 0, 0, 0, 1}; int dy1[] = {0, -1, 0, 1, 0}; int dx2[] = {-1, -1, -1, 0, 0, 0, 1, 1, 1}; int dy2[] = {-1, 0, 1, -1, 0, 1, -1, 0, 1}; int dx3[] = {-2, -1, -1, -1, 0, 0, 0, 0, 0, 1, 1, 1, 0}; int dy3[] = {0, -1, 0, 1, -2, -1, 0, 1, 2, -1, 0, 1, 0}; vector<int> dx[3]; vector<int> dy[3]; dx[0].assign(dx1, dx1 + 5); dx[1].assign(dx2, dx2 + 9); dx[2].assign(dx3, dx3 + 13); dy[0].assign(dy1, dy1 + 5); dy[1].assign(dy2, dy2 + 9); dy[2].assign(dy3, dy3 + 13); int x, y, s; int ans1 = 100; int ans2 = 0; int ma[10][10]; memset(ma, 0, sizeof(ma)); while (scanf("%d,%d,%d", &x, &y, &s) == 3) { s--; REP(i, dx[s].size()) { int xx = x + dx[s][i]; int yy = y + dy[s][i]; if (xx < 0 || 10 <= xx || yy < 0 || 10 <= yy) continue; if (ma[xx][yy] == 0) ans1--; ma[xx][yy]++; ans2 = max(ma[xx][yy], ans2); } } cout << ans1 << endl; cout << ans2 << endl; }
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < (int)n; ++i) #define FOR(i, c) \ for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i) #define ALL(c) (c).begin(), (c).end() int main() { // 5, 9, 13 int dx1[] = {-1, 0, 0, 0, 1}; int dy1[] = {0, -1, 0, 1, 0}; int dx2[] = {-1, -1, -1, 0, 0, 0, 1, 1, 1}; int dy2[] = {-1, 0, 1, -1, 0, 1, -1, 0, 1}; int dx3[] = {-2, -1, -1, -1, 0, 0, 0, 0, 0, 1, 1, 1, 2}; int dy3[] = {0, -1, 0, 1, -2, -1, 0, 1, 2, -1, 0, 1, 0}; vector<int> dx[3]; vector<int> dy[3]; dx[0].assign(dx1, dx1 + 5); dx[1].assign(dx2, dx2 + 9); dx[2].assign(dx3, dx3 + 13); dy[0].assign(dy1, dy1 + 5); dy[1].assign(dy2, dy2 + 9); dy[2].assign(dy3, dy3 + 13); int x, y, s; int ans1 = 100; int ans2 = 0; int ma[10][10]; memset(ma, 0, sizeof(ma)); while (scanf("%d,%d,%d", &x, &y, &s) == 3) { s--; REP(i, dx[s].size()) { int xx = x + dx[s][i]; int yy = y + dy[s][i]; if (xx < 0 || 10 <= xx || yy < 0 || 10 <= yy) continue; if (ma[xx][yy] == 0) ans1--; ma[xx][yy]++; ans2 = max(ma[xx][yy], ans2); } } cout << ans1 << endl; cout << ans2 << endl; }
[["-", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13]]
1
472
2
#include <algorithm> #include <bitset> #include <cfloat> #include <climits> #include <cmath> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; int main() { vector<vector<int>> paper(10, vector<int>(10, 0)); int ret1 = 100; int ret2 = 0; int dy[] = {1, -1, 0, 0, 1, -1, 1, -1, 2, -2, 0, 0}; int dx[] = {0, 0, 1, -1, 1, 1, -1, -1, 0, 0, 2, -2}; for (;;) { int x0, y0, size; char c; if (!(cin >> x0 >> c >> y0 >> c >> size)) break; for (int i = 0; i < 4 * size; ++i) { int y = y0 + dy[i]; int x = x0 + dx[i]; if (y < 0 || y > 9 || x < 0 || x > 9) continue; if (paper[y][x] == 0) --ret1; ++paper[y][x]; ret2 = max(ret2, paper[y][x]); } } cout << ret1 << endl << ret2 << endl; }
#include <algorithm> #include <bitset> #include <cfloat> #include <climits> #include <cmath> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; int main() { vector<vector<int>> paper(10, vector<int>(10, 0)); int ret1 = 100; int ret2 = 0; int dy[] = {0, 1, -1, 0, 0, 1, -1, 1, -1, 2, -2, 0, 0}; int dx[] = {0, 0, 0, 1, -1, 1, 1, -1, -1, 0, 0, 2, -2}; for (;;) { int x0, y0, size; char c; if (!(cin >> x0 >> c >> y0 >> c >> size)) break; for (int i = 0; i < 4 * size + 1; ++i) { int y = y0 + dy[i]; int x = x0 + dx[i]; if (y < 0 || y > 9 || x < 0 || x > 9) continue; if (paper[y][x] == 0) --ret1; ++paper[y][x]; ret2 = max(ret2, paper[y][x]); } } cout << ret1 << endl << ret2 << endl; }
[["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 21], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 72], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
279
6
#include <algorithm> #include <cstring> #include <iostream> #include <vector> using namespace std; int sdy[] = {-1, 0, 0, 1, 0}; int sdx[] = {0, -1, 1, 0, 0}; int mdy[] = {0, 0, 0, -1, -1, -1, 1, 1, 1}; int mdx[] = {-1, 0, 1, -1, 0, 1, -1, 0, 1}; int ldy[] = {0, 0, 0, -1, -1, -1, 1, 1, 1, 2, 0, 0, -2}; int ldx[] = {-1, 0, 1, -1, 0, 1, -1, 0, 1, 0, -2, 2, 0}; int main() { int field[10][10]; memset(field, 0, sizeof(field)); int x, y, size; char cm; while (cin >> x >> cm >> y >> cm >> size) { // field[y][x]++; if (size == 1) { for (int i = 0; i < 4; i++) { int py = y + sdy[i]; int px = x + sdx[i]; if (py >= 0 && px >= 0 && py < 10 && px < 10) { field[py][px]++; } } } else if (size == 2) { for (int i = 0; i < 9; i++) { int py = y + mdy[i]; int px = x + mdx[i]; if (py >= 0 && px >= 0 && py < 10 && px < 10) { field[py][px]++; } } } else { for (int i = 0; i < 13; i++) { int py = y + ldy[i]; int px = x + ldx[i]; if (py >= 0 && px >= 0 && py < 10 && px < 10) { field[py][px]++; } } } } int maxConcentration = 0; int cnt = 0; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (field[i][j] == 0) cnt++; maxConcentration = max(maxConcentration, field[i][j]); } } cout << cnt << endl; cout << maxConcentration << endl; return 0; }
#include <algorithm> #include <cstring> #include <iostream> #include <vector> using namespace std; int sdy[] = {-1, 0, 0, 1, 0}; int sdx[] = {0, -1, 1, 0, 0}; int mdy[] = {0, 0, 0, -1, -1, -1, 1, 1, 1}; int mdx[] = {-1, 0, 1, -1, 0, 1, -1, 0, 1}; int ldy[] = {0, 0, 0, -1, -1, -1, 1, 1, 1, 2, 0, 0, -2}; int ldx[] = {-1, 0, 1, -1, 0, 1, -1, 0, 1, 0, -2, 2, 0}; int main() { int field[10][10]; memset(field, 0, sizeof(field)); int x, y, size; char cm; while (cin >> x >> cm >> y >> cm >> size) { // field[y][x]++; if (size == 1) { for (int i = 0; i < 5; i++) { int py = y + sdy[i]; int px = x + sdx[i]; if (py >= 0 && px >= 0 && py < 10 && px < 10) { field[py][px]++; } } } else if (size == 2) { for (int i = 0; i < 9; i++) { int py = y + mdy[i]; int px = x + mdx[i]; if (py >= 0 && px >= 0 && py < 10 && px < 10) { field[py][px]++; } } } else { for (int i = 0; i < 13; i++) { int py = y + ldy[i]; int px = x + ldx[i]; if (py >= 0 && px >= 0 && py < 10 && px < 10) { field[py][px]++; } } } } int maxConcentration = 0; int cnt = 0; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (field[i][j] == 0) cnt++; maxConcentration = max(maxConcentration, field[i][j]); } } cout << cnt << endl; cout << maxConcentration << endl; return 0; }
[["-", 0, 57, 64, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 57, 64, 9, 0, 7, 15, 16, 12, 13]]
1
518
2
#include <iostream> using namespace std; int main() { int cell[10][10] = {{0}}, x, y, size, i, j, max = 0, num = 0; char c; while (1) { cin >> x; if (cin.eof()) break; cin >> c >> y >> c >> size; switch (size) { case 1: for (i = y - 1; i <= y + 1; i++) { for (j = ((i == y - 1 || i == y + 1) ? x : x - 1); j <= ((i == y - 1 || i == y + 1) ? x : x + 1); j++) { if ((0 <= i && i < 10) || (0 <= j && j < 10)) cell[j][i]++; } } break; case 2: for (i = y - 1; i <= y + 1; i++) { for (j = x - 1; j <= x + 1; j++) { if ((0 <= i && i < 10) || (0 <= j && j < 10)) cell[j][i]++; } } break; case 3: for (i = y - 2; i <= y + 2; i++) { for (j = ((i == y - 2 || i == y + 2) ? x : ((i == y - 1 || i == y + 1) ? x - 1 : x - 2)); j <= ((i == y - 2 || i == y + 2) ? x : ((i == y - 1 || i == y + 1) ? x + 1 : x + 2)); j++) { if ((0 <= i && i < 10) || (0 <= j && j < 10)) cell[j][i]++; } } break; } } for (i = 0; i < 10; i++) { for (j = 0; j < 10; j++) { if (cell[j][i] >= max) max = cell[j][i]; if (cell[j][i] == 0) num++; } } cout << num << endl << max << endl; return 0; }
#include <iostream> using namespace std; int main() { int cell[10][10] = {{0}}, x, y, size, i, j, max = 0, num = 0; char c; while (1) { cin >> x; if (cin.eof()) break; cin >> c >> y >> c >> size; switch (size) { case 1: for (i = y - 1; i <= y + 1; i++) { for (j = ((i == y - 1 || i == y + 1) ? x : x - 1); j <= ((i == y - 1 || i == y + 1) ? x : x + 1); j++) { if ((0 <= i && i < 10) && (0 <= j && j < 10)) cell[j][i]++; } } break; case 2: for (i = y - 1; i <= y + 1; i++) { for (j = x - 1; j <= x + 1; j++) { if ((0 <= i && i < 10) && (0 <= j && j < 10)) cell[j][i]++; } } break; case 3: for (i = y - 2; i <= y + 2; i++) { for (j = ((i == y - 2 || i == y + 2) ? x : ((i == y - 1 || i == y + 1) ? x - 1 : x - 2)); j <= ((i == y - 2 || i == y + 2) ? x : ((i == y - 1 || i == y + 1) ? x + 1 : x + 2)); j++) { if ((0 <= i && i < 10) && (0 <= j && j < 10)) cell[j][i]++; } } break; } } for (i = 0; i < 10; i++) { for (j = 0; j < 10; j++) { if (cell[j][i] >= max) max = cell[j][i]; if (cell[j][i] == 0) num++; } } cout << num << endl << max << endl; return 0; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 106], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 98]]
1
498
6
#include <iostream> using namespace std; main() { int map[10][10]; int x, y, size; // initialize for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { map[i][j] = 0; } } int white = 0, Max = 0; while (scanf("%d,%d,%d", &x, &y, &size) != EOF) { if (size == 1) { if (y >= 0 && y < 10 && (x - 1) >= 0 && (x - 1) < 10) map[y][x - 1]++; if ((y - 1) >= 0 && (y - 1) < 10 && x >= 0 && x < 10) map[y - 1][x]++; if (y >= 0 && y < 10 && x >= 0 && x < 10) map[y][x]++; if ((y + 1) >= 0 && (y + 1) < 10 && x >= 0 && x < 10) map[y + 1][x]++; if (y >= 0 && y < 10 && (x + 1) >= 0 && (x + 1) < 10) map[y][x + 1]++; } if (size == 2) { if (y - 1 >= 0 && y - 1 < 10 && (x - 1) >= 0 && (x - 1) < 10) map[y - 1][x - 1]++; if (y + 1 >= 0 && y + 1 < 10 && (x - 1) >= 0 && (x - 1) < 10) map[y + 1][x - 1]++; if (y - 1 >= 0 && y - 1 < 10 && (x + 1) >= 0 && (x + 1) < 10) map[y - 1][x + 1]++; if (y + 1 >= 0 && y + 1 < 10 && (x + 1) >= 0 && (x + 1) < 10) map[y + 1][x + 1]++; if (y >= 0 && y < 10 && (x - 1) >= 0 && (x - 1) < 10) map[y][x - 1]++; if ((y - 1) >= 0 && (y - 1) < 10 && x >= 0 && x < 10) map[y - 1][x]++; if (y >= 0 && y < 10 && x >= 0 && x < 10) map[y][x]++; if ((y + 1) >= 0 && (y + 1) < 10 && x >= 0 && x < 10) map[y + 1][x]++; if (y >= 0 && y < 10 && (x + 1) >= 0 && (x + 1) < 10) map[y][x + 1]++; } if (size == 3) { if (y >= 0 && y < 10 && (x - 2) >= 0 && (x - 2) < 10) map[y][x - 2]++; if (y - 2 >= 0 && y - 2 < 10 && (x) >= 0 && (x) < 10) map[y - 2][x]++; if (y + 2 >= 0 && y + 2 < 10 && (x) >= 0 && (x) < 10) map[y + 2][x]++; if (y >= 0 && y < 10 && (x + 2) >= 0 && (x + 2) < 10) map[y][x + 2]++; if (y - 1 >= 0 && y - 1 < 10 && (x - 1) >= 0 && (x - 1) < 10) map[y - 1][x - 1]++; if (y + 1 >= 0 && y + 1 < 10 && (x - 1) >= 0 && (x - 1) < 10) map[y + 1][x - 1]++; if (y - 1 >= 0 && y - 1 < 10 && (x + 1) >= 0 && (x + 1) < 10) map[y - 1][x + 1]++; if (y + 1 >= 0 && y + 1 < 10 && (x + 1) >= 0 && (x + 1) < 10) map[y + 1][x + 1]++; if (y >= 0 && y < 10 && (x - 1) >= 0 && (x - 1) < 10) map[y][x - 1]++; if ((y - 1) >= 0 && (y - 1) < 10 && x >= 0 && x < 10) map[y - 1][x]++; if (y >= 0 && y < 10 && x >= 0 && x < 10) map[y][x]++; if ((y + 1) >= 0 && (y + 1) < 10 && x >= 0 && x < 10) map[y + 1][x]++; if (y >= 0 && y < 10 && (x + 1) >= 0 && (x + 1) < 10) map[y][x + 1]++; } } for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (map[i][j] == 0) white++; if (map[i][j] >= Max) Max = map[i][j]; } } cout << white << " " << Max << endl; return 0; }
#include <iostream> using namespace std; main() { int map[10][10]; int x, y, size; // initialize for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { map[i][j] = 0; } } int white = 0, Max = 0; while (scanf("%d,%d,%d", &x, &y, &size) != EOF) { if (size == 1) { if (y >= 0 && y < 10 && (x - 1) >= 0 && (x - 1) < 10) map[y][x - 1]++; if ((y - 1) >= 0 && (y - 1) < 10 && x >= 0 && x < 10) map[y - 1][x]++; if (y >= 0 && y < 10 && x >= 0 && x < 10) map[y][x]++; if ((y + 1) >= 0 && (y + 1) < 10 && x >= 0 && x < 10) map[y + 1][x]++; if (y >= 0 && y < 10 && (x + 1) >= 0 && (x + 1) < 10) map[y][x + 1]++; } if (size == 2) { if (y - 1 >= 0 && y - 1 < 10 && (x - 1) >= 0 && (x - 1) < 10) map[y - 1][x - 1]++; if (y + 1 >= 0 && y + 1 < 10 && (x - 1) >= 0 && (x - 1) < 10) map[y + 1][x - 1]++; if (y - 1 >= 0 && y - 1 < 10 && (x + 1) >= 0 && (x + 1) < 10) map[y - 1][x + 1]++; if (y + 1 >= 0 && y + 1 < 10 && (x + 1) >= 0 && (x + 1) < 10) map[y + 1][x + 1]++; if (y >= 0 && y < 10 && (x - 1) >= 0 && (x - 1) < 10) map[y][x - 1]++; if ((y - 1) >= 0 && (y - 1) < 10 && x >= 0 && x < 10) map[y - 1][x]++; if (y >= 0 && y < 10 && x >= 0 && x < 10) map[y][x]++; if ((y + 1) >= 0 && (y + 1) < 10 && x >= 0 && x < 10) map[y + 1][x]++; if (y >= 0 && y < 10 && (x + 1) >= 0 && (x + 1) < 10) map[y][x + 1]++; } if (size == 3) { if (y >= 0 && y < 10 && (x - 2) >= 0 && (x - 2) < 10) map[y][x - 2]++; if (y - 2 >= 0 && y - 2 < 10 && (x) >= 0 && (x) < 10) map[y - 2][x]++; if (y + 2 >= 0 && y + 2 < 10 && (x) >= 0 && (x) < 10) map[y + 2][x]++; if (y >= 0 && y < 10 && (x + 2) >= 0 && (x + 2) < 10) map[y][x + 2]++; if (y - 1 >= 0 && y - 1 < 10 && (x - 1) >= 0 && (x - 1) < 10) map[y - 1][x - 1]++; if (y + 1 >= 0 && y + 1 < 10 && (x - 1) >= 0 && (x - 1) < 10) map[y + 1][x - 1]++; if (y - 1 >= 0 && y - 1 < 10 && (x + 1) >= 0 && (x + 1) < 10) map[y - 1][x + 1]++; if (y + 1 >= 0 && y + 1 < 10 && (x + 1) >= 0 && (x + 1) < 10) map[y + 1][x + 1]++; if (y >= 0 && y < 10 && (x - 1) >= 0 && (x - 1) < 10) map[y][x - 1]++; if ((y - 1) >= 0 && (y - 1) < 10 && x >= 0 && x < 10) map[y - 1][x]++; if (y >= 0 && y < 10 && x >= 0 && x < 10) map[y][x]++; if ((y + 1) >= 0 && (y + 1) < 10 && x >= 0 && x < 10) map[y + 1][x]++; if (y >= 0 && y < 10 && (x + 1) >= 0 && (x + 1) < 10) map[y][x + 1]++; } } for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (map[i][j] == 0) white++; if (map[i][j] >= Max) Max = map[i][j]; } } cout << white << endl << Max << endl; return 0; }
[["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 62], ["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 31, 16, 12, 22]]
1
1,226
4
#include <cstdio> #include <iostream> using namespace std; int board[10][10]; void fill(int x, int y) { if (0 <= x && x < 10 && 0 <= y && y < 10) { board[y][x]++; } } int main() { int x, y, size; while (scanf("%d,%d,%d", &x, &y, &size) + 1) { if (size >= 1) { // small fill(x, y); fill(x + 1, y); fill(x - 1, y); fill(x, y + 1); fill(x, y - 1); } if (size >= 2) { // medium fill(x + 1, y + 1); fill(x + 1, y - 1); fill(x - 1, y + 1); fill(x - 1, y + 1); } if (size >= 3) { // large fill(x + 2, y); fill(x - 2, y); fill(x, y + 2); fill(x, y - 2); } } int num_zero = 0; int deepest = 0; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (board[j][i] == 0) { num_zero++; } if (deepest < board[j][i]) { deepest = board[j][i]; } } } cout << num_zero << endl; cout << deepest << endl; return 0; }
#include <cstdio> #include <iostream> using namespace std; int board[10][10]; void fill(int x, int y) { if (0 <= x && x < 10 && 0 <= y && y < 10) { board[y][x]++; } } int main() { int x, y, size; while (~scanf("%d,%d,%d", &x, &y, &size)) { if (size >= 1) { // small fill(x, y); fill(x + 1, y); fill(x - 1, y); fill(x, y + 1); fill(x, y - 1); } if (size >= 2) { // medium fill(x + 1, y + 1); fill(x + 1, y - 1); fill(x - 1, y + 1); fill(x - 1, y - 1); } if (size >= 3) { // large fill(x + 2, y); fill(x - 2, y); fill(x, y + 2); fill(x, y - 2); } } int num_zero = 0; int deepest = 0; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (board[j][i] == 0) { num_zero++; } if (deepest < board[j][i]) { deepest = board[j][i]; } } } cout << num_zero << endl; cout << deepest << endl; return 0; }
[["+", 8, 9, 0, 52, 15, 339, 51, 91, 17, 92], ["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 72], ["-", 8, 9, 0, 52, 15, 339, 51, 16, 12, 13], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33]]
1
340
5
#include <cstdio> #include <iostream> using namespace std; int main() { int x, y, t; int field[30][30] = {0}; for (;;) { if (scanf("%d,%d,%d", &x, &y, &t) == EOF) { break; } field[x + 10][y + 10]++; field[x + 9][y + 10]++; field[x + 11][y + 10]++; field[x + 10][y + 9]++; field[x + 10][y + 11]++; if (t > 1) { field[x + 9][y + 11]++; field[x + 9][y + 9]++; field[x + 11][y + 11]++; field[x + 11][y + 9]++; } if (t > 2) { field[x + 10][y + 12]++; field[x + 10][y + 8]++; field[x + 12][y + 10]++; field[x + 8][y + 10]++; } } int ans[2] = {0}; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (!field[i + 10][y + 10]) { ans[0]++; } if (field[i + 10][y + 10] > ans[1]) { ans[1] = field[i + 10][j + 10]; } } } cout << ans[0] << endl << ans[1] << endl; return 0; }
#include <cstdio> #include <iostream> using namespace std; int main() { int x, y, t; int field[30][30] = {0}; for (;;) { if (scanf("%d,%d,%d", &x, &y, &t) == EOF) { break; } field[x + 10][y + 10]++; field[x + 9][y + 10]++; field[x + 11][y + 10]++; field[x + 10][y + 9]++; field[x + 10][y + 11]++; if (t > 1) { field[x + 9][y + 11]++; field[x + 9][y + 9]++; field[x + 11][y + 11]++; field[x + 11][y + 9]++; } if (t > 2) { field[x + 10][y + 12]++; field[x + 10][y + 8]++; field[x + 12][y + 10]++; field[x + 8][y + 10]++; } } int ans[2] = {0}; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (!field[i + 10][j + 10]) { ans[0]++; } if (field[i + 10][j + 10] > ans[1]) { ans[1] = field[i + 10][j + 10]; } } } cout << ans[0] << endl << ans[1] << endl; return 0; }
[["-", 51, 91, 28, 69, 341, 342, 0, 16, 31, 22], ["+", 51, 91, 28, 69, 341, 342, 0, 16, 31, 22], ["-", 51, 16, 31, 69, 341, 342, 0, 16, 31, 22], ["+", 51, 16, 31, 69, 341, 342, 0, 16, 31, 22]]
1
372
4
#include <cstdio> #include <iostream> using namespace std; int main() { int board[10][10] = {0}; fill(board[0], board[0] + 10 * 10, 0); const int INK[3][14][2] = {{{6}, {0, -1}, {-1, 0}, {0, 0}, {1, 0}, {0, 1}}, {{10}, {-1, -1}, {0, -1}, {1, -1}, {-1, 0}, {0, 0}, {1, 0}, {-1, 1}, {0, 1}, {-1, 1}}, {{14}, {0, -2}, {-1, -1}, {0, -1}, {1, -1}, {-2, 0}, {-1, 0}, {0, 0}, {1, 0}, {2, 0}, {-1, 1}, {0, 1}, {1, 1}, {0, 2}}}; int x, y, ink; int max = 0; int count = 100; while (scanf("%d,%d,%d", &x, &y, &ink) != EOF) { for (int i = 1; i < INK[ink - 1][0][0]; ++i) { int dx = x + INK[ink - 1][i][0]; int dy = y + INK[ink - 1][i][1]; if (!(dx < 0 || dy < 0 || dx > 9 || dy > 9)) { if (board[dx][dy] == 0) --count; ++board[dx][dy]; if (board[dx][dy] > max) max = board[dx][dy]; } } /* debug for(int i=0;i<10;++i){ for(int j=0;j<10;++j) cout << board[i][j] << " "; cout << "\n"; }*/ } cout << count << "\n" << max << "\n"; return 0; }
#include <cstdio> #include <iostream> using namespace std; int main() { int board[10][10] = {0}; fill(board[0], board[0] + 10 * 10, 0); const int INK[3][14][2] = {{{6}, {0, -1}, {-1, 0}, {0, 0}, {1, 0}, {0, 1}}, {{10}, {-1, -1}, {0, -1}, {1, -1}, {-1, 0}, {0, 0}, {1, 0}, {-1, 1}, {0, 1}, {1, 1}}, {{14}, {0, -2}, {-1, -1}, {0, -1}, {1, -1}, {-2, 0}, {-1, 0}, {0, 0}, {1, 0}, {2, 0}, {-1, 1}, {0, 1}, {1, 1}, {0, 2}}}; int x, y, ink; int max = 0; int count = 100; while (scanf("%d,%d,%d", &x, &y, &ink) != EOF) { for (int i = 1; i < INK[ink - 1][0][0]; ++i) { int dx = x + INK[ink - 1][i][0]; int dy = y + INK[ink - 1][i][1]; if (!(dx < 0 || dy < 0 || dx > 9 || dy > 9)) { if (board[dx][dy] == 0) --count; ++board[dx][dy]; if (board[dx][dy] > max) max = board[dx][dy]; } } /*debug for(int i=0;i<10;++i){ for(int j=0;j<10;++j) cout << board[i][j] << " "; cout << "\n"; }*/ } cout << count << "\n" << max << "\n"; return 0; }
[["-", 49, 50, 51, 83, 0, 83, 0, 83, 0, 13], ["+", 49, 50, 51, 83, 0, 83, 0, 83, 0, 13]]
1
430
2
#include <stdio.h> int main() { int RB[10][10], i, j, k; for (i = 0; i < 10; i++) for (j = 0; j < 10; RB[i][j++] = 0) ; while (scanf("%d,%d,%d", &i, &j, &k) != EOF) { RB[i][j]++; if (i) RB[i - 1][j]++; if (i < 9) RB[i + 1][j]++; if (j) RB[i][j - 1]++; if (j < 9) RB[i][j + 1]++; if (k > 1) { if (i * j) RB[i - 1][j - 1]++; if (i < 9 && j < 9) RB[i + 1][j + 1]++; if (i && j < 9) RB[i - 1][j + 1]++; if (i < 9 && j) RB[i + 1][j - 1]++; } if (k == 2) { if (i > 1) RB[i - 2][j]++; if (i < 8) RB[i + 2][j]++; if (j > 1) RB[i][j - 2]++; if (j < 8) RB[i][j + 2]++; } } for (i = 0, k = 100; i < 10; i++) for (j = 0; j < 10; j++) if (RB[i][j]) k--; printf("%d\n", k); for (i = 0, k = 0; i < 10; i++) for (j = 0; j < 10; j++) if (RB[i][j] > k) k = RB[i][j]; printf("%d\n", k); return 0; }
#include <stdio.h> int main() { int RB[10][10], i, j, k; for (i = 0; i < 10; i++) for (j = 0; j < 10; RB[i][j++] = 0) ; while (scanf("%d,%d,%d", &i, &j, &k) != EOF) { RB[i][j]++; if (i) RB[i - 1][j]++; if (i < 9) RB[i + 1][j]++; if (j) RB[i][j - 1]++; if (j < 9) RB[i][j + 1]++; if (k > 1) { if (i * j) RB[i - 1][j - 1]++; if (i < 9 && j < 9) RB[i + 1][j + 1]++; if (i && j < 9) RB[i - 1][j + 1]++; if (i < 9 && j) RB[i + 1][j - 1]++; } if (k == 3) { if (i > 1) RB[i - 2][j]++; if (i < 8) RB[i + 2][j]++; if (j > 1) RB[i][j - 2]++; if (j < 8) RB[i][j + 2]++; } } for (i = 0, k = 100; i < 10; i++) for (j = 0; j < 10; j++) if (RB[i][j]) k--; printf("%d\n", k); for (i = 0, k = 0; i < 10; i++) for (j = 0; j < 10; j++) if (RB[i][j] > k) k = RB[i][j]; printf("%d\n", k); return 0; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
439
2
#include <iostream> using namespace std; int main() { int grid[14][14]; int s[4][2] = {{0, -1}, {0, 1}, {-1, 0}, {1, 0}}; int m[4][2] = {{-1, -1}, {-1, 1}, {1, -1}, {1, 1}}; int l[4][2] = {{0, -2}, {0, 2}, {-2, 0}, {2, 0}}; int x, y, size; int i, j; int max = 0; int blank = 0; char comma; for (i = 0; i < 14; i++) { for (j = 0; j < 14; j++) { grid[i][j] = 0; } } while (cin >> x >> comma >> y >> comma >> size) { x += 2; y += 2; grid[x][y] += 1; for (i = 0; i < 4; i++) { grid[x + s[i][0]][y + s[i][1]] += 1; } if (size > 1) { for (i = 0; i < 4; i++) { grid[x + m[i][0]][y + m[i][1]] += 1; } if (size > 2) { for (i = 0; i < 4; i++) { grid[x + l[i][0]][y + l[i][1]] += 1; } } } } for (i = 2; i < 12; i++) { for (j = 2; j < 12; j++) { if (grid[i][j] > max) { max = grid[i][j]; } else if (grid[i][j] = 0) { blank += 1; } } } cout << blank << endl; cout << max << endl; return 0; }
#include <iostream> using namespace std; int main() { int grid[14][14]; int s[4][2] = {{0, -1}, {0, 1}, {-1, 0}, {1, 0}}; int m[4][2] = {{-1, -1}, {-1, 1}, {1, -1}, {1, 1}}; int l[4][2] = {{0, -2}, {0, 2}, {-2, 0}, {2, 0}}; int x, y, size; int i, j; int max = 0; int blank = 0; char comma; for (i = 0; i < 14; i++) { for (j = 0; j < 14; j++) { grid[i][j] = 0; } } while (cin >> x >> comma >> y >> comma >> size) { x += 2; y += 2; grid[x][y] += 1; for (i = 0; i < 4; i++) { grid[x + s[i][0]][y + s[i][1]] += 1; } if (size > 1) { for (i = 0; i < 4; i++) { grid[x + m[i][0]][y + m[i][1]] += 1; } if (size > 2) { for (i = 0; i < 4; i++) { grid[x + l[i][0]][y + l[i][1]] += 1; } } } } for (i = 2; i < 12; i++) { for (j = 2; j < 12; j++) { if (grid[i][j] > max) { max = grid[i][j]; } else if (grid[i][j] == 0) { blank += 1; } } } cout << blank << endl; cout << max << endl; return 0; }
[["-", 75, 76, 0, 57, 15, 339, 51, 11, 17, 32], ["+", 75, 76, 0, 57, 15, 339, 51, 16, 17, 60]]
1
452
2
#include <iostream> #include <stdio.h> using namespace std; int main() { int dec[10][10]; int x, y, size, num, max; char a; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { dec[i][j] = 0; } } while (cin >> y >> a >> x >> a >> size) { if (size == 1) { if (x + 1 < 10 && x + 1 >= 0 && y >= 0 && y < 10) dec[x + 1][y] += 1; if (x - 1 >= 0 && x - 1 < 10 && y >= 0 && y < 10) dec[x - 1][y] += 1; if (x >= 0 && x < 10 && y + 1 < 10 && y + 1 >= 0) dec[x][y + 1] += 1; if (x >= 0 && x < 10 && y - 1 < 10 && y - 1 >= 0) dec[x][y - 1] += 1; dec[x][y] += 1; } else if (size == 2) { for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { if (x + i >= 0 && x + i < 10 && y + j >= 0 && y + j < 10) dec[x + i][y + j] += 1; } } } else if (size == 3) { for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { if (x + i >= 0 && x + i < 10 && y + j >= 0 && y + j < 10) dec[x + i][y + j] += 1; } } if (x + 2 < 10 && x + 2 >= 0 && y >= 0 && y < 10) dec[x + 2][y] += 1; if (x - 2 >= 0 && x - 2 < 10 && y >= 0 && y < 10) dec[x - 2][y] += 1; if (x < 10 && x >= 0 && y + 2 >= 0 && y + 2 < 10) dec[x][y + 2] += 1; if (x >= 0 && x < 10 && y - 2 >= 0 && y - 2 < 10) dec[x][y - 2] += 1; } } max = dec[0][0]; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (dec[i][j] == 0) num += 1; if (max < dec[i][j]) max = dec[i][j]; } } cout << num << endl << max << endl; }
#include <iostream> #include <stdio.h> using namespace std; int main() { int dec[10][10]; int x, y, size, num, max; char a; num = 0; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { dec[i][j] = 0; } } while (cin >> y >> a >> x >> a >> size) { if (size == 1) { if (x + 1 < 10 && x + 1 >= 0 && y >= 0 && y < 10) dec[x + 1][y] += 1; if (x - 1 >= 0 && x - 1 < 10 && y >= 0 && y < 10) dec[x - 1][y] += 1; if (x >= 0 && x < 10 && y + 1 < 10 && y + 1 >= 0) dec[x][y + 1] += 1; if (x >= 0 && x < 10 && y - 1 < 10 && y - 1 >= 0) dec[x][y - 1] += 1; dec[x][y] += 1; } else if (size == 2) { for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { if (x + i >= 0 && x + i < 10 && y + j >= 0 && y + j < 10) dec[x + i][y + j] += 1; } } } else if (size == 3) { for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { if (x + i >= 0 && x + i < 10 && y + j >= 0 && y + j < 10) dec[x + i][y + j] += 1; } } if (x + 2 < 10 && x + 2 >= 0 && y >= 0 && y < 10) dec[x + 2][y] += 1; if (x - 2 >= 0 && x - 2 < 10 && y >= 0 && y < 10) dec[x - 2][y] += 1; if (x < 10 && x >= 0 && y + 2 >= 0 && y + 2 < 10) dec[x][y + 2] += 1; if (x >= 0 && x < 10 && y - 2 >= 0 && y - 2 < 10) dec[x][y - 2] += 1; } } max = dec[0][0]; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (dec[i][j] == 0) num += 1; if (max < dec[i][j]) max = dec[i][j]; } } cout << num << endl << max << endl; }
[["+", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
637
4
#include <iostream> #include <string> #include <vector> enum InkSize { small = 0, middle, large }; InkSize Next(int x) { if (x < 0 || 2 < x) { std::cout << "Input Error.\n"; return small; } const InkSize ink[3] = {small, middle, large}; return ink[x]; } struct Board { Board(int a) { for (size_t i = 0; i < m_element; ++i) { for (size_t j = 0; j < m_element; ++j) { m_map[j][i] = a; } } } void DropInk(int x, int y, InkSize ink) { const int inkSet[3][5][5] = {{ // small {0, 0, 0, 0, 0}, {0, 0, 1, 0, 0}, {0, 1, 1, 1, 0}, {0, 0, 1, 0, 0}, {0, 0, 0, 0, 0}, }, { // middle {0, 0, 0, 0, 0}, {0, 1, 1, 1, 0}, {0, 1, 1, 1, 0}, {0, 1, 1, 1, 0}, {0, 0, 0, 0, 0}, }, { // large {0, 0, 1, 0, 0}, {0, 1, 1, 1, 0}, {1, 1, 1, 1, 1}, {0, 1, 1, 1, 0}, {0, 0, 1, 0, 0}, }}; for (size_t i = 0; i < 5; ++i) { for (size_t j = 0; j < 5; ++j) { if (y - 2 + i < 0 || x - 2 + j < 0 || y - 2 + i > 9 || x - 2 + j > 9) { continue; } m_map[y - 2 + i][x - 2 + j] += inkSet[ink][i][j]; } } } int CountNonInkedCell() { int count = 0; for (size_t i = 0; i < m_element; ++i) { for (size_t j = 0; j < m_element; ++j) { if (m_map[i][j] == 0) { ++count; } } } return count; } int MostInkedCell() { int max = 0; for (size_t i = 0; i < m_element; ++i) { for (size_t j = 0; j < m_element; ++j) { if (m_map[i][j] > max) { max = m_map[i][j]; } } } return max; } enum { m_element = 10 }; int m_map[m_element][m_element]; }; int main() { Board boad1(0); int x = 0, y = 0, inkSize = 0; char c; while (std::cin >> x >> c >> y >> c >> inkSize) { boad1.DropInk(x, y, Next(inkSize - 1)); } std::cout << boad1.CountNonInkedCell() << ' ' << boad1.MostInkedCell() << '\n'; }
#include <iostream> #include <string> #include <vector> enum InkSize { small = 0, middle, large }; InkSize Next(int x) { if (x < 0 || 2 < x) { std::cout << "Input Error.\n"; return small; } const InkSize ink[3] = {small, middle, large}; return ink[x]; } struct Board { Board(int a) { for (size_t i = 0; i < m_element; ++i) { for (size_t j = 0; j < m_element; ++j) { m_map[j][i] = a; } } } void DropInk(int x, int y, InkSize ink) { const int inkSet[3][5][5] = {{ // small {0, 0, 0, 0, 0}, {0, 0, 1, 0, 0}, {0, 1, 1, 1, 0}, {0, 0, 1, 0, 0}, {0, 0, 0, 0, 0}, }, { // middle {0, 0, 0, 0, 0}, {0, 1, 1, 1, 0}, {0, 1, 1, 1, 0}, {0, 1, 1, 1, 0}, {0, 0, 0, 0, 0}, }, { // large {0, 0, 1, 0, 0}, {0, 1, 1, 1, 0}, {1, 1, 1, 1, 1}, {0, 1, 1, 1, 0}, {0, 0, 1, 0, 0}, }}; for (size_t i = 0; i < 5; ++i) { for (size_t j = 0; j < 5; ++j) { if (y - 2 + i < 0 || x - 2 + j < 0 || y - 2 + i > 9 || x - 2 + j > 9) { continue; } m_map[y - 2 + i][x - 2 + j] += inkSet[ink][i][j]; } } } int CountNonInkedCell() { int count = 0; for (size_t i = 0; i < m_element; ++i) { for (size_t j = 0; j < m_element; ++j) { if (m_map[i][j] == 0) { ++count; } } } return count; } int MostInkedCell() { int max = 0; for (size_t i = 0; i < m_element; ++i) { for (size_t j = 0; j < m_element; ++j) { if (m_map[i][j] > max) { max = m_map[i][j]; } } } return max; } enum { m_element = 10 }; int m_map[m_element][m_element]; }; int main() { Board boad1(0); int x = 0, y = 0, inkSize = 0; char c; while (std::cin >> x >> c >> y >> c >> inkSize) { boad1.DropInk(x, y, Next(inkSize - 1)); } std::cout << boad1.CountNonInkedCell() << '\n' << boad1.MostInkedCell() << '\n'; }
[["-", 0, 16, 31, 16, 31, 16, 12, 103, 0, 125], ["+", 0, 16, 31, 16, 31, 16, 12, 103, 0, 44]]
1
678
2
#include <cstdio> int ds[][2] = {{0, 0}, {1, 0}, {0, 1}, {-1, 0}, {0, -1}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}, {2, 0}, {0, 2}, {-2, 0}, {0, -2}}; int map[10][10], kosa, rest = 100; int max(int a, int b) { return a > b ? a : b; } int drop(int x, int y) { if (x >= 0 && x < 10 && y >= 0 && y < 10) { if (map[x][y]++ == 0) rest--; kosa = max(map[x][y], kosa); } } int main() { int x, y, size; while (~scanf("%d,%d,%d", &x, &y, &size)) for (int i = 0; i <= 4 * size; i++) drop(x + ds[i][0], y + ds[i][1]); printf("%d %d\n", rest, kosa); }
#include <cstdio> int ds[][2] = {{0, 0}, {1, 0}, {0, 1}, {-1, 0}, {0, -1}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}, {2, 0}, {0, 2}, {-2, 0}, {0, -2}}; int map[10][10], kosa, rest = 100; int max(int a, int b) { return a > b ? a : b; } int drop(int x, int y) { if (x >= 0 && x < 10 && y >= 0 && y < 10) { if (map[x][y]++ == 0) rest--; kosa = max(map[x][y], kosa); } } int main() { int x, y, size; while (~scanf("%d,%d,%d", &x, &y, &size)) for (int i = 0; i <= 4 * size; i++) drop(x + ds[i][0], y + ds[i][1]); printf("%d\n%d\n", rest, kosa); }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
1
270
4
#include <iostream> #include <stdio.h> int paper[10][10]; int vecx[] = {0, 1, 0, -1}, vecy[] = {-1, 0, 1, 0}; int main() { int x, y, size; while (scanf("%d,%d,%d", &x, &y, &size) != EOF) { switch (size) { case 1: paper[x][y]++; for (int i = 0; i < 4; i++) { int nx = x + vecx[i], ny = y + vecy[i]; if (nx >= 0 && nx < 10 && y >= 0 && y < 10) { paper[nx][ny]++; } } break; case 2: for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { if (x + i >= 0 && x + i < 10 && y + j >= 0 && y + j < 10) { paper[x + i][y + j]++; } } } break; case 3: for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { if (x + i >= 0 && x + i < 10 && y + j >= 0 && y + j < 10) { paper[x + i][y + j]++; } } } for (int i = 0; i < 4; i++) { int nx = x + vecx[i] * 2, ny = y + vecy[i] * 2; if (nx >= 0 && nx < 10 && y >= 0 && y < 10) { paper[nx][ny]++; } } break; } } int a = 0, b = 0; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (!paper[i][j]) { a++; } else { b = std::max(b, paper[i][j]); } } } std::cout << a << std::endl; std::cout << b << std::endl; return 0; }
#include <iostream> #include <stdio.h> int paper[10][10]; int vecx[] = {0, 1, 0, -1}, vecy[] = {-1, 0, 1, 0}; int main() { int x, y, size; while (scanf("%d,%d,%d", &x, &y, &size) != EOF) { switch (size) { case 1: paper[x][y]++; for (int i = 0; i < 4; i++) { int nx = x + vecx[i], ny = y + vecy[i]; if (nx >= 0 && nx < 10 && ny >= 0 && ny < 10) { paper[nx][ny]++; } } break; case 2: for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { if (x + i >= 0 && x + i < 10 && y + j >= 0 && y + j < 10) { paper[x + i][y + j]++; } } } break; case 3: for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { if (x + i >= 0 && x + i < 10 && y + j >= 0 && y + j < 10) { paper[x + i][y + j]++; } } } for (int i = 0; i < 4; i++) { int nx = x + vecx[i] * 2, ny = y + vecy[i] * 2; if (nx >= 0 && nx < 10 && ny >= 0 && ny < 10) { paper[nx][ny]++; } } break; } } int a = 0, b = 0; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (!paper[i][j]) { a++; } else { b = std::max(b, paper[i][j]); } } } std::cout << a << std::endl; std::cout << b << std::endl; return 0; }
[["-", 15, 339, 51, 16, 31, 16, 12, 16, 31, 22], ["+", 15, 339, 51, 16, 31, 16, 12, 16, 31, 22], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22]]
1
485
8
#include <cstring> #include <iostream> using namespace std; int f[10][10]; void solve() {} int dx[] = {1, 0, -1, 0, 1, 1, -1, -1, 2, 0, -2, 0}; int dy[] = {0, 1, 0, -1, 1, -1, 1, -1, 0, 2, 0, -2}; int cnt, d; void ink(int x, int y, int s) { for (int i = 0; i < 4 * s; i++) { int nx = dx[i] + x; int ny = dy[i] + y; if (nx < 0 || nx >= 10 || ny < 0 || ny >= 10) continue; f[ny][nx]++; if (f[ny][nx] == 1) cnt++; d = max(d, f[ny][nx]); } } int main() { int x, y, size; cnt = d = 0; char c; memset(f, 0, sizeof(f)); while (cin >> x >> c >> y >> c >> size) { ink(x, y, size); } cout << 100 - cnt << endl << d << endl; return 0; }
#include <cstring> #include <iostream> using namespace std; int f[10][10]; void solve() {} int dx[] = {0, 1, 0, -1, 0, 1, 1, -1, -1, 2, 0, -2, 0}; int dy[] = {0, 0, 1, 0, -1, 1, -1, 1, -1, 0, 2, 0, -2}; int cnt, d; void ink(int x, int y, int s) { for (int i = 0; i <= 4 * s; i++) { int nx = dx[i] + x; int ny = dy[i] + y; if (nx < 0 || nx >= 10 || ny < 0 || ny >= 10) continue; f[ny][nx]++; if (f[ny][nx] == 1) cnt++; d = max(d, f[ny][nx]); } } int main() { int x, y, size; cnt = d = 0; char c; memset(f, 0, sizeof(f)); while (cin >> x >> c >> y >> c >> size) { ink(x, y, size); } cout << 100 - cnt << endl << d << endl; return 0; }
[["+", 0, 30, 0, 43, 49, 50, 51, 83, 0, 13], ["+", 0, 30, 0, 43, 49, 50, 51, 83, 0, 21], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
1
275
6
#include <ctype.h> #include <iostream> #include <math.h> #include <stdio.h> #include <string> using namespace std; int main() { int a[10][10] = {0}; int x, y, size; while (scanf("%d,%d,%d", &x, &y, &size) != EOF) { // size=1 if (size >= 1) { a[x][y]++; if (x - 1 > -1) { a[x - 1][y]++; } if (y - 1 > -1) { a[x][y - 1]++; } if (x + 1 < 10) { a[x + 1][y]++; } if (y + 1 < 10) { a[x][y + 1]++; } } // size=2 if (size >= 2) { if (x - 1 > -1 && y - 1 > -1) { a[x - 1][y - 1]++; } if (x + 1 < 10 && y - 1 > -1) { a[x + 1][y - 1]++; } if (x + 1 < 10 && y + 1 < 10) { a[x + 1][y + 1]++; } if (x - 1 > -1 && y + 1 < 10) { a[x - 1][y + 1]++; } } // size=3 if (size >= 3) { if (x - 2 > -1) { a[x - 2][y]++; } if (y - 2 > -1) { a[x][y - 2]++; } if (x + 2 < 10) { a[x + 2][y]++; } if (y + 2 < 10) { a[x][y + 2]++; } } } int white = 0; int max = 0; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (a[i][j] == 0) { white++; } if (a[i][j] > max) { max = a[i][j]; } } } cout << white << " " << max << endl; return 0; }
#include <ctype.h> #include <iostream> #include <math.h> #include <stdio.h> #include <string> using namespace std; int main() { int a[10][10] = {0}; int x, y, size; while (scanf("%d,%d,%d", &x, &y, &size) != EOF) { // size=1 if (size >= 1) { a[x][y]++; if (x - 1 > -1) { a[x - 1][y]++; } if (y - 1 > -1) { a[x][y - 1]++; } if (x + 1 < 10) { a[x + 1][y]++; } if (y + 1 < 10) { a[x][y + 1]++; } } // size=2 if (size >= 2) { if (x - 1 > -1 && y - 1 > -1) { a[x - 1][y - 1]++; } if (x + 1 < 10 && y - 1 > -1) { a[x + 1][y - 1]++; } if (x + 1 < 10 && y + 1 < 10) { a[x + 1][y + 1]++; } if (x - 1 > -1 && y + 1 < 10) { a[x - 1][y + 1]++; } } // size=3 if (size >= 3) { if (x - 2 > -1) { a[x - 2][y]++; } if (y - 2 > -1) { a[x][y - 2]++; } if (x + 2 < 10) { a[x + 2][y]++; } if (y + 2 < 10) { a[x][y + 2]++; } } } int white = 0; int max = 0; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (a[i][j] == 0) { white++; } if (a[i][j] > max) { max = a[i][j]; } } } cout << white << endl << max << endl; return 0; }
[["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 62], ["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 31, 16, 12, 22]]
1
480
4
#include <cstdio> #include <iostream> #include <stdio.h> using namespace std; int main() { int x, y, s, count = 0; int paper[14][14] = {0}; while (scanf("%d,%d,%d", &x, &y, &s) != EOF) { if (s == 1 || s == 2 || s == 3) { paper[x + 2][y + 2]++; paper[x + 1][y + 2]++; paper[x + 3][y + 2]++; paper[x + 2][y + 1]++; paper[x + 2][y + 3]++; } else if (s == 2 || s == 3) { paper[x + 1][y + 1]++; paper[x + 1][y + 3]++; paper[x + 3][y + 1]++; paper[x + 3][y + 3]++; } else if (s == 3) { paper[x + 4][y + 2]++; paper[x + 2][y + 4]++; paper[x][y + 2]++; paper[x + 2][y]++; } } int a = 1; for (int i = 2; i < 12; i++) { for (int j = 2; j < 12; j++) { if (paper[i][j] == 0) count++; if (a < paper[i][j]) a = paper[i][j]; } } cout << count << endl; cout << a << endl; return 0; }
#include <cstdio> #include <iostream> #include <stdio.h> using namespace std; int main() { int x, y, s, count = 0; int paper[14][14] = {0}; while (scanf("%d,%d,%d", &x, &y, &s) != EOF) { if (s == 1 || s == 2 || s == 3) { paper[x + 2][y + 2]++; paper[x + 1][y + 2]++; paper[x + 3][y + 2]++; paper[x + 2][y + 1]++; paper[x + 2][y + 3]++; } if (s == 2 || s == 3) { paper[x + 1][y + 1]++; paper[x + 1][y + 3]++; paper[x + 3][y + 1]++; paper[x + 3][y + 3]++; } if (s == 3) { paper[x + 4][y + 2]++; paper[x + 2][y + 4]++; paper[x][y + 2]++; paper[x + 2][y]++; } } int a = 1; for (int i = 2; i < 12; i++) { for (int j = 2; j < 12; j++) { if (paper[i][j] == 0) count++; if (a < paper[i][j]) a = paper[i][j]; } } cout << count << endl; cout << a << endl; return 0; }
[["-", 0, 52, 8, 9, 0, 57, 75, 76, 0, 95], ["-", 0, 57, 75, 76, 0, 57, 75, 76, 0, 95]]
1
354
2
#include <algorithm> #include <cstdio> #include <iostream> using namespace std; #define XAXIS 10 #define YAXIS 10 int main() { int paper[XAXIS][YAXIS]; int x, y, s; int white = 0, most = 0; // initialize for (int i = 0; i < XAXIS; i++) for (int j = 0; j < YAXIS; j++) paper[i][j] = 0; while (scanf("%d,%d,%d", &x, &y, &s) != EOF) { switch (s) { case 3: if (x + 2 < XAXIS) paper[x + 2][y] += 1; // 2 right if (y + 2 < YAXIS) paper[x][y + 2] += 1; // 2 down if (x - 2 >= 0) paper[x - 2][y] += 1; // 2 left if (y - 2 >= 0) paper[x][y - 2] += 1; // 2 up case 2: if (x + 1 < XAXIS && y + 1 < YAXIS) paper[x + 1][y + 1] += 1; // right upper if (x + 1 < XAXIS && y - 1 > 0) paper[x + 1][y - 1] += 1; // right downer if (x - 1 >= 0 && y + 1 < YAXIS) paper[x - 1][y + 1] += 1; // left upper if (x - 1 >= 0 && y - 1 < 0) paper[x - 1][y - 1] += 1; // left downer case 1: if (x + 1 < XAXIS) paper[x + 1][y] += 1; // right if (y + 1 < YAXIS) paper[x][y + 1] += 1; // down if (x - 1 >= 0) paper[x - 1][y] += 1; // left if (y - 1 >= 0) paper[x][y - 1] += 1; // up paper[x][y] += 1; break; } } for (int i = 0; i < XAXIS; i++) for (int j = 0; j < YAXIS; j++) { if (paper[i][j] == 0) white++; most = max(most, paper[i][j]); } cout << white << endl << most << endl; return 0; }
#include <algorithm> #include <cstdio> #include <iostream> using namespace std; #define XAXIS 10 #define YAXIS 10 int main() { int paper[XAXIS][YAXIS]; int x, y, s; int white = 0, most = 0; for (int i = 0; i < XAXIS; i++) for (int j = 0; j < YAXIS; j++) paper[i][j] = 0; while (scanf("%d,%d,%d", &x, &y, &s) != EOF) { switch (s) { case 3: if (x + 2 < XAXIS) paper[x + 2][y] += 1; if (y + 2 < YAXIS) paper[x][y + 2] += 1; if (x - 2 >= 0) paper[x - 2][y] += 1; if (y - 2 >= 0) paper[x][y - 2] += 1; case 2: if (x + 1 < XAXIS && y + 1 < YAXIS) paper[x + 1][y + 1] += 1; if (x + 1 < XAXIS && y - 1 >= 0) paper[x + 1][y - 1] += 1; if (x - 1 >= 0 && y + 1 < YAXIS) paper[x - 1][y + 1] += 1; if (x - 1 >= 0 && y - 1 >= 0) paper[x - 1][y - 1] += 1; case 1: if (x + 1 < XAXIS) paper[x + 1][y] += 1; if (y + 1 < YAXIS) paper[x][y + 1] += 1; if (x - 1 >= 0) paper[x - 1][y] += 1; if (y - 1 >= 0) paper[x][y - 1] += 1; paper[x][y] += 1; break; } } for (int i = 0; i < XAXIS; i++) for (int j = 0; j < YAXIS; j++) { if (paper[i][j] == 0) white++; most = max(most, paper[i][j]); } cout << white << endl << most << endl; return 0; }
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 47], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 20], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 18]]
1
492
4
#include <algorithm> #include <cstdio> #include <iostream> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; int p[10][10]; int cnt = 0, Max = 0; void ink(int x, int y) { if (0 <= x && x < 10 || 0 <= y && y < 10) p[x][y]++; } int main() { rep(i, 10) rep(j, 10) { p[i][j] = 0; } int x, y, size; while (~scanf("%d,%d,%d", &x, &y, &size)) { if (size == 1) { ink(x, y); ink(x + 1, y); ink(x - 1, y); ink(x, y + 1); ink(x, y - 1); } else if (size == 2) { ink(x, y); ink(x + 1, y); ink(x - 1, y); ink(x, y + 1); ink(x, y - 1); ink(x + 1, y + 1); ink(x - 1, y + 1); ink(x - 1, y - 1); ink(x + 1, y - 1); } else if (size == 3) { ink(x, y); ink(x + 1, y); ink(x - 1, y); ink(x, y + 1); ink(x, y - 1); ink(x + 1, y + 1); ink(x - 1, y + 1); ink(x - 1, y - 1); ink(x + 1, y - 1); ink(x + 2, y); ink(x - 2, y); ink(x, y + 2); ink(x, y - 2); } cnt = Max = 0; rep(i, 10) rep(j, 10) { if (p[i][j] == 0) cnt++; Max = max(Max, p[i][j]); } } cout << cnt << "\n" << Max << endl; return 0; }
#include <algorithm> #include <cstdio> #include <iostream> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; int p[10][10]; int cnt = 0, Max = 0; void ink(int x, int y) { if (0 <= x && x < 10 && 0 <= y && y < 10) p[x][y]++; } int main() { rep(i, 10) rep(j, 10) { p[i][j] = 0; } int x, y, size; while (~scanf("%d,%d,%d", &x, &y, &size)) { if (size == 1) { ink(x, y); ink(x + 1, y); ink(x - 1, y); ink(x, y + 1); ink(x, y - 1); } else if (size == 2) { ink(x, y); ink(x + 1, y); ink(x - 1, y); ink(x, y + 1); ink(x, y - 1); ink(x + 1, y + 1); ink(x - 1, y + 1); ink(x - 1, y - 1); ink(x + 1, y - 1); } else if (size == 3) { ink(x, y); ink(x + 1, y); ink(x - 1, y); ink(x, y + 1); ink(x, y - 1); ink(x + 1, y + 1); ink(x - 1, y + 1); ink(x - 1, y - 1); ink(x + 1, y - 1); ink(x + 2, y); ink(x - 2, y); ink(x, y + 2); ink(x, y - 2); } cnt = 0; Max = -10000000; rep(i, 10) rep(j, 10) { if (p[i][j] == 0) cnt++; Max = max(Max, p[i][j]); } } cout << cnt << "\n" << Max << endl; return 0; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 106], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 98], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35], ["-", 8, 9, 0, 1, 0, 11, 12, 11, 12, 13]]
1
478
6
#include <algorithm> #include <iostream> #include <stdio.h> using namespace std; int pos[10][10]; /*void p(){ for(int i=0;i<10;++i){ for(int j=0;j<10;++j){ cout<<pos[i][j]<<" "; } cout<<endl; } cout<<endl; }*/ main() { int tmp[3], ink2[3] = {1, 1, 2}; int ink[3][5][5] = {{{0, 1, 0, 0, 0}, {1, 1, 1, 0, 0}, {0, 1, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}}, {{1, 1, 1, 0, 0}, {1, 1, 1, 0, 0}, {1, 1, 1, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}}, {{0, 0, 1, 0, 0}, {0, 1, 1, 1, 0}, {1, 1, 1, 1, 1}, {0, 1, 1, 1, 0}, {0, 0, 1, 0, 0}}}; for (int i = 0; i < 10; ++i) for (int j = 0; j < 10; ++j) pos[i][j] = 0; while (cin >> tmp[0]) { scanf(",%d,%d", &tmp[1], &tmp[2]); for (int i = 0; i < 5; ++i) { for (int j = 0; j < 5; ++j) { int t[2] = {tmp[0] - ink2[tmp[2] - 1] + i, tmp[1] - ink2[tmp[2] - 1] + j}; if (t[0] >= 0 && t[0] <= 9 && t[1] >= 0 && t[1] <= 9) { pos[t[0]][t[1]] += ink[tmp[2] - 1][i][j]; } } } } int ans[2] = {0, 0}; for (int i = 0; i < 10; ++i) { for (int j = 0; j < 10; ++j) { if (pos[i][j] == 0) ans[0]++; ans[1] = max(pos[i][j], ans[1]); } } cout << ans[0] << " " << ans[1] << endl; }
#include <algorithm> #include <iostream> #include <stdio.h> using namespace std; int pos[10][10]; /*void p(){ for(int i=0;i<10;++i){ for(int j=0;j<10;++j){ cout<<pos[i][j]<<" "; } cout<<endl; } cout<<endl; }*/ main() { int tmp[3], ink2[3] = {1, 1, 2}; int ink[3][5][5] = {{{0, 1, 0, 0, 0}, {1, 1, 1, 0, 0}, {0, 1, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}}, {{1, 1, 1, 0, 0}, {1, 1, 1, 0, 0}, {1, 1, 1, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}}, {{0, 0, 1, 0, 0}, {0, 1, 1, 1, 0}, {1, 1, 1, 1, 1}, {0, 1, 1, 1, 0}, {0, 0, 1, 0, 0}}}; for (int i = 0; i < 10; ++i) for (int j = 0; j < 10; ++j) pos[i][j] = 0; while (cin >> tmp[0]) { scanf(",%d,%d", &tmp[1], &tmp[2]); for (int i = 0; i < 5; ++i) { for (int j = 0; j < 5; ++j) { int t[2] = {tmp[0] - ink2[tmp[2] - 1] + i, tmp[1] - ink2[tmp[2] - 1] + j}; if (t[0] >= 0 && t[0] <= 9 && t[1] >= 0 && t[1] <= 9) { pos[t[0]][t[1]] += ink[tmp[2] - 1][i][j]; } } } } int ans[2] = {0, 0}; for (int i = 0; i < 10; ++i) { for (int j = 0; j < 10; ++j) { if (pos[i][j] == 0) ans[0]++; ans[1] = max(pos[i][j], ans[1]); } } cout << ans[0] << endl << ans[1] << endl; }
[["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 62], ["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 31, 16, 12, 22]]
1
549
4
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) int xy[10][10]; void set(int x, int y) { if (x >= 0 && y >= 0 && x <= 9 && y <= 9) xy[x][y]++; } int main(void) { int size, x, y, white, deep; while (~scanf("%d,%d,%d", &x, &y, &size)) { if (size >= 1) { set(x, y); set(x, y - 1); set(x, y + 1); set(x - 1, y); set(x + 1, y); } if (size >= 2) { set(x + 1, y + 1); set(x + 1, y - 1); set(x - 1, y + 1); set(x - 1, y + 1); } if (size == 3) { set(x + 2, y); set(x - 2, y); set(x, y + 2); set(x, y - 2); } } white = 0; deep = 0; rep(i, 10) { rep(j, 10) { if (xy[i][j] == 0) white++; if (deep < xy[i][j]) deep = xy[i][j]; } } cout << white << endl << deep << endl; return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) int xy[10][10]; void set(int x, int y) { if (x >= 0 && y >= 0 && x <= 9 && y <= 9) xy[x][y]++; } int main(void) { int size, x, y, white, deep; while (~scanf("%d,%d,%d", &x, &y, &size)) { if (size >= 1) { set(x, y); set(x, y - 1); set(x, y + 1); set(x - 1, y); set(x + 1, y); } if (size >= 2) { set(x + 1, y + 1); set(x + 1, y - 1); set(x - 1, y + 1); set(x - 1, y - 1); } if (size == 3) { set(x + 2, y); set(x - 2, y); set(x, y + 2); set(x, y - 2); } } white = 0; deep = 0; rep(i, 10) { rep(j, 10) { if (xy[i][j] == 0) white++; if (deep < xy[i][j]) deep = xy[i][j]; } } cout << white << endl << deep << endl; return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33]]
1
328
2
#include <iostream> using namespace std; int ds[3] = {4, 9, 13}; int dx[13] = {0, -1, 0, 1, 0, -1, 1, -1, 1, 0, -2, 2, 0}; int dy[13] = {-1, 0, 0, 0, 1, -1, -1, 1, 1, -2, 0, 0, 2}; int main() { int x, y, size; char c; int map[14][14] = {0}; int cnt = 0; int map_max = 0; while (cin >> x >> c >> y >> c >> size) { for (int i = 0; i < ds[size - 1]; i++) { map[x + 2 + dx[i]][y + 2 + dy[i]]++; } } for (int i = 2; i < 12; i++) { for (int j = 2; j < 12; j++) { if (map[i][j] == 0) cnt++; map_max = max(map_max, map[i][j]); } } cout << cnt << endl << map_max << endl; return 0; }
#include <iostream> using namespace std; int ds[3] = {5, 9, 13}; int dx[13] = {0, -1, 0, 1, 0, -1, 1, -1, 1, 0, -2, 2, 0}; int dy[13] = {-1, 0, 0, 0, 1, -1, -1, 1, 1, -2, 0, 0, 2}; int main() { int x, y, size; char c; int map[14][14] = {0}; int cnt = 0; int map_max = 0; while (cin >> x >> c >> y >> c >> size) { for (int i = 0; i < ds[size - 1]; i++) { map[x + 2 + dx[i]][y + 2 + dy[i]]++; } } for (int i = 2; i < 12; i++) { for (int j = 2; j < 12; j++) { if (map[i][j] == 0) cnt++; map_max = max(map_max, map[i][j]); } } cout << cnt << endl << map_max << endl; return 0; }
[["-", 0, 30, 0, 43, 49, 50, 51, 83, 0, 13], ["+", 0, 30, 0, 43, 49, 50, 51, 83, 0, 13]]
1
262
2
#include <cstdio> #include <iostream> using namespace std; int main() { int x, y, s; int p[14][14] = {0}; while (scanf("%d,%d,%d", &x, &y, &s) > 0) { x += 2; y += 2; p[x][y] += 1; p[x + 1][y] += 1; p[x][y - 1] += 1; p[x][y + 1] += 1; p[x - 1][y] += 1; if (s == 1) continue; p[x + 1][y + 1] += 1; p[x + 1][y - 1] += 1; p[x - 1][y + 1] += 1; p[x - 1][y + 1] += 1; if (s == 2) continue; p[x + 2][y] += 1; p[x - 2][y] += 1; p[x][y + 2] += 1; p[x][y - 2] += 1; } int cnt = 0, max = 0; for (int i = 2; i < 12; i++) { for (int j = 2; j < 12; j++) { if (p[j][i] == 0) cnt++; if (max < p[j][i]) max = p[j][i]; } } cout << cnt << endl << max << endl; return 0; }
#include <cstdio> #include <iostream> using namespace std; int main() { int x, y, s; int p[14][14] = {0}; while (scanf("%d,%d,%d", &x, &y, &s) > 0) { x += 2; y += 2; p[x][y] += 1; p[x + 1][y] += 1; p[x][y - 1] += 1; p[x][y + 1] += 1; p[x - 1][y] += 1; if (s == 1) continue; p[x + 1][y + 1] += 1; p[x + 1][y - 1] += 1; p[x - 1][y + 1] += 1; p[x - 1][y - 1] += 1; if (s == 2) continue; p[x + 2][y] += 1; p[x - 2][y] += 1; p[x][y + 2] += 1; p[x][y - 2] += 1; } int cnt = 0, max = 0; for (int i = 2; i < 12; i++) { for (int j = 2; j < 12; j++) { if (p[j][i] == 0) cnt++; if (max < p[j][i]) max = p[j][i]; } } cout << cnt << endl << max << endl; return 0; }
[["-", 0, 11, 31, 69, 341, 342, 0, 16, 17, 72], ["+", 0, 11, 31, 69, 341, 342, 0, 16, 17, 33]]
1
333
2
#include <algorithm> #include <cstdio> #include <iostream> using namespace std; int grid[14][14] = {0}; void small(int x, int y) { grid[x][y]++; grid[x - 1][y]++; grid[x + 1][y]++; grid[x][y - 1]++; grid[x][y + 1]++; } void medium(int x, int y) { small(x, y); grid[x - 1][y - 1]++; grid[x + 1][y - 1]++; grid[x - 1][y + 1]++; grid[x + 1][y + 1]++; } void large(int x, int y) { medium(x, y); grid[x - 2][y]++; grid[x + 2][y]++; grid[x][y - 2]++; grid[x][y + 2]++; } int main() { int x, y, size; while (scanf("%d,%d,%d", &x, &y, &size) != EOF) { if (size == 1) small(x + 2, y + 2); else if (size == 2) medium(x + 2, y + 2); else if (size == 3) large(x + 2, y + 2); } int ans1 = 0; int ans2 = 0; for (int i = 2; i < 10; i++) { for (int j = 2; j < 10; j++) { if (grid[i][j] == 0) ans1++; else ans2 = max(ans2, grid[i][j]); } } printf("%d\n%d\n", ans1, ans2); return 0; }
#include <algorithm> #include <cstdio> #include <iostream> using namespace std; int grid[14][14] = {0}; void small(int x, int y) { grid[x][y]++; grid[x - 1][y]++; grid[x + 1][y]++; grid[x][y - 1]++; grid[x][y + 1]++; } void medium(int x, int y) { small(x, y); grid[x - 1][y - 1]++; grid[x + 1][y - 1]++; grid[x - 1][y + 1]++; grid[x + 1][y + 1]++; } void large(int x, int y) { medium(x, y); grid[x - 2][y]++; grid[x + 2][y]++; grid[x][y - 2]++; grid[x][y + 2]++; } int main() { int x, y, size; while (scanf("%d,%d,%d", &x, &y, &size) != EOF) { if (size == 1) small(x + 2, y + 2); else if (size == 2) medium(x + 2, y + 2); else if (size == 3) large(x + 2, y + 2); } int ans1 = 0; int ans2 = 0; for (int i = 2; i < 12; i++) { for (int j = 2; j < 12; j++) { if (grid[i][j] == 0) ans1++; else ans2 = max(ans2, grid[i][j]); } } printf("%d\n%d\n", ans1, ans2); return 0; }
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13]]
1
397
4
#include <iostream> #include <vector> using namespace std; constexpr int paper_w = 10, paper_h = 10; constexpr int ink_w = 5, ink_h = 5; int inkarea[3][ink_h][ink_w] = { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0}; int main() { int paper[paper_h][paper_w] = {0}; int x, y, size; char c; while (cin >> x >> c >> y >> c >> size) { for (int i = 0; i < ink_h; i++) { for (int j = 0; j < ink_w; j++) { int ink_x = x + j - 2, ink_y = y + i - 2; if (ink_y < 0 || paper_h <= ink_y || ink_x < 0 || paper_w <= ink_x) continue; paper[ink_y][ink_x] += inkarea[size - 1][i][j]; } } int white = 0, density = 0; for (int i = 0; i < paper_h; i++) { for (int j = 0; j < paper_w; j++) { if (!paper[i][j]) white++; if (density < paper[i][j]) density = paper[i][j]; } } cout << white << endl; cout << density << endl; } }
#include <iostream> #include <vector> using namespace std; constexpr int paper_w = 10, paper_h = 10; constexpr int ink_w = 5, ink_h = 5; int inkarea[3][ink_h][ink_w] = { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0}; int main() { int paper[paper_h][paper_w] = {0}; int x, y, size; char c; while (cin >> x >> c >> y >> c >> size) { for (int i = 0; i < ink_h; i++) { for (int j = 0; j < ink_w; j++) { int ink_x = x + j - 2, ink_y = y + i - 2; if (ink_y < 0 || paper_h <= ink_y || ink_x < 0 || paper_w <= ink_x) continue; paper[ink_y][ink_x] += inkarea[size - 1][i][j]; } } } int white = 0, density = 0; for (int i = 0; i < paper_h; i++) { for (int j = 0; j < paper_w; j++) { if (!paper[i][j]) white++; if (density < paper[i][j]) density = paper[i][j]; } } cout << white << endl; cout << density << endl; }
[["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46], ["-", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
1
416
2
#include <cmath> #include <cstdio> #include <iostream> using namespace std; // int dx[] = {0,1,0,-1}, dy[] = {1,0,-1,0}; int main() { int x, y, s; int board[10][10] = {{0}}; while (~scanf("%d,%d,%d", &x, &y, &s)) { if (s == 3) { for (int i = -2; i < 3; i++) { for (int j = -2; j < 3; j++) { if (abs(i) + abs(j) < 3 && 0 < x + j && x + j < 10 && 0 < y + i && y + i < 10) board[y + i][x + j]++; } } } else if (s == 2) { for (int i = -1; i < 2; i++) { for (int j = -1; j < 2; j++) { if (0 < x + j && x + j < 10 && 0 < y + i && y + i < 10) board[y + i][x + j]++; } } } else { for (int i = -1; i < 2; i++) { for (int j = -1; j < 2; j++) { if (abs(i) + abs(j) < 2 && 0 < x + j && x + j < 10 && 0 < y + i && y + i < 10) board[y + i][x + j]++; } } } } int max_c = 0, white = 0; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (board[i][j] == 0) white++; max_c = max(max_c, board[i][j]); } } cout << white << endl; cout << max_c << endl; }
#include <cmath> #include <cstdio> #include <iostream> using namespace std; // int dx[] = {0,1,0,-1}, dy[] = {1,0,-1,0}; int main() { int x, y, s; int board[10][10] = {{0}}; while (~scanf("%d,%d,%d", &x, &y, &s)) { if (s == 3) { for (int i = -2; i < 3; i++) { for (int j = -2; j < 3; j++) { if (abs(i) + abs(j) < 3 && 0 <= x + j && x + j < 10 && 0 <= y + i && y + i < 10) board[y + i][x + j]++; } } } else if (s == 2) { for (int i = -1; i < 2; i++) { for (int j = -1; j < 2; j++) { if (0 <= x + j && x + j < 10 && 0 <= y + i && y + i < 10) board[y + i][x + j]++; } } } else { for (int i = -1; i < 2; i++) { for (int j = -1; j < 2; j++) { if (abs(i) + abs(j) < 2 && 0 <= x + j && x + j < 10 && 0 <= y + i && y + i < 10) board[y + i][x + j]++; } } } } int max_c = 0, white = 0; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (board[i][j] == 0) white++; max_c = max(max_c, board[i][j]); } } cout << white << endl; cout << max_c << endl; }
[["-", 31, 16, 31, 16, 31, 16, 12, 16, 17, 18], ["+", 31, 16, 31, 16, 31, 16, 12, 16, 17, 19], ["-", 15, 339, 51, 16, 31, 16, 12, 16, 17, 18], ["+", 15, 339, 51, 16, 31, 16, 12, 16, 17, 19], ["-", 51, 16, 31, 16, 31, 16, 31, 16, 17, 18], ["+", 51, 16, 31, 16, 31, 16, 31, 16, 17, 19]]
1
400
12
// include //------------------------------------------ #include <bits/stdc++.h> // only for GCC using namespace std; // typedef //------------------------------------------ typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<string> vs; typedef vector<bool> vb; typedef vector<vb> vvb; typedef pair<int, int> pii; typedef long long ll; typedef unsigned long long ull; // container util //------------------------------------------ #define all(a) (a).begin(), (a).end() #define rall(a) (a).rbegin(), (a).rend() #define pb push_back #define mp make_pair // repetition //------------------------------------------ #define loop(i, a, b) for (ull i = (a); i < ull(b); ++i) #define rep(i, n) loop(i, 0, n) #define iter(i, c) for (auto i = (c).begin(); i != (c).end(); ++i) #define riter(i, c) for (auto i = (c).rbegin(); i != (c).rend(); ++i) // constant //-------------------------------------------- const double eps = 1e-10; const double pi = acos(-1.0); const double inf = (int)1e8; // output vector // ------------------------------------------ namespace std { template <typename T> ostream &operator<<(ostream &os, vector<T> const &v) { iter(it, v) os << *it << (it + 1 == v.end() ? "" : ","); return os; } template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) { return os << "[" << p.dirst << "," << p.second << "]"; } } // namespace std // clear memory // ------------------------------------------ #define clr(a, i) memset((a), (i), sizeof(a)) int main() { int x, y, s; char c; int a[14][14] = {0}; while (cin >> x >> c >> y >> c >> s) { if (s == 1) { a[x + 2][y + 2]++; a[x + 1][y + 2]++; a[x + 2][y + 1]++; a[x + 3][y + 2]++; a[x + 2][y + 3]++; } if (s == 1) { a[x + 1][y + 1]++; a[x + 1][y + 2]++; a[x + 1][y + 3]++; a[x + 2][y + 1]++; a[x + 2][y + 2]++; a[x + 2][y + 3]++; a[x + 3][y + 1]++; a[x + 3][y + 2]++; a[x + 3][y + 3]++; } if (s == 2) { a[x + 1][y + 1]++; a[x + 1][y + 2]++; a[x + 1][y + 3]++; a[x + 2][y + 1]++; a[x + 2][y + 2]++; a[x + 2][y + 3]++; a[x + 3][y + 1]++; a[x + 3][y + 2]++; a[x + 3][y + 3]++; a[x][y + 2]++; a[x + 2][y]++; a[x + 2][y + 4]++; a[x + 4][y + 2]++; } } int max = 0, sum = 0; loop(i, 2, 12) loop(j, 2, 12) { if (a[i][j] == 0) sum++; if (a[i][j] > max) max = a[i][j]; } cout << sum << endl; cout << max << endl; }
// include //------------------------------------------ #include <bits/stdc++.h> // only for GCC using namespace std; // typedef //------------------------------------------ typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<string> vs; typedef vector<bool> vb; typedef vector<vb> vvb; typedef pair<int, int> pii; typedef long long ll; typedef unsigned long long ull; // container util //------------------------------------------ #define all(a) (a).begin(), (a).end() #define rall(a) (a).rbegin(), (a).rend() #define pb push_back #define mp make_pair // repetition //------------------------------------------ #define loop(i, a, b) for (ull i = (a); i < ull(b); ++i) #define rep(i, n) loop(i, 0, n) #define iter(i, c) for (auto i = (c).begin(); i != (c).end(); ++i) #define riter(i, c) for (auto i = (c).rbegin(); i != (c).rend(); ++i) // constant //-------------------------------------------- const double eps = 1e-10; const double pi = acos(-1.0); const double inf = (int)1e8; // output vector // ------------------------------------------ namespace std { template <typename T> ostream &operator<<(ostream &os, vector<T> const &v) { iter(it, v) os << *it << (it + 1 == v.end() ? "" : ","); return os; } template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) { return os << "[" << p.dirst << "," << p.second << "]"; } } // namespace std // clear memory // ------------------------------------------ #define clr(a, i) memset((a), (i), sizeof(a)) int main() { int x, y, s; char c; int a[14][14] = {0}; while (cin >> x >> c >> y >> c >> s) { if (s == 1) { a[x + 2][y + 2]++; a[x + 1][y + 2]++; a[x + 2][y + 1]++; a[x + 3][y + 2]++; a[x + 2][y + 3]++; } if (s == 2) { a[x + 1][y + 1]++; a[x + 1][y + 2]++; a[x + 1][y + 3]++; a[x + 2][y + 1]++; a[x + 2][y + 2]++; a[x + 2][y + 3]++; a[x + 3][y + 1]++; a[x + 3][y + 2]++; a[x + 3][y + 3]++; } if (s == 3) { a[x + 1][y + 1]++; a[x + 1][y + 2]++; a[x + 1][y + 3]++; a[x + 2][y + 1]++; a[x + 2][y + 2]++; a[x + 2][y + 3]++; a[x + 3][y + 1]++; a[x + 3][y + 2]++; a[x + 3][y + 3]++; a[x][y + 2]++; a[x + 2][y]++; a[x + 2][y + 4]++; a[x + 4][y + 2]++; } } int max = 0, sum = 0; loop(i, 2, 12) loop(j, 2, 12) { if (a[i][j] == 0) sum++; if (a[i][j] > max) max = a[i][j]; } cout << sum << endl; cout << max << endl; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
768
4
map = Array.new() 10.times do |i| map << Array.new(10,0) end while line = gets x,y,size = line.split(",").map(&:to_i) map[x][y] += 1 map[x+1][y] += 1 if x < 9 map[x-1][y] += 1 if x > 0 map[x][y+1] += 1 if y < 9 map[x][y-1] += 1 if y > 0 next if size == 1 map[x+1][y+1] += 1 if x < 9 && y < 9 map[x+1][y-1] += 1 if x < 9 && y > 0 map[x-1][y+1] += 1 if x > 0 && y < 9 map[x-1][y-1] += 1 if x > 0 && y > 9 next if size == 2 map[x+2][y] += 1 if x < 8 map[x-2][y] += 1 if x > 1 map[x][y+2] += 1 if y < 8 map[x][y-2] += 1 if y > 1 end c = 0 deep = 0 map.each do |row| max = row.max deep = max if max > deep c += row.count(0) end puts c puts deep
require "pp" map = Array.new() 10.times do |i| map << Array.new(10,0) end while line = gets x,y,size = line.split(",").map(&:to_i) map[x][y] += 1 map[x+1][y] += 1 if x < 9 map[x-1][y] += 1 if x > 0 map[x][y+1] += 1 if y < 9 map[x][y-1] += 1 if y > 0 next if size == 1 map[x+1][y+1] += 1 if x < 9 && y < 9 map[x+1][y-1] += 1 if x < 9 && y > 0 map[x-1][y+1] += 1 if x > 0 && y < 9 map[x-1][y-1] += 1 if x > 0 && y > 0 next if size == 2 map[x+2][y] += 1 if x < 8 map[x-2][y] += 1 if x > 1 map[x][y+2] += 1 if y < 8 map[x][y-2] += 1 if y > 1 end c = 0 deep = 0 map.each do |row| max = row.max deep = max if max > deep c += row.count(0) end puts c puts deep
[["+", 36, 36, 36, 36, 0, 493, 0, 652, 735, 22], ["+", 0, 493, 0, 652, 3, 4, 0, 557, 0, 62], ["+", 0, 493, 0, 652, 3, 4, 0, 557, 0, 6], ["-", 8, 170, 0, 751, 15, 738, 12, 738, 12, 612], ["+", 8, 170, 0, 751, 15, 738, 12, 738, 12, 612]]
4
311
6
# Paper class Paper def initialize(x, y) @x, @y, @grids = x, y, Array.new(x) { Array.new(y, 0) } end def dye(x, y, size) case size when 1 dense(x, y) dense(x, y - 1) dense(x + 1, y) dense(x, y + 1) dense(x - 1, y) when 2 dense(x, y) dense(x, y - 1) dense(x + 1, y - 1) dense(x + 1, y) dense(x + 1, y + 1) dense(x, y + 1) dense(x - 1, y + 1) dense(x - 1, y) dense(x - 1, y - 1) when 3 dense(x, y) dense(x, y - 1) dense(x + 1, y - 1) dense(x + 1, y) dense(x + 1, y + 1) dense(x, y + 1) dense(x - 1, y + 1) dense(x - 1, y) dense(x - 1, y - 1) dense(x, y - 2) dense(x + 2, y) dense(x, y + 2) dense(x - 2, y) end end def graph @grids.transpose.each do |row| puts row.join(' ') end end def dense(x, y, density = 1) @grids[x][y] += density if exists?(x, y) end def exists?(x, y) 0 <= x && x <= @x - 1 && 0 <= y && y <= @y - 1 end def max_density max_density = 0 @grids.each do |item| max_density = [max_density, item.max].max end max_density end def while_grids_sum while_grids_sum = 0 @grids.each do |item| while_grids_sum += item.select { |x| x == 0 }.size end end end paper = Paper.new(10, 10) while line = gets x, y, size = line.chomp.split(',').map(&:to_i) paper.dye(x, y, size) end puts paper.while_grids_sum puts paper.max_density
# Paper class Paper def initialize(x, y) @x, @y, @grids = x, y, Array.new(x) { Array.new(y, 0) } end def dye(x, y, size) case size when 1 dense(x, y) dense(x, y - 1) dense(x + 1, y) dense(x, y + 1) dense(x - 1, y) when 2 dense(x, y) dense(x, y - 1) dense(x + 1, y - 1) dense(x + 1, y) dense(x + 1, y + 1) dense(x, y + 1) dense(x - 1, y + 1) dense(x - 1, y) dense(x - 1, y - 1) when 3 dense(x, y) dense(x, y - 1) dense(x + 1, y - 1) dense(x + 1, y) dense(x + 1, y + 1) dense(x, y + 1) dense(x - 1, y + 1) dense(x - 1, y) dense(x - 1, y - 1) dense(x, y - 2) dense(x + 2, y) dense(x, y + 2) dense(x - 2, y) end end def graph @grids.transpose.each do |row| puts row.join(' ') end end def dense(x, y, density = 1) @grids[x][y] += density if exists?(x, y) end def exists?(x, y) 0 <= x && x <= @x - 1 && 0 <= y && y <= @y - 1 end def max_density max_density = 0 @grids.each do |item| max_density = [max_density, item.max].max end max_density end def while_grids_sum while_grids_sum = 0 @grids.each do |item| while_grids_sum += item.select { |x| x == 0 }.size end while_grids_sum end end paper = Paper.new(10, 10) while line = gets x, y, size = line.chomp.split(',').map(&:to_i) paper.dye(x, y, size) end puts paper.while_grids_sum puts paper.max_density
[["+", 0, 269, 8, 736, 0, 735, 8, 736, 0, 22]]
4
470
33
#!/usr/bin/ruby @paper = Array.new(10) @paper.map!{|c| c = Array.new(10, 0) } @patt = [[[-1,0],[0,-1],[0,0],[0,1],[1,0]], \ [[-1,-1],[-1,1],[1,1],[1,-1]], \ [[0,-2],[-2,0],[2,0],[0,2]]] def drop(x, y, num) @patt[num].each do |xa, ya| next unless [x+xa, y+ya].any?{|x| (0...10) === x} @paper[x+xa][y+ya] += 1 end end until gets.nil? x, y, size = $_.split(?,).map(&:to_i) drop(x, y, 0) drop(x, y, 1) if size > 1 drop(x, y, 2) if size > 2 end puts @paper.flatten.count(0), @paper.flatten.max
#!/usr/bin/ruby @paper = Array.new(10) @paper.map!{|c| c = Array.new(10, 0) } @patt = [[[-1,0],[0,-1],[0,0],[0,1],[1,0]], \ [[-1,-1],[-1,1],[1,1],[1,-1]], \ [[0,-2],[-2,0],[2,0],[0,2]]] def drop(x, y, num) @patt[num].each do |xa, ya| next unless [x+xa, y+ya].all?{|x| (0...10) === x} @paper[x+xa][y+ya] += 1 end end until gets.nil? x, y, size = $_.split(?,).map(&:to_i) drop(x, y, 0) drop(x, y, 1) if size > 1 drop(x, y, 2) if size > 2 end puts @paper.flatten.count(0), @paper.flatten.max
[["-", 196, 737, 8, 736, 0, 745, 15, 652, 735, 22], ["+", 196, 737, 8, 736, 0, 745, 15, 652, 735, 22]]
4
255
2
# -*- coding: utf-8 -*- import sys def small_inc(x, y, cells): cells[x][y] += 1 if y > 0: cells[x][y-1] += 1 if x > 0: cells[x-1][y] += 1 if x < MAPSIZE-1: cells[x+1][y] += 1 if y < MAPSIZE-1: cells[x][y+1] += 1 def medium_inc(x, y, cells): if y > 0: cells[x][y-1] += 1 if x > 0: cells[x-1][y-1] += 1 if x < MAPSIZE-1: cells[x+1][y-1] += 1 cells[x][y] += 1 if x > 0: cells[x-1][y] += 1 if x < MAPSIZE-1: cells[x+1][y] += 1 if y < MAPSIZE-1: cells[x][y-1] += 1 if x > 0: cells[x-1][y+1] += 1 if x < MAPSIZE-1: cells[x+1][y+1] += 1 def large_inc(x, y, cells): if y > 1: cells[x][y-2] += 1 if y > 0: cells[x][y-1] += 1 if x > 0: cells[x-1][y-1] += 1 if x < MAPSIZE-1: cells[x+1][y-1] += 1 cells[x][y] += 1 if x > 1: cells[x-2][y] += 1 if x > 0: cells[x-1][y] += 1 if x < MAPSIZE-1: cells[x+1][y] += 1 if x < MAPSIZE-2: cells[x+2][y] += 1 if y < MAPSIZE-1: cells[x][y-1] += 1 if x > 0: cells[x-1][y+1] += 1 if x < MAPSIZE-1: cells[x+1][y+1] += 1 if y < MAPSIZE-2: cells[x][y+2] += 1 SMALL = 1 MEDIUM = 2 LARGE = 3 MAPSIZE = 10 cells = [[0 for i in range(MAPSIZE)] for j in range(MAPSIZE)] for line in sys.stdin: x , y, size = list(map(int, line.split(','))) if size == SMALL: small_inc(x, y, cells) elif size == MEDIUM: medium_inc(x, y, cells) elif size == LARGE: large_inc(x, y, cells) count = max_d = 0 for i in range(MAPSIZE): for j in range(MAPSIZE): if cells[i][j] == 0: count += 1 else: max_d = max(max_d, cells[i][j]) print(count) print(max_d)
# -*- coding: utf-8 -*- import sys def small_inc(x, y, cells): cells[x][y] += 1 if y > 0: cells[x][y-1] += 1 if x > 0: cells[x-1][y] += 1 if x < MAPSIZE-1: cells[x+1][y] += 1 if y < MAPSIZE-1: cells[x][y+1] += 1 def medium_inc(x, y, cells): if y > 0: cells[x][y-1] += 1 if x > 0: cells[x-1][y-1] += 1 if x < MAPSIZE-1: cells[x+1][y-1] += 1 cells[x][y] += 1 if x > 0: cells[x-1][y] += 1 if x < MAPSIZE-1: cells[x+1][y] += 1 if y < MAPSIZE-1: cells[x][y+1] += 1 if x > 0: cells[x-1][y+1] += 1 if x < MAPSIZE-1: cells[x+1][y+1] += 1 def large_inc(x, y, cells): if y > 1: cells[x][y-2] += 1 if y > 0: cells[x][y-1] += 1 if x > 0: cells[x-1][y-1] += 1 if x < MAPSIZE-1: cells[x+1][y-1] += 1 cells[x][y] += 1 if x > 1: cells[x-2][y] += 1 if x > 0: cells[x-1][y] += 1 if x < MAPSIZE-1: cells[x+1][y] += 1 if x < MAPSIZE-2: cells[x+2][y] += 1 if y < MAPSIZE-1: cells[x][y+1] += 1 if x > 0: cells[x-1][y+1] += 1 if x < MAPSIZE-1: cells[x+1][y+1] += 1 if y < MAPSIZE-2: cells[x][y+2] += 1 SMALL = 1 MEDIUM = 2 LARGE = 3 MAPSIZE = 10 cells = [[0 for i in range(MAPSIZE)] for j in range(MAPSIZE)] for line in sys.stdin: x , y, size = list(map(int, line.split(','))) if size == SMALL: small_inc(x, y, cells) elif size == MEDIUM: medium_inc(x, y, cells) elif size == LARGE: large_inc(x, y, cells) count = max_d = 0 for i in range(MAPSIZE): for j in range(MAPSIZE): if cells[i][j] == 0: count += 1 else: max_d = max(max_d, cells[i][j]) print(count) print(max_d)
[["-", 0, 1, 0, 677, 31, 206, 206, 657, 17, 33], ["+", 0, 1, 0, 677, 31, 206, 206, 657, 17, 72]]
5
644
4
d = [[0] * 10 for i in range(10)] def b(x, y): for i in range(x - 2, x + 3): a = 3 - abs(x - i) for a in range(y - a + 1, y + a): if 0 <= i < 10 and 0 <= a < 10: d[a][i] += 1 def m(x, y): for i in range(x - 1, x + 2): for j in range(y - 1, y + 2): if 0 <= i < 10 and 0 <= j < 10: d[j][i] += 1 def s(x, y): r = (1, 0) for i in range(x - 1, x + 2): a = abs(x - i) for j in range(y - r[a], y + r[a] + 1): if 0 <= i < 10 and 0 <= j < 10: d[j][i] += 1 while 1: try: f = (None, s, m, b) x, y, size = list(map(int, input().split(','))) f[size](x, y) except: break r1 = r2 = 0 for i in range(10): for j in range(10): r1 += 1 if d[i][j] == 0 else 0 r2 = max(r2, d[i][j]) print(r1, r2)
d = [[0] * 10 for i in range(10)] def b(x, y): for i in range(x - 2, x + 3): a = 3 - abs(x - i) for a in range(y - a + 1, y + a): if 0 <= i < 10 and 0 <= a < 10: d[a][i] += 1 def m(x, y): for i in range(x - 1, x + 2): for j in range(y - 1, y + 2): if 0 <= i < 10 and 0 <= j < 10: d[j][i] += 1 def s(x, y): r = (1, 0) for i in range(x - 1, x + 2): a = abs(x - i) for j in range(y - r[a], y + r[a] + 1): if 0 <= i < 10 and 0 <= j < 10: d[j][i] += 1 while 1: try: f = (None, s, m, b) x, y, size = list(map(int, input().split(','))) f[size](x, y) except: break r1 = r2 = 0 for i in range(10): for j in range(10): r1 += 1 if d[i][j] == 0 else 0 r2 = max(r2, d[i][j]) print(r1) print(r2)
[["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 21], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25], ["+", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24]]
5
333
4
a = [[0] * 14 for _ in range(14)] while True: try: x, y, s = map(int, input().split(',')) except: break x += 2 y += 2 for d in [(0, 0), (0, -1), (0, 1), (-1, 0), (1, 0)]: a[x + d[0]][y + d[1]] += 1 if s >= 2: for d in [(1, 1), (1, -1), (-1, 1), (-1, -1)]: a[x + d[0]][y + d[1]] += 1 if s == 3: for d in [(0, 2), (0, -2), (2, 0), (-2, 0)]: a[x + d[0]][y + d[1]] += 1 print(sum(a[i][2:12].count(0) for i in range(2, 12))) print(max(max(a[i][2:12]) for i in range(2, 12))) print(a)
a = [[0] * 14 for _ in range(14)] while True: try: x, y, s = map(int, input().split(',')) except: break x += 2 y += 2 for d in [(0, 0), (0, -1), (0, 1), (-1, 0), (1, 0)]: a[x + d[0]][y + d[1]] += 1 if s >= 2: for d in [(1, 1), (1, -1), (-1, 1), (-1, -1)]: a[x + d[0]][y + d[1]] += 1 if s == 3: for d in [(0, 2), (0, -2), (2, 0), (-2, 0)]: a[x + d[0]][y + d[1]] += 1 print(sum(a[i][2:12].count(0) for i in range(2, 12))) print(max(max(a[i][2:12]) for i in range(2, 12)))
[["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]]
5
279
4
Masu = [] def access(x,y): if x < 0 or y < 0 or x > 9 or y > 9: return Masu[y][x] += 1 for i in range(10): Masu.append([0,0,0,0,0,0,0,0,0,0]) kosu = 0 komax = 0 while True: try: x,y,s = map(int,input().split(",")) if s == 1: for j in range(3): access(y +1 - j,x) access(y,x - 1) access(y,x + 1) elif s == 2: for k in range(3): for l in range(3): access(y + 1 - k,x + 1 -l) elif s == 3: for k in range(3): for l in range(3): access(y + 1 - k,x + 1 -l) access(y - 2,x) access(y + 2,x) access(y,x + 2) access(y,x - 2) print(Masu) except (EOFError,ValueError): for i in range(10): kosu += Masu[i].count(0) for j in range(10): if komax < max(Masu[j]): komax = max(Masu[j]) print(kosu) print(komax) break
Masu = [] def access(x,y): if x < 0 or y < 0 or x > 9 or y > 9: return Masu[y][x] += 1 for i in range(10): Masu.append([0,0,0,0,0,0,0,0,0,0]) kosu = 0 komax = 0 while True: try: x,y,s = map(int,input().split(",")) if s == 1: for j in range(3): access(y +1 - j,x) access(y,x - 1) access(y,x + 1) elif s == 2: for k in range(3): for l in range(3): access(y + 1 - k,x + 1 -l) elif s == 3: for k in range(3): for l in range(3): access(y + 1 - k,x + 1 -l) access(y - 2,x) access(y + 2,x) access(y,x + 2) access(y,x - 2) except (EOFError,ValueError): for i in range(10): kosu += Masu[i].count(0) for j in range(10): if komax < max(Masu[j]): komax = max(Masu[j]) print(kosu) print(komax) break
[["-", 0, 246, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
313
4
board=[[0]*10 for i in range(10)] ink=[[[0,0,0,0,0],[0,0,1,0,0],[0,1,1,1,0],[0,0,1,0,0],[0,0,0,0,0]], [[0,0,0,0,0],[0,1,1,1,0],[0,1,1,1,0],[0,1,1,1,0],[0,0,0,0,0]], [[0,0,1,0,0],[0,1,1,1,0],[1,1,1,1,1],[0,1,1,1,0],[0,0,1,0,0]]] while True: try: x,y,s=map(int,input().split(",")) except: break for i in range(5): for j in range(5): if 0<=i+y-2<=9 and 0<=j+x-2<=9: board[i+y-2][j+x-2]+=ink[s-1][i][j] flat=sum(board,[]) print(flat.count(0)) print(flat.count(max(flat)))
board=[[0]*10 for i in range(10)] ink=[[[0,0,0,0,0],[0,0,1,0,0],[0,1,1,1,0],[0,0,1,0,0],[0,0,0,0,0]], [[0,0,0,0,0],[0,1,1,1,0],[0,1,1,1,0],[0,1,1,1,0],[0,0,0,0,0]], [[0,0,1,0,0],[0,1,1,1,0],[1,1,1,1,1],[0,1,1,1,0],[0,0,1,0,0]]] while True: try: x,y,s=map(int,input().split(",")) except: break for i in range(5): for j in range(5): if 0<=i+y-2<=9 and 0<=j+x-2<=9: board[i+y-2][j+x-2]+=ink[s-1][i][j] flat=sum(board,[]) print(flat.count(0)) print(max(flat))
[["-", 0, 652, 3, 4, 0, 652, 63, 319, 500, 22], ["-", 0, 652, 3, 4, 0, 652, 63, 319, 0, 131], ["-", 0, 652, 3, 4, 0, 652, 63, 319, 319, 22], ["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
329
5