problem_id
stringlengths 6
6
| language
stringclasses 2
values | original_status
stringclasses 3
values | original_src
stringlengths 19
243k
| changed_src
stringlengths 19
243k
| change
stringclasses 3
values | i1
int64 0
8.44k
| i2
int64 0
8.44k
| j1
int64 0
8.44k
| j2
int64 0
8.44k
| error
stringclasses 270
values | stderr
stringlengths 0
226k
|
---|---|---|---|---|---|---|---|---|---|---|---|
p00013 | C++ | Runtime Error | #include <iostream>
#include <vector>
using namespace std;
int main() {
vector<int> car;
int n;
while (1) {
if (cin >> n, n) {
car.push_back(n);
} else {
cout << car.back() << endl;
car.pop_back();
}
}
return 0;
} | #include <iostream>
#include <vector>
using namespace std;
int main() {
vector<int> car;
int n;
while (cin >> n) {
if (n) {
car.push_back(n);
} else {
cout << car.back() << endl;
car.pop_back();
}
}
return 0;
} | replace | 8 | 10 | 8 | 10 | -11 | |
p00013 | C++ | Runtime Error | #include <iostream>
#include <stack>
using namespace std;
int main(void) {
stack<int> s;
int buf;
while (1) {
cin >> buf;
if (buf == 0) {
cout << s.top() << endl;
s.pop();
} else {
s.push(buf);
}
}
} | #include <iostream>
#include <stack>
using namespace std;
int main(void) {
stack<int> s;
int buf;
while (cin >> buf) {
if (buf == 0) {
cout << s.top() << endl;
s.pop();
} else {
s.push(buf);
}
}
} | replace | 8 | 10 | 8 | 9 | -11 | |
p00013 | C++ | Runtime Error | #include <cstdio>
#include <iostream>
#include <stack>
using namespace std;
stack<int> sta;
int main(void) {
int a;
while (1) {
cin >> a;
if (a)
sta.push(a);
else {
cout << sta.top() << endl;
sta.pop();
}
}
return 0;
} | #include <cstdio>
#include <iostream>
#include <stack>
using namespace std;
stack<int> sta;
int main(void) {
int a;
while (scanf("%d", &a) != EOF) {
if (a)
sta.push(a);
else {
cout << sta.top() << endl;
sta.pop();
}
}
return 0;
} | replace | 9 | 11 | 9 | 10 | -11 | |
p00013 | C++ | Runtime Error | #include <cstdio>
#include <iostream>
using namespace std;
int main() {
int a[10], i = 0, n;
while (scanf("%d", n) == 1) {
if (n != 0) {
a[i] = n;
i++;
} else {
i--;
cout << a[i] << endl;
}
}
return 0;
} | #include <cstdio>
#include <iostream>
using namespace std;
int main() {
int a[10], i = 0, n;
while (scanf("%d", &n) == 1) {
if (n != 0) {
a[i] = n;
i++;
} else {
i--;
cout << a[i] << endl;
}
}
return 0;
} | replace | 5 | 6 | 5 | 6 | -11 | |
p00013 | C++ | Runtime Error | #include <iostream>
#include <stack>
using namespace std;
int main() {
int a;
stack<int> syaryo;
while (cin >> a) {
cin >> a;
if (a != 0) {
syaryo.push(a);
}
else {
cout << syaryo.top() << endl;
syaryo.pop();
}
}
return 0;
} | #include <iostream>
#include <stack>
using namespace std;
int main() {
int a;
stack<int> syaryo;
while (cin >> a) {
if (a != 0) {
syaryo.push(a);
}
else {
cout << syaryo.top() << endl;
syaryo.pop();
}
}
return 0;
} | delete | 11 | 12 | 11 | 11 | 0 | |
p00013 | C++ | Runtime Error | #include <algorithm>
#include <cctype>
#include <cstdio>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
int c[10], e[10], m, n = 0, k = 0;
for (int i = 0; i < 10; i++) {
c[i] = 0;
e[i] = 0;
}
while (cin >> m) {
if (m == 0) {
e[k] = c[n - 1];
k++;
c[n - 1] = 0;
n--;
} else {
c[n] = m;
n++;
}
}
for (int i = 0; i < k; i++)
cout << e[i] << endl;
return 0;
} | #include <algorithm>
#include <cctype>
#include <cstdio>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
int c[256], e[256], m, n = 0, k = 0;
for (int i = 0; i < 10; i++) {
c[i] = 0;
e[i] = 0;
}
while (cin >> m) {
if (m == 0) {
e[k] = c[n - 1];
k++;
c[n - 1] = 0;
n--;
} else {
c[n] = m;
n++;
}
}
for (int i = 0; i < k; i++)
cout << e[i] << endl;
return 0;
} | replace | 9 | 10 | 9 | 10 | 0 | |
p00013 | C++ | Time Limit Exceeded | #include <cstdio>
using namespace std;
int main() {
int in[10];
int i = 0;
while (scanf("%d", &in[i])) {
if (in[i] == 0) {
i--;
printf("%d\n", in[i]);
} else {
i++;
}
}
} | #include <cstdio>
using namespace std;
int main() {
int in[10];
int i = 0;
while (scanf("%d", &in[i]) != EOF) {
if (in[i] == 0) {
i--;
printf("%d\n", in[i]);
} else {
i++;
}
}
} | replace | 8 | 9 | 8 | 9 | TLE | |
p00013 | C++ | Runtime Error | #include <iostream>
#include <malloc.h>
using namespace std;
struct stack {
int element;
struct stack *next;
};
int top(struct stack *s) { return s->element; }
struct stack *pop(struct stack *s) {
struct stack *p, *q;
q = s;
p = s->next;
free(q);
s = p;
return s;
}
struct stack *push(struct stack *s, int x) {
struct stack *p, *q;
q = s;
p = (struct stack *)malloc(sizeof(struct stack));
p->element = x;
p->next = q;
s = p;
return s;
}
int main() {
struct stack *S = NULL;
int num;
while (1) {
cin >> num;
if (num == 0) {
cout << top(S) << endl;
S = pop(S);
} else {
S = push(S, num);
}
}
return 0;
} | #include <iostream>
#include <malloc.h>
using namespace std;
struct stack {
int element;
struct stack *next;
};
int top(struct stack *s) { return s->element; }
struct stack *pop(struct stack *s) {
struct stack *p, *q;
q = s;
p = s->next;
free(q);
s = p;
return s;
}
struct stack *push(struct stack *s, int x) {
struct stack *p, *q;
q = s;
p = (struct stack *)malloc(sizeof(struct stack));
p->element = x;
p->next = q;
s = p;
return s;
}
int main() {
struct stack *S = NULL;
int num;
while (cin >> num) {
if (num == 0) {
cout << top(S) << endl;
S = pop(S);
} else {
S = push(S, num);
}
}
return 0;
} | replace | 30 | 32 | 30 | 31 | -11 | |
p00013 | C++ | Runtime Error | #include <cstdio>
int main() {
int g[10];
int i = 0;
int t;
while (scanf("%d", &t)) {
if (t) {
g[i] = t;
i++;
} else {
i--;
printf("%d\n", g[i]);
}
}
return 0;
} | #include <cstdio>
int main() {
int g[10];
int i = 0;
int t;
while (scanf("%d", &t) + 1) {
if (t) {
g[i] = t;
i++;
} else {
i--;
printf("%d\n", g[i]);
}
}
return 0;
} | replace | 6 | 7 | 6 | 7 | -11 | |
p00014 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define fi first
#define se second
using namespace std;
bool value(int y, int x, int R, int C) {
return 0 <= y && y < R && 0 <= x && x < C;
}
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vi> vvi;
double pie = acos(-1);
int INF = 10000009;
int dx[4] = {0, -1, 0, 1};
int dy[4] = {-1, 0, 1, 0};
int main() {
int d;
while (true) {
cin >> d;
int S = 0;
for (int i = 1; i * d <= 600 - d; i++) {
int x = i * d;
x = x * x;
x *= d;
S += x;
}
cout << S << endl;
S = 0;
}
} | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define fi first
#define se second
using namespace std;
bool value(int y, int x, int R, int C) {
return 0 <= y && y < R && 0 <= x && x < C;
}
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vi> vvi;
double pie = acos(-1);
int INF = 10000009;
int dx[4] = {0, -1, 0, 1};
int dy[4] = {-1, 0, 1, 0};
int main() {
int d;
while (cin >> d) {
int S = 0;
for (int i = 1; i * d <= 600 - d; i++) {
int x = i * d;
x = x * x;
x *= d;
S += x;
}
cout << S << endl;
S = 0;
}
} | replace | 29 | 31 | 29 | 30 | TLE | |
p00014 | C++ | Time Limit Exceeded | #include <iostream>
#include <math.h>
using namespace std;
double y(double x) {
double y;
y = x * x;
return y;
}
int main() {
int i, d, s;
while (cin >> d) {
s = 0;
for (i = 0; i < 600; i += d) {
s += d * y(i);
}
cout << s << endl;
}
while (1)
;
return 0;
} | #include <iostream>
#include <math.h>
using namespace std;
double y(double x) {
double y;
y = x * x;
return y;
}
int main() {
int i, d, s;
while (cin >> d) {
s = 0;
for (i = 0; i < 600; i += d) {
s += d * y(i);
}
cout << s << endl;
}
return 0;
} | delete | 20 | 22 | 20 | 20 | TLE | |
p00014 | C++ | Time Limit Exceeded | #include <iostream>
using namespace std;
int main(void) {
int n;
while (cin >> n, n) {
long long res = 0;
for (int i = 0; i < 600; i += n) {
res += n * i * i;
}
cout << res << endl;
}
return 0;
} | #include <iostream>
using namespace std;
int main(void) {
int n;
while (cin >> n) {
long long res = 0;
for (int i = 0; i < 600; i += n) {
res += n * i * i;
}
cout << res << endl;
}
return 0;
} | replace | 5 | 6 | 5 | 6 | TLE | |
p00014 | C++ | Time Limit Exceeded | #include <cstdio>
#include <iostream>
using namespace std;
int main() {
int w;
while (scanf("%d", &w) && w) {
int i;
long long area = 0;
for (i = w; i < 600; i += w) {
area += w * i * i;
}
printf("%lld\n", area);
}
} | #include <cstdio>
#include <iostream>
using namespace std;
int main() {
int w;
while (scanf("%d", &w) != EOF) {
int i;
long long area = 0;
for (i = w; i < 600; i += w) {
area += w * i * i;
}
printf("%lld\n", area);
}
} | replace | 5 | 6 | 5 | 6 | TLE | |
p00015 | C++ | Runtime Error | #include <algorithm>
#include <cstring>
#include <iostream>
using namespace std;
int main() {
int N;
cin >> N;
for (int i = 0; i < N; i++) {
char str1[82];
char str2[82];
string ans = "";
cin >> str1;
cin >> str2;
int m1 = strlen(str1) - 1, m2 = strlen(str2) - 1, pre = 0;
int m = max(m1, m2);
for (int j = 0; j <= m; j++) {
int sum = pre;
sum += (m1 >= 0) ? str1[m1--] - '0' : 0;
sum += (m2 >= 0) ? str2[m2--] - '0' : 0;
pre = sum / 10;
sum -= pre * 10;
ans += '0' + sum;
}
if (pre > 0)
ans += '0' + pre;
reverse(ans.begin(), ans.end());
if (ans.length() > 80)
cout << "overflow" << endl;
else
cout << ans << endl;
}
} | #include <algorithm>
#include <cstring>
#include <iostream>
using namespace std;
int main() {
int N;
cin >> N;
for (int i = 0; i < N; i++) {
char str1[1000];
char str2[1000];
string ans = "";
cin >> str1;
cin >> str2;
int m1 = strlen(str1) - 1, m2 = strlen(str2) - 1, pre = 0;
int m = max(m1, m2);
for (int j = 0; j <= m; j++) {
int sum = pre;
sum += (m1 >= 0) ? str1[m1--] - '0' : 0;
sum += (m2 >= 0) ? str2[m2--] - '0' : 0;
pre = sum / 10;
sum -= pre * 10;
ans += '0' + sum;
}
if (pre > 0)
ans += '0' + pre;
reverse(ans.begin(), ans.end());
if (ans.length() > 80)
cout << "overflow" << endl;
else
cout << ans << endl;
}
} | replace | 9 | 11 | 9 | 11 | 0 | |
p00015 | C++ | Time Limit Exceeded | #include <iostream>
#include <string>
using namespace std;
int main() {
int n, l1, l2, i;
string a, b;
char ans[80];
int ia, ib, sum;
cin >> n;
while (n--) {
cin >> a >> b;
if (a.length() > 80 || b.length() > 80) {
cout << "overflow" << endl;
continue;
}
if (a.length() == 80 || b.length() == 80) {
if ((int)a[0] - '0' + (int)b[0] - '0' > 9) {
cout << "overflow" << endl;
continue;
}
}
if (a.length() < b.length()) {
swap(a, b);
}
l1 = a.length();
l2 = b.length();
for (i = 0; i < 80; i++)
ans[i] = 0;
for (i = 1; i < l2 + 1; i++) {
ia = (int)a[l1 - i] - (int)'0';
ib = (int)b[l2 - i] - (int)'0';
sum = ia + ib;
ans[80 - i] += sum + '0';
}
for (i = l2 + 1; i < l1 + 1; i++) {
ans[80 - i] = a[l1 - i];
}
for (i = 79; i >= 0; i--) {
if (ans[i] - '0' > 9 && ans[i] != 0) {
ans[i] = ans[i] - 10;
if (ans[i - 1] == 0)
ans[i - 1] += 49;
else
ans[i - 1] += 1;
}
}
for (i = 0; i < 80; i++) {
if (ans[i] != 0) {
cout << (int)ans[i] - '0';
}
}
cout << endl;
}
while (1)
;
return 0;
} | #include <iostream>
#include <string>
using namespace std;
int main() {
int n, l1, l2, i;
string a, b;
char ans[80];
int ia, ib, sum;
cin >> n;
while (n--) {
cin >> a >> b;
if (a.length() > 80 || b.length() > 80) {
cout << "overflow" << endl;
continue;
}
if (a.length() == 80 || b.length() == 80) {
if ((int)a[0] - '0' + (int)b[0] - '0' > 9) {
cout << "overflow" << endl;
continue;
}
}
if (a.length() < b.length()) {
swap(a, b);
}
l1 = a.length();
l2 = b.length();
for (i = 0; i < 80; i++)
ans[i] = 0;
for (i = 1; i < l2 + 1; i++) {
ia = (int)a[l1 - i] - (int)'0';
ib = (int)b[l2 - i] - (int)'0';
sum = ia + ib;
ans[80 - i] += sum + '0';
}
for (i = l2 + 1; i < l1 + 1; i++) {
ans[80 - i] = a[l1 - i];
}
for (i = 79; i >= 0; i--) {
if (ans[i] - '0' > 9 && ans[i] != 0) {
ans[i] = ans[i] - 10;
if (ans[i - 1] == 0)
ans[i - 1] += 49;
else
ans[i - 1] += 1;
}
}
for (i = 0; i < 80; i++) {
if (ans[i] != 0) {
cout << (int)ans[i] - '0';
}
}
cout << endl;
}
return 0;
} | delete | 55 | 57 | 55 | 55 | TLE | |
p00015 | C++ | Time Limit Exceeded | #include <algorithm>
#include <bits/stdc++.h>
#include <list>
#include <queue>
#include <stack>
#include <vector>
using namespace std;
int main() {
int t;
scanf("%d", &t);
while (t--) {
char c1[80], c2[80];
scanf("%s", &c1);
scanf("%s", &c2);
string s1, s2;
s1 = c1, s2 = c2;
if (s1 == "0" && s2 == "0") {
printf("0\n");
continue;
}
reverse(s1.begin(), s1.end());
reverse(s2.begin(), s2.end());
int n = max(s1.size(), s2.size()) + 1;
for (int i = s1.size(); i < n; i++) {
s1 += '0';
}
for (int i = s2.size(); i < n; i++) {
s2 += '0';
}
string res;
int b = 0;
for (int i = 0; i < max(s1.size(), s2.size()); i++) {
int u = s1[i] - '0' + s2[i] - '0' + b;
b = (u >= 10);
u %= 10;
res += u + '0';
}
reverse(res.begin(), res.end());
string res2;
int j = 0;
while (res[j] == '0')
j++;
for (; j < res.size(); j++) {
res2 += res[j];
}
if (res2.size() > 80) {
printf("overflow\n");
} else {
printf("%s\n", res2.c_str());
}
}
return 0;
} | #include <algorithm>
#include <bits/stdc++.h>
#include <list>
#include <queue>
#include <stack>
#include <vector>
using namespace std;
int main() {
int t;
scanf("%d", &t);
while (t--) {
char c1[1000], c2[1000];
scanf("%s", &c1);
scanf("%s", &c2);
string s1, s2;
s1 = c1, s2 = c2;
if (s1 == "0" && s2 == "0") {
printf("0\n");
continue;
}
reverse(s1.begin(), s1.end());
reverse(s2.begin(), s2.end());
int n = max(s1.size(), s2.size()) + 1;
for (int i = s1.size(); i < n; i++) {
s1 += '0';
}
for (int i = s2.size(); i < n; i++) {
s2 += '0';
}
string res;
int b = 0;
for (int i = 0; i < max(s1.size(), s2.size()); i++) {
int u = s1[i] - '0' + s2[i] - '0' + b;
b = (u >= 10);
u %= 10;
res += u + '0';
}
reverse(res.begin(), res.end());
string res2;
int j = 0;
while (res[j] == '0')
j++;
for (; j < res.size(); j++) {
res2 += res[j];
}
if (res2.size() > 80) {
printf("overflow\n");
} else {
printf("%s\n", res2.c_str());
}
}
return 0;
} | replace | 12 | 13 | 12 | 13 | TLE | |
p00015 | C++ | Runtime Error | #include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
while (n-- > 0) {
string num1, num2;
cin >> num1 >> num2;
int sum[101];
int degit = 0;
for (int i = 0; i < 101; i++)
sum[i] = 0;
for (int i = 0; i < num1.size(); i++) {
sum[100 - i] = num1[num1.size() - i - 1] - '0';
}
int d;
for (int i = 0; i < num1.size() || i < num2.size() || degit != 0; i++) {
int now;
if (i < num2.size()) {
now =
sum[100 - i] + (int)num2[num2.size() - i - 1] - (int)('0') + degit;
} else {
now = sum[100 - i] + degit;
}
sum[100 - i] = (now % 10);
if (now >= 10)
degit = 1;
else
degit = 0;
d = i;
}
if (d < 80) {
for (int i = 100 - d; i < 101; i++)
cout << sum[i];
cout << endl;
} else {
cout << "overflow" << endl;
}
}
} | #include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
while (n-- > 0) {
string num1, num2;
cin >> num1 >> num2;
if (num1.size() > 80 || num2.size() > 80) {
cout << "overflow" << endl;
continue;
}
int sum[101];
int degit = 0;
for (int i = 0; i < 101; i++)
sum[i] = 0;
for (int i = 0; i < num1.size(); i++) {
sum[100 - i] = num1[num1.size() - i - 1] - '0';
}
int d;
for (int i = 0; i < num1.size() || i < num2.size() || degit != 0; i++) {
int now;
if (i < num2.size()) {
now =
sum[100 - i] + (int)num2[num2.size() - i - 1] - (int)('0') + degit;
} else {
now = sum[100 - i] + degit;
}
sum[100 - i] = (now % 10);
if (now >= 10)
degit = 1;
else
degit = 0;
d = i;
}
if (d < 80) {
for (int i = 100 - d; i < 101; i++)
cout << sum[i];
cout << endl;
} else {
cout << "overflow" << endl;
}
}
} | insert | 12 | 12 | 12 | 16 | 0 | |
p00015 | C++ | Runtime Error | #include <cstring>
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
char num[2][90];
int ans[90], up = 0, t, l;
cin >> num[0] >> num[1];
int a = strlen(num[0]), b = strlen(num[1]), max = (b > a) ? b : a,
min = (b > a) ? a : b;
for (l = 0; l < max; l++) {
if (l < min) {
t = (int)num[0][a - l - 1] + (int)num[1][b - l - 1] - 48 * 2 + up;
} else if (a < b) {
t = (int)num[1][b - l - 1] - 48 + up;
} else {
t = (int)num[0][a - l - 1] - 48 + up;
}
if (t > 9) {
t -= 10;
up = 1;
} else {
up = 0;
}
ans[l] = t;
}
if (up == 1) {
ans[max] = 1;
l++;
}
if (l <= 80)
for (int m = l - 1; m >= 0; m--) {
cout << ans[m];
}
else {
cout << "overflow";
}
cout << endl;
}
return 0;
} | #include <cstring>
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
char num[2][900];
int ans[900], up = 0, t, l;
cin >> num[0] >> num[1];
int a = strlen(num[0]), b = strlen(num[1]), max = (b > a) ? b : a,
min = (b > a) ? a : b;
for (l = 0; l < max; l++) {
if (l < min) {
t = (int)num[0][a - l - 1] + (int)num[1][b - l - 1] - 48 * 2 + up;
} else if (a < b) {
t = (int)num[1][b - l - 1] - 48 + up;
} else {
t = (int)num[0][a - l - 1] - 48 + up;
}
if (t > 9) {
t -= 10;
up = 1;
} else {
up = 0;
}
ans[l] = t;
}
if (up == 1) {
ans[max] = 1;
l++;
}
if (l <= 80)
for (int m = l - 1; m >= 0; m--) {
cout << ans[m];
}
else {
cout << "overflow";
}
cout << endl;
}
return 0;
} | replace | 7 | 9 | 7 | 9 | 0 | |
p00015 | C++ | Runtime Error | #include <cstdio>
#include <cstring>
#define MAX_NUM 100
using namespace std;
void array_add(int *a, int *b) {
int i;
for (i = MAX_NUM - 1; i > 0; i--) {
a[i] = a[i] + b[i];
a[i - 1] = a[i - 1] + a[i] / 10;
a[i] %= 10;
}
}
int main(void) {
int n, i, j, len1, len2, val1[MAX_NUM], val2[MAX_NUM];
char c;
scanf("%d%*c", &n);
for (i = 0; i < n; i++) {
for (j = 0; (c = getchar()) != '\n'; j++) {
val1[j] = c - '0';
}
len1 = j;
for (j = 0; (c = getchar()) != '\n'; j++) {
val2[j] = c - '0';
}
len2 = j;
for (j = MAX_NUM - 1; j > MAX_NUM - 1 - len1; j--) {
val1[j] = val1[len1 - 1 + (j - (MAX_NUM - 1))];
}
for (; j >= 0; j--) {
val1[j] = 0;
}
val1[MAX_NUM] = 0;
for (j = MAX_NUM - 1; j > MAX_NUM - 1 - len2; j--) {
val2[j] = val2[len2 - 1 + (j - (MAX_NUM - 1))];
}
for (; j >= 0; j--) {
val2[j] = 0;
}
array_add(val1, val2);
for (j = 0; val1[j] == 0 && j < MAX_NUM; j++)
;
if (j <= MAX_NUM - 81)
printf("overflow");
else if (j == MAX_NUM)
printf("0");
else {
for (; j < MAX_NUM; j++) {
printf("%d", val1[j]);
}
}
printf("\n");
}
return 0;
} | #include <cstdio>
#include <cstring>
#define MAX_NUM 32767
using namespace std;
void array_add(int *a, int *b) {
int i;
for (i = MAX_NUM - 1; i > 0; i--) {
a[i] = a[i] + b[i];
a[i - 1] = a[i - 1] + a[i] / 10;
a[i] %= 10;
}
}
int main(void) {
int n, i, j, len1, len2, val1[MAX_NUM], val2[MAX_NUM];
char c;
scanf("%d%*c", &n);
for (i = 0; i < n; i++) {
for (j = 0; (c = getchar()) != '\n'; j++) {
val1[j] = c - '0';
}
len1 = j;
for (j = 0; (c = getchar()) != '\n'; j++) {
val2[j] = c - '0';
}
len2 = j;
for (j = MAX_NUM - 1; j > MAX_NUM - 1 - len1; j--) {
val1[j] = val1[len1 - 1 + (j - (MAX_NUM - 1))];
}
for (; j >= 0; j--) {
val1[j] = 0;
}
val1[MAX_NUM] = 0;
for (j = MAX_NUM - 1; j > MAX_NUM - 1 - len2; j--) {
val2[j] = val2[len2 - 1 + (j - (MAX_NUM - 1))];
}
for (; j >= 0; j--) {
val2[j] = 0;
}
array_add(val1, val2);
for (j = 0; val1[j] == 0 && j < MAX_NUM; j++)
;
if (j <= MAX_NUM - 81)
printf("overflow");
else if (j == MAX_NUM)
printf("0");
else {
for (; j < MAX_NUM; j++) {
printf("%d", val1[j]);
}
}
printf("\n");
}
return 0;
} | replace | 2 | 3 | 2 | 3 | 0 | |
p00015 | C++ | Runtime Error | #include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
int a[80];
string sa1, sa2, s1 = "", s2 = "";
for (int i = 0; i < 80; i++)
a[i] = 0;
cin >> sa1 >> sa2;
for (int j = 0; j < 80 - sa1.length(); j++) {
s1 += '0';
}
s1 += sa1;
for (int j = 0; j < 80 - sa2.length(); j++) {
s2 += '0';
}
s2 += sa2;
for (int i = 0; i < 80; i++) {
a[i] += (s1[i] - '0') + (s2[i] - '0');
}
for (int i = 79; i >= 1; i--) {
a[i - 1] += a[i] / 10;
a[i] %= 10;
}
if (a[0] >= 10) {
printf("overflow\n");
continue;
}
int x = 0;
while (a[x] == 0)
x++;
for (int i = x; i <= 79; i++) {
cout << a[i];
}
if (x == 80)
printf("0\n");
else
printf("\n");
}
return 0;
} | #include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
int a[80];
string sa1, sa2, s1 = "", s2 = "";
for (int i = 0; i < 80; i++)
a[i] = 0;
cin >> sa1 >> sa2;
if (sa1.length() > 80 || sa2.length() > 80) {
printf("overflow\n");
continue;
}
for (int j = 0; j < 80 - sa1.length(); j++) {
s1 += '0';
}
s1 += sa1;
for (int j = 0; j < 80 - sa2.length(); j++) {
s2 += '0';
}
s2 += sa2;
for (int i = 0; i < 80; i++) {
a[i] += (s1[i] - '0') + (s2[i] - '0');
}
for (int i = 79; i >= 1; i--) {
a[i - 1] += a[i] / 10;
a[i] %= 10;
}
if (a[0] >= 10) {
printf("overflow\n");
continue;
}
int x = 0;
while (a[x] == 0)
x++;
for (int i = x; i <= 79; i++) {
cout << a[i];
}
if (x == 80)
printf("0\n");
else
printf("\n");
}
return 0;
} | insert | 18 | 18 | 18 | 22 | -6 | terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
|
p00015 | C++ | Runtime Error | // 2012/10/28 Tazoe
#include <iostream>
#include <string>
using namespace std;
int main() {
int N;
cin >> N;
for (int i = 0; i < N; i++) {
string S1, S2;
cin >> S1;
cin >> S2;
if (S1.size() < S2.size()) {
string tmp = S1;
S1 = S2;
S2 = tmp;
}
int A[80];
int C = 0;
for (int j = 0; j < S1.size(); j++) {
int tmp = (int)(S1[S1.size() - 1 - j] - '0') + C;
if (j < S2.size()) {
tmp += (int)(S2[S2.size() - 1 - j] - '0');
}
A[j] = tmp % 10;
C = tmp / 10;
}
if (S1.size() == 80 && C == 1) {
cout << "overflow" << endl;
} else {
if (C == 1) {
cout << C;
}
for (int j = S1.size() - 1; j >= 0; j--) {
cout << A[j];
}
cout << endl;
}
}
return 0;
} | // 2012/10/28 Tazoe
#include <iostream>
#include <string>
using namespace std;
int main() {
int N;
cin >> N;
for (int i = 0; i < N; i++) {
string S1, S2;
cin >> S1;
cin >> S2;
if (S1.size() < S2.size()) {
string tmp = S1;
S1 = S2;
S2 = tmp;
}
if (S1.size() > 80) {
cout << "overflow" << endl;
continue;
}
int A[80];
int C = 0;
for (int j = 0; j < S1.size(); j++) {
int tmp = (int)(S1[S1.size() - 1 - j] - '0') + C;
if (j < S2.size()) {
tmp += (int)(S2[S2.size() - 1 - j] - '0');
}
A[j] = tmp % 10;
C = tmp / 10;
}
if (S1.size() == 80 && C == 1) {
cout << "overflow" << endl;
} else {
if (C == 1) {
cout << C;
}
for (int j = S1.size() - 1; j >= 0; j--) {
cout << A[j];
}
cout << endl;
}
}
return 0;
} | insert | 19 | 19 | 19 | 24 | 0 | |
p00015 | C++ | Runtime Error | #include <iostream>
#include <string>
using namespace std;
int charToInt(char);
string sumStr(string, string);
int charToInt(char c) { return (int)c - (int)'0'; }
string sumStr(string a, string b) {
int pa = a.length() - 1, pb = b.length() - 1;
string str(83, '0');
int pstr = str.length() - 1;
int next = 0;
while (pa >= 0 && pb >= 0) {
int temp = charToInt(a[pa]) + charToInt(b[pb]) + next;
next = temp / 10;
str[pstr] = (char)(temp % 10 + (int)'0');
pa--;
pb--;
pstr--;
}
while (pa >= 0) {
int temp = charToInt(a[pa]) + next;
next = temp / 10;
str[pstr] = (char)(temp % 10 + (int)'0');
pa--;
pstr--;
}
while (pb >= 0) {
int temp = charToInt(b[pb]) + next;
next = temp / 10;
str[pstr] = (char)(temp % 10 + (int)'0');
pb--;
pstr--;
}
str[pstr] = (char)(next + (int)'0');
for (int i = 0; i < str.length(); i++) {
if (str[i] != '0') {
return str.substr(i, str.length() - i);
}
}
return "0";
}
int main() {
int N;
cin >> N;
for (int i = 0; i < N; i++) {
bool overflow = false;
int data[N][8];
string sum;
for (int j = 0; j < 2; j++) {
string str;
cin >> str;
if (!overflow) {
if (j == 0)
sum = str;
else
sum = sumStr(sum, str);
if (sum.length() > 80)
overflow = true;
}
}
if (overflow)
cout << "overflow" << endl;
else
cout << sum << endl;
}
return 0;
} | #include <iostream>
#include <string>
using namespace std;
int charToInt(char);
string sumStr(string, string);
int charToInt(char c) { return (int)c - (int)'0'; }
string sumStr(string a, string b) {
int pa = a.length() - 1, pb = b.length() - 1;
string str(83, '0');
int pstr = str.length() - 1;
int next = 0;
while (pa >= 0 && pb >= 0) {
int temp = charToInt(a[pa]) + charToInt(b[pb]) + next;
next = temp / 10;
str[pstr] = (char)(temp % 10 + (int)'0');
pa--;
pb--;
pstr--;
}
while (pa >= 0) {
int temp = charToInt(a[pa]) + next;
next = temp / 10;
str[pstr] = (char)(temp % 10 + (int)'0');
pa--;
pstr--;
}
while (pb >= 0) {
int temp = charToInt(b[pb]) + next;
next = temp / 10;
str[pstr] = (char)(temp % 10 + (int)'0');
pb--;
pstr--;
}
str[pstr] = (char)(next + (int)'0');
for (int i = 0; i < str.length(); i++) {
if (str[i] != '0') {
return str.substr(i, str.length() - i);
}
}
return "0";
}
int main() {
int N;
cin >> N;
for (int i = 0; i < N; i++) {
bool overflow = false;
int data[N][8];
string sum;
for (int j = 0; j < 2; j++) {
string str;
cin >> str;
if (str.length() > 80)
overflow = true;
if (!overflow) {
if (j == 0)
sum = str;
else
sum = sumStr(sum, str);
if (sum.length() > 80)
overflow = true;
}
}
if (overflow)
cout << "overflow" << endl;
else
cout << sum << endl;
}
return 0;
} | replace | 59 | 60 | 59 | 61 | 0 | |
p00015 | C++ | Time Limit Exceeded | #include <stdio.h>
#include <string.h>
int main(void) {
int N;
scanf("%d", &N);
int i, j, k;
for (i = 0; i < N; ++i) {
int digits[2][80];
for (j = 0; j < 2; ++j) {
for (k = 0; k < 80; ++k) {
digits[j][k] = 0;
}
}
int overflow = 0;
for (j = 0; j < 2; ++j) {
char digit[256];
scanf("%s", digit);
getchar();
if (overflow || strlen(digit) > 80) {
overflow = 1;
} else {
for (k = 0; k < strlen(digit); ++k) {
digits[j][k] = digit[strlen(digit) - 1 - k] - '0';
}
}
}
if (!overflow) {
int sum[81];
for (j = 0; j < 81; ++j) {
sum[j] = 0;
}
for (j = 0; j < 80; ++j) {
for (k = 0; k < 2; ++k) {
sum[j] += digits[k][j];
}
sum[j + 1] += sum[j] / 10;
sum[j] %= 10;
}
if (sum[80] > 0) {
overflow = 1;
} else {
int available = 0;
for (j = 80; j >= 0; --j) {
if (available || sum[j] != 0 || j == 0) {
available = 1;
printf("%d", sum[j]);
}
}
printf("\n");
}
}
if (overflow) {
printf("overflow\n");
}
}
return 0;
} | #include <stdio.h>
#include <string.h>
int main(void) {
int N;
scanf("%d", &N);
int i, j, k;
for (i = 0; i < N; ++i) {
int digits[2][80];
for (j = 0; j < 2; ++j) {
for (k = 0; k < 80; ++k) {
digits[j][k] = 0;
}
}
int overflow = 0;
for (j = 0; j < 2; ++j) {
char digit[256];
scanf("%256s", digit);
getchar();
if (overflow || strlen(digit) > 80) {
overflow = 1;
} else {
for (k = 0; k < strlen(digit); ++k) {
digits[j][k] = digit[strlen(digit) - 1 - k] - '0';
}
}
}
if (!overflow) {
int sum[81];
for (j = 0; j < 81; ++j) {
sum[j] = 0;
}
for (j = 0; j < 80; ++j) {
for (k = 0; k < 2; ++k) {
sum[j] += digits[k][j];
}
sum[j + 1] += sum[j] / 10;
sum[j] %= 10;
}
if (sum[80] > 0) {
overflow = 1;
} else {
int available = 0;
for (j = 80; j >= 0; --j) {
if (available || sum[j] != 0 || j == 0) {
available = 1;
printf("%d", sum[j]);
}
}
printf("\n");
}
}
if (overflow) {
printf("overflow\n");
}
}
return 0;
} | replace | 21 | 22 | 21 | 22 | TLE | |
p00015 | C++ | Runtime Error | #include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int main(void) {
char a[256], b[256];
int n, flag, count1, count2, count3, daisyo = 0, miss = 0;
cin >> n;
for (int i = 0; i < n; i++) {
flag = 0;
daisyo = 0;
miss = 0;
cin >> a >> b;
count1 = strlen(a);
count2 = strlen(b);
if (count1 > 80 || count2 > 80) {
flag = 1;
}
count3 = count1 - count2;
if (count2 > count1) {
count3 *= -1;
daisyo = 1;
}
if (daisyo == 0) {
if (!(count1 == count2))
for (int j = 0; j <= count2; j++) {
b[count2 - j + count3] = b[count2 - j];
}
for (int j = 0; j < count3; j++) {
b[j] = '0';
}
for (int j = 1; j <= count1; j++) {
a[count1 - j] += b[count1 - j] - 48;
if (((int)a[count1 - j]) - 48 > 9) {
if (j >= 80) {
flag = 1;
break;
}
a[count1 - j] = (a[count1 - j] - 48) % 10 + 48;
if ((count1 - j) == 0) {
miss = 1;
} else {
a[count1 - j - 1] = a[count1 - j - 1] + 1;
}
}
}
}
else {
for (int j = 0; j <= count1; j++) {
a[count1 - j + count3] = a[count1 - j];
}
for (int j = 0; j < count3; j++) {
a[j] = '0';
}
for (int j = 1; j <= count2; j++) {
b[count2 - j] += a[count2 - j] - 48;
if (((int)b[count2 - j] - 48) > 9) {
if (j >= 80) {
flag = 1;
break;
}
b[count2 - j] = (b[count2 - j] - 48) % 10 + 48;
if ((count2 - j) == 0) {
miss = 1;
} else {
b[count2 - j - 1] = b[count2 - j - 1] + 1;
}
}
}
}
if (flag == 1) {
cout << "overflow" << endl;
}
else {
if (miss == 1) {
cout << '1';
}
if (daisyo == 0) {
for (int j = 0; j < count1; j++) {
cout << (int)a[j] - 48;
}
}
else {
for (int j = 0; j < count2; j++) {
cout << (int)b[j] - 48;
}
}
cout << endl;
}
}
return (0);
} | #include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int main(void) {
char a[1000] = {0}, b[1000] = {0};
int n, flag, count1, count2, count3, daisyo = 0, miss = 0;
cin >> n;
for (int i = 0; i < n; i++) {
flag = 0;
daisyo = 0;
miss = 0;
cin >> a >> b;
count1 = strlen(a);
count2 = strlen(b);
if (count1 > 80 || count2 > 80) {
flag = 1;
}
count3 = count1 - count2;
if (count2 > count1) {
count3 *= -1;
daisyo = 1;
}
if (daisyo == 0) {
if (!(count1 == count2))
for (int j = 0; j <= count2; j++) {
b[count2 - j + count3] = b[count2 - j];
}
for (int j = 0; j < count3; j++) {
b[j] = '0';
}
for (int j = 1; j <= count1; j++) {
a[count1 - j] += b[count1 - j] - 48;
if (((int)a[count1 - j]) - 48 > 9) {
if (j >= 80) {
flag = 1;
break;
}
a[count1 - j] = (a[count1 - j] - 48) % 10 + 48;
if ((count1 - j) == 0) {
miss = 1;
} else {
a[count1 - j - 1] = a[count1 - j - 1] + 1;
}
}
}
}
else {
for (int j = 0; j <= count1; j++) {
a[count1 - j + count3] = a[count1 - j];
}
for (int j = 0; j < count3; j++) {
a[j] = '0';
}
for (int j = 1; j <= count2; j++) {
b[count2 - j] += a[count2 - j] - 48;
if (((int)b[count2 - j] - 48) > 9) {
if (j >= 80) {
flag = 1;
break;
}
b[count2 - j] = (b[count2 - j] - 48) % 10 + 48;
if ((count2 - j) == 0) {
miss = 1;
} else {
b[count2 - j - 1] = b[count2 - j - 1] + 1;
}
}
}
}
if (flag == 1) {
cout << "overflow" << endl;
}
else {
if (miss == 1) {
cout << '1';
}
if (daisyo == 0) {
for (int j = 0; j < count1; j++) {
cout << (int)a[j] - 48;
}
}
else {
for (int j = 0; j < count2; j++) {
cout << (int)b[j] - 48;
}
}
cout << endl;
}
}
return (0);
} | replace | 7 | 8 | 7 | 8 | 0 | |
p00015 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int T;
cin >> T;
while (T--) {
// char s[100] = "abc";
string a, b;
cin >> a >> b;
reverse(a.begin(), a.end());
reverse(b.begin(), b.end());
while (a.size() < 100)
a += "0";
while (b.size() < 100)
b += "0";
string ans = "";
int carry = 0;
for (int i = 0; i < 100; i++) {
int d = (a[i] - '0') + (b[i] - '0') + carry;
ans += d % 10 + '0';
carry = d / 10;
}
reverse(ans.begin(), ans.end());
if (ans.find_first_not_of('0') < 20) {
cout << "overflow" << endl;
continue;
}
ans = ans.substr(ans.find_first_not_of('0'));
cout << ans << endl;
}
return 0;
} | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int T;
cin >> T;
while (T--) {
// char s[100] = "abc";
string a, b;
cin >> a >> b;
if (a == b) {
if (a == "0") {
cout << "0" << endl;
continue;
}
}
reverse(a.begin(), a.end());
reverse(b.begin(), b.end());
while (a.size() < 100)
a += "0";
while (b.size() < 100)
b += "0";
string ans = "";
int carry = 0;
for (int i = 0; i < 100; i++) {
int d = (a[i] - '0') + (b[i] - '0') + carry;
ans += d % 10 + '0';
carry = d / 10;
}
reverse(ans.begin(), ans.end());
if (ans.find_first_not_of('0') < 20) {
cout << "overflow" << endl;
continue;
}
ans = ans.substr(ans.find_first_not_of('0'));
cout << ans << endl;
}
return 0;
} | insert | 12 | 12 | 12 | 18 | 0 | |
p00015 | C++ | Time Limit Exceeded | #include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int main(void) {
int N, j, k = 0;
cin >> N;
char strA[300], strB[300];
while (1) {
k++;
if (k == N + 1) {
break;
}
cin >> strA >> strB;
int ans[81] = {0};
ans[0] = 11111;
if (strlen(strA) > 80 || strlen(strB) > 80) {
cout << "overflow" << endl;
continue;
}
int a[81] = {0}, b[81] = {0};
if (strA[strlen(strA) - 1] == '0' && strB[strlen(strB) - 1] == '0') {
cout << 0 << endl;
continue;
}
j = strlen(strA) - 1;
for (int i = 80; j >= 0; i--) {
a[i] = (int)strA[j] - 48;
j--;
}
j = strlen(strB) - 1;
for (int i = 80; j >= 0; i--) {
b[i] = (int)strB[j] - 48;
j--;
}
for (int i = 80; i != 0; i--) {
ans[i] = ans[i] + a[i] + b[i];
if (ans[i] >= 10) {
ans[i] = ans[i] - 10;
ans[i - 1]++;
}
}
if (ans[0] != 11111) {
cout << "overflow" << endl;
continue;
}
for (int i = 1; i < 81; i++) {
if (ans[i] != 0) {
j = i;
break;
}
}
char c[3];
for (int i = j; i < 81; i++) {
printf("%c", ans[i] + 48);
}
cout << '\n';
}
return 0;
} | #include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int main(void) {
int N, j, k = 0;
cin >> N;
char strA[100000], strB[100000];
while (1) {
k++;
if (k == N + 1) {
break;
}
cin >> strA >> strB;
int ans[81] = {0};
ans[0] = 11111;
if (strlen(strA) > 80 || strlen(strB) > 80) {
cout << "overflow" << endl;
continue;
}
int a[81] = {0}, b[81] = {0};
if (strA[strlen(strA) - 1] == '0' && strB[strlen(strB) - 1] == '0') {
cout << 0 << endl;
continue;
}
j = strlen(strA) - 1;
for (int i = 80; j >= 0; i--) {
a[i] = (int)strA[j] - 48;
j--;
}
j = strlen(strB) - 1;
for (int i = 80; j >= 0; i--) {
b[i] = (int)strB[j] - 48;
j--;
}
for (int i = 80; i != 0; i--) {
ans[i] = ans[i] + a[i] + b[i];
if (ans[i] >= 10) {
ans[i] = ans[i] - 10;
ans[i - 1]++;
}
}
if (ans[0] != 11111) {
cout << "overflow" << endl;
continue;
}
for (int i = 1; i < 81; i++) {
if (ans[i] != 0) {
j = i;
break;
}
}
char c[3];
for (int i = j; i < 81; i++) {
printf("%c", ans[i] + 48);
}
cout << '\n';
}
return 0;
} | replace | 8 | 9 | 8 | 9 | TLE | |
p00015 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define times(n, i) uptil(0, n, i)
#define upto(f, t, i) \
for (auto _##i = (t), i = decltype(_##i)(f) poi i <= _##i poi i++)
#define uptil(f, t, i) \
for (auto _##i = (t), i = decltype(_##i)(f) poi i < _##i poi i++)
#define downto(f, t, i) \
for (auto i = (f), _##i = decltype(i)(t) poi i >= _##i poi i--)
#define downtil(f, t, i) \
for (auto i = (f), _##i = decltype(i)(t) poi i > _##i poi i--)
#define unless(c) if (!(c))
#define until(c) while (!(c))
#define loop while (true)
#define poi ;
#define poipoi << "\n"
#define fuwafuwa(n, c) dokidoki((n) + (c)-1, c)
#define dokidoki(n, c) ((n) / (c) * (c))
template <class T> bool read(T &t) { return cin >> t poi }
template <class T, class... U> bool read(T &t, U &...u) {
unless(cin >> t) return false poi return read(u...) poi
}
const int PYON = 80 poi
int
main() {
int N poi cin >> N poi times(N, i) {
string A, B poi cin >> A >> B poi vector<int> a(PYON, 0),
b(PYON, 0) poi upto(1, A.size(), i) a[PYON - i] =
A[A.size() - i] - '0' poi upto(1, B.size(), i) b[PYON - i] =
B[B.size() - i] - '0' poi int pyon =
0 poi vector<int> sum(PYON) poi downto(PYON - 1, 0, i) {
sum[i] = a[i] + b[i] + pyon poi pyon = sum[i] / 10 poi sum[i] %= 10 poi
}
if (pyon)
cout << "overflow" poi else times(PYON, i) if ((pyon = pyon || sum[i]))
cout
<< sum[i] poi cout poipoi poi
}
return 0 poi
} | #include <bits/stdc++.h>
using namespace std;
#define times(n, i) uptil(0, n, i)
#define upto(f, t, i) \
for (auto _##i = (t), i = decltype(_##i)(f) poi i <= _##i poi i++)
#define uptil(f, t, i) \
for (auto _##i = (t), i = decltype(_##i)(f) poi i < _##i poi i++)
#define downto(f, t, i) \
for (auto i = (f), _##i = decltype(i)(t) poi i >= _##i poi i--)
#define downtil(f, t, i) \
for (auto i = (f), _##i = decltype(i)(t) poi i > _##i poi i--)
#define unless(c) if (!(c))
#define until(c) while (!(c))
#define loop while (true)
#define poi ;
#define poipoi << "\n"
#define fuwafuwa(n, c) dokidoki((n) + (c)-1, c)
#define dokidoki(n, c) ((n) / (c) * (c))
template <class T> bool read(T &t) { return cin >> t poi }
template <class T, class... U> bool read(T &t, U &...u) {
unless(cin >> t) return false poi return read(u...) poi
}
const int PYON = 80 poi
int
main() {
int N poi cin >> N poi times(N, i) {
string A, B poi cin >> A >> B poi if (A.size() > PYON || B.size() > PYON) {
cout << "overflow" poipoi poi continue poi
}
else if (A == "0" && B == "0"){cout
<< "0" poipoi poi continue poi} vector<int>
a(PYON, 0),
b(PYON, 0) poi upto(1, A.size(), i) a[PYON - i] =
A[A.size() - i] - '0' poi upto(1, B.size(), i) b[PYON - i] =
B[B.size() - i] - '0' poi int pyon =
0 poi vector<int> sum(PYON) poi downto(PYON - 1, 0, i) {
sum[i] = a[i] + b[i] + pyon poi pyon = sum[i] / 10 poi sum[i] %= 10 poi
}
if (pyon)
cout << "overflow" poi else times(PYON, i) if ((pyon = pyon || sum[i]))
cout
<< sum[i] poi cout poipoi poi
}
return 0 poi
} | replace | 33 | 34 | 33 | 39 | -6 | double free or corruption (out)
|
p00015 | C++ | Runtime Error | #include <algorithm>
#include <cctype>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <string>
using namespace std;
int N, ans[82], a, b, la, lb, up, deg;
string sta, stb;
int main() {
cin >> N;
for (int i = 0; i < N; i++) {
cin >> sta >> stb;
la = sta.size();
lb = stb.size();
up = 0;
deg = 1;
for (int i = 0; i < max(la, lb) + 1; i++) {
if (i >= la)
a = '0';
else
a = sta[la - 1 - i];
if (i >= lb)
b = '0';
else
b = stb[lb - 1 - i];
if (a + b + up > 105) {
ans[i] = a + b + up - 10 - 96;
up = 1;
} else {
ans[i] = a + b + up - 96;
up = 0;
}
if (ans[i] != 0)
deg = i + 1;
}
if (deg > 80)
cout << "overflow" << endl;
else {
for (int i = 0; i < deg; i++)
cout << ans[deg - 1 - i];
cout << endl;
}
}
} | #include <algorithm>
#include <cctype>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <string>
using namespace std;
int N, ans[82], a, b, la, lb, up, deg;
string sta, stb;
int main() {
cin >> N;
for (int i = 0; i < N; i++) {
cin >> sta >> stb;
la = sta.size();
lb = stb.size();
up = 0;
deg = 1;
for (int i = 0; i < max(la, lb) + 1; i++) {
if (i >= la)
a = '0';
else
a = sta[la - 1 - i];
if (i >= lb)
b = '0';
else
b = stb[lb - 1 - i];
if (min(a, b) > 80) {
cout << "overflow" << endl;
continue;
}
if (a + b + up > 105) {
ans[i] = a + b + up - 10 - 96;
up = 1;
} else {
ans[i] = a + b + up - 96;
up = 0;
}
if (ans[i] != 0)
deg = i + 1;
}
if (deg > 80)
cout << "overflow" << endl;
else {
for (int i = 0; i < deg; i++)
cout << ans[deg - 1 - i];
cout << endl;
}
}
} | insert | 30 | 30 | 30 | 34 | 0 | |
p00016 | C++ | Time Limit Exceeded | #include <iostream>
#include <math.h>
#include <string>
#include <vector>
using namespace std;
int main() {
int dis1, rad1, dis2 = 0, rad2 = 0;
double x = 0, y = 0, PI = 3.141592653589793;
scanf("%d , %d", &dis1, &rad1);
y += dis1;
rad2 = rad1;
while (scanf("%d , %d", &dis1, &rad1)) {
if (dis1 != 0) {
x += dis1 * sin(rad2 * PI / 180);
y += dis1 * cos(rad2 * PI / 180);
rad2 += rad1;
} else {
cout << int(x) << endl;
cout << int(y) << endl;
}
}
return 0;
} | #include <iostream>
#include <math.h>
#include <string>
#include <vector>
using namespace std;
int main() {
int dis1, rad1, dis2 = 0, rad2 = 0;
double x = 0, y = 0, PI = 3.141592653589793;
scanf("%d , %d", &dis1, &rad1);
y += dis1;
rad2 = rad1;
while (scanf("%d , %d", &dis1, &rad1)) {
if (dis1 != 0) {
x += dis1 * sin(rad2 * PI / 180);
y += dis1 * cos(rad2 * PI / 180);
rad2 += rad1;
} else {
cout << int(x) << endl;
cout << int(y) << endl;
break;
}
}
return 0;
} | insert | 20 | 20 | 20 | 21 | TLE | |
p00016 | C++ | Runtime Error | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <vector>
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
#define ALL(a) (a).begin(), (a).end()
#define REP(i, n) for (int i = 0; i < (n); ++i)
const double EPS = 1e-10;
const double PI = acos(-1.0);
#define dump(x) \
cerr << " (L" << __LINE__ << ") " << #x << " = " << (x) << endl;
#define dumpv(x) \
cerr << " (L" << __LINE__ << ") " << #x << " = "; \
REP(q, (x).size()) cerr << (x)[q] << " "; \
cerr << endl;
template <typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &d) {
return s << "(" << d.first << "," << d.second << ")";
}
int main() {
double x = 0.0, y = 0.0;
double angle = 90;
while (true) {
int a, b;
scanf("%d,%d", &a, &b);
if (a == 0 && b == 0)
break;
double theta = PI * angle / 180.0;
dump(theta);
x += a * cos(theta);
y += a * sin(theta);
angle -= b;
}
printf("%d\n%d\n", (int)x, (int)y);
} | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <vector>
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
#define ALL(a) (a).begin(), (a).end()
#define REP(i, n) for (int i = 0; i < (n); ++i)
const double EPS = 1e-10;
const double PI = acos(-1.0);
#define dump(x) \
cerr << " (L" << __LINE__ << ") " << #x << " = " << (x) << endl;
#define dumpv(x) \
cerr << " (L" << __LINE__ << ") " << #x << " = "; \
REP(q, (x).size()) cerr << (x)[q] << " "; \
cerr << endl;
template <typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &d) {
return s << "(" << d.first << "," << d.second << ")";
}
int main() {
double x = 0.0, y = 0.0;
double angle = 90;
while (true) {
int a, b;
scanf("%d,%d", &a, &b);
if (a == 0 && b == 0)
break;
double theta = PI * angle / 180.0;
x += a * cos(theta);
y += a * sin(theta);
angle -= b;
}
printf("%d\n%d\n", (int)x, (int)y);
} | delete | 43 | 44 | 43 | 43 | 0 | (L37) theta = 1.5708
(L37) theta = 0.436332
(L37) theta = -0.506145
(L37) theta = -0.436332
(L37) theta = -1.76278
(L37) theta = -1.29154
(L37) theta = -2.68781
(L37) theta = -1.18682
(L37) theta = -1.0821
(L37) theta = -1.67552
|
p00016 | C++ | Time Limit Exceeded | #include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
int d, t;
double x = 0, y = 0;
double angle = 90;
while (1) {
cin >> d >> t;
if (d == 0 && t == 0)
break;
x += d * cos(angle / 180 * acos(-1));
y += d * sin(angle / 180 * acos(-1));
angle -= t;
}
cout << (int)x << endl;
cout << (int)y << endl;
} | #include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
int d, t;
double x = 0, y = 0;
double angle = 90;
while (1) {
char c;
cin >> d >> c >> t;
if (d == 0 && t == 0)
break;
x += d * cos(angle / 180 * acos(-1));
y += d * sin(angle / 180 * acos(-1));
angle -= t;
}
cout << (int)x << endl;
cout << (int)y << endl;
} | replace | 10 | 11 | 10 | 12 | TLE | |
p00016 | C++ | Time Limit Exceeded | #include <algorithm>
#include <fstream>
#include <iostream>
#include <math.h>
#include <queue>
#include <utility>
#include <vector>
#define PI 3.141592
using namespace std;
int main() {
ifstream cin("../test.txt");
double x, y, ca, a, l;
x = 0;
y = 0;
ca = PI / 2;
char c;
while (true) {
cin >> l >> c >> a; // 進む距離と回転角度
if (l == 0 && a == 0)
break;
x += l * cos(ca);
y += l * sin(ca);
ca -= a * PI / 180.0;
}
cout << (int)x << endl;
cout << (int)y << endl;
} | #include <algorithm>
#include <fstream>
#include <iostream>
#include <math.h>
#include <queue>
#include <utility>
#include <vector>
#define PI 3.141592
using namespace std;
int main() {
// ifstream cin("../test.txt");
double x, y, ca, a, l;
x = 0;
y = 0;
ca = PI / 2;
char c;
while (true) {
cin >> l >> c >> a; // 進む距離と回転角度
if (l == 0 && a == 0)
break;
x += l * cos(ca);
y += l * sin(ca);
ca -= a * PI / 180.0;
}
cout << (int)x << endl;
cout << (int)y << endl;
} | replace | 11 | 12 | 11 | 12 | TLE | |
p00016 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
int main() {
double x = 0, y = 0, s = 90, a, b;
while (scanf("%f,%f", &a, &b), a) {
x += a * cos(s * M_PI / 180);
y += a * sin(s * M_PI / 180);
s -= b;
}
cout << (int)x << endl;
cout << (int)y << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
double x = 0, y = 0, s = 90;
int a, b;
while (scanf("%d,%d", &a, &b), a) {
x += a * cos(s * M_PI / 180);
y += a * sin(s * M_PI / 180);
s -= b;
}
cout << (int)x << endl;
cout << (int)y << endl;
} | replace | 3 | 5 | 3 | 6 | TLE | |
p00017 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
int main() {
string str;
while (getline(cin, str)) {
while (1) {
if (str.find("the") != -1 || str.find("that") != -1 ||
str.find("this") != -1)
break;
for (int i = 0; i < str.size(); i++) {
if (str[i] == '.' || str[i] == ' ') {
} else
str[i]--;
}
}
cout << str << endl;
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
string str;
while (getline(cin, str)) {
while (1) {
if (str.find("the") != -1 || str.find("that") != -1 ||
str.find("this") != -1)
break;
for (int i = 0; i < str.size(); i++) {
if (str[i] == '.' || str[i] == ' ') {
} else if (str[i] == 'a')
str[i] = 'z';
else
str[i]--;
}
}
cout << str << endl;
}
return 0;
} | replace | 11 | 12 | 11 | 14 | TLE | |
p00017 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <list>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define PUSH(n, v) \
for (int i = 0; i < (n); i++) { \
int j; \
cin >> j; \
v.push_back(j); \
}
#define ALL(v) v.begin(), v.end()
void rot1(string &s) {
string t = "";
REP(i, s.size()) {
if (s[i] > 'a' && s[i] < 'z') {
if (s[i] == 'a')
t += "z";
else
t += s[i] - 1;
} else {
t += s[i];
}
}
s = t;
}
int main() {
string s;
while (getline(cin, s)) {
while (s.find("the") == string::npos && s.find("this") == string::npos &&
s.find("that") == string::npos) {
rot1(s);
}
cout << s << endl;
}
return 0;
} | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <list>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define PUSH(n, v) \
for (int i = 0; i < (n); i++) { \
int j; \
cin >> j; \
v.push_back(j); \
}
#define ALL(v) v.begin(), v.end()
void rot1(string &s) {
string t = "";
REP(i, s.size()) {
if (s[i] >= 'a' && s[i] <= 'z') {
if (s[i] == 'a')
t += "z";
else
t += s[i] - 1;
} else {
t += s[i];
}
}
s = t;
}
int main() {
string s;
while (getline(cin, s)) {
while (s.find("the") == string::npos && s.find("this") == string::npos &&
s.find("that") == string::npos) {
rot1(s);
}
cout << s << endl;
}
return 0;
} | replace | 23 | 24 | 23 | 24 | TLE | |
p00017 | C++ | Time Limit Exceeded | #include <iostream>
using namespace std;
int main() {
string s;
for (; getline(cin, s);) {
cin.ignore();
bool f = 0;
for (; !f;) {
for (int i = 0; i < s.size(); i++) {
if (s[i] >= 'a' && s[i] <= 'z') {
s[i]--;
if (s[i] < 'a')
s[i] = 'z';
}
}
string t[3] = {"the", "this", "that"};
for (int i = 0; !f && i < 3; i++) {
for (int j = 0; !f && j + t[i].size() < s.size(); j++) {
if (s.substr(j, t[i].size()) == t[i]) {
cout << s << endl;
f = 1;
}
}
}
}
}
}
| #include <iostream>
using namespace std;
int main() {
string s;
for (; getline(cin, s);) {
bool f = 0;
for (; !f;) {
for (int i = 0; i < s.size(); i++) {
if (s[i] >= 'a' && s[i] <= 'z') {
s[i]--;
if (s[i] < 'a')
s[i] = 'z';
}
}
string t[3] = {"the", "this", "that"};
for (int i = 0; !f && i < 3; i++) {
for (int j = 0; !f && j + t[i].size() < s.size(); j++) {
if (s.substr(j, t[i].size()) == t[i]) {
cout << s << endl;
f = 1;
}
}
}
}
}
}
| delete | 5 | 6 | 5 | 5 | TLE | |
p00017 | C++ | Runtime Error | #include <iostream>
#include <string>
using namespace std;
int main() {
string stro, str;
while (getline(cin, stro)) {
for (int i = 0; i < 26; i++) {
str = stro;
for (int j = 0; j < stro.length(); j++) {
if (str[j] >= 'a' && str[j] <= 'z')
if (str[j] + i > 'z')
str[j] += i - 26;
else
str[j] += i;
}
unsigned f_the = str.find("the", 0);
unsigned f_this = str.find("this", 0);
unsigned f_that = str.find("that", 0);
if ((f_the != string::npos && f_the == 0 &&
(str[f_the + 3] == ' ' || str[f_the + 3] == '.' ||
str[f_the + 3] == '\0')) ||
(f_this != string::npos && f_this == 0 &&
(str[f_this + 4] == ' ' || str[f_this + 4] == '.' ||
str[f_this + 4] == '\0')) ||
(f_that != string::npos && f_that == 0 &&
(str[f_that + 4] == ' ' || str[f_that + 4] == '.' ||
str[f_that + 4] == '\0')))
cout << str << endl;
else if ((f_the != string::npos &&
(str[(f_the - 1 < 0) ? 0 : f_the - 1] == ' ' ||
str[(f_the - 1 < 0) ? 0 : f_the - 1] == '.' ||
str[(f_the - 1 < 0) ? 0 : f_the - 1] == '\n') &&
(str[f_the + 3] == ' ' || str[f_the + 3] == '.' ||
str[f_the + 3] == '\0')) ||
(f_this != string::npos &&
(str[(f_this - 1 < 0) ? 0 : f_this - 1] == ' ' ||
str[(f_this - 1 < 0) ? 0 : f_this - 1] == '.' ||
str[(f_this - 1 < 0) ? 0 : f_this - 1] == '\n') &&
(str[f_this + 4] == ' ' || str[f_this + 4] == '.' ||
str[f_this + 4] == '\0')) ||
(f_that != string::npos &&
(str[(f_that - 1 < 0) ? 0 : f_that - 1] == ' ' ||
str[(f_that - 1 < 0) ? 0 : f_that - 1] == '.' ||
str[(f_that - 1 < 0) ? 0 : f_that - 1] == '\n') &&
(str[f_that + 4] == ' ' || str[f_that + 4] == '.' ||
str[f_that + 4] == '\0')))
cout << str << endl;
}
}
} | #include <iostream>
#include <string>
using namespace std;
int main() {
string stro, str;
while (getline(cin, stro)) {
for (int i = 0; i < 26; i++) {
str = stro;
for (int j = 0; j < stro.length(); j++) {
if (str[j] >= 'a' && str[j] <= 'z')
if (str[j] + i > 'z')
str[j] += i - 26;
else
str[j] += i;
}
std::string::size_type f_the = str.find("the", 0);
std::string::size_type f_this = str.find("this", 0);
std::string::size_type f_that = str.find("that", 0);
if ((f_the != string::npos && f_the == 0 &&
(str[f_the + 3] == ' ' || str[f_the + 3] == '.' ||
str[f_the + 3] == '\0')) ||
(f_this != string::npos && f_this == 0 &&
(str[f_this + 4] == ' ' || str[f_this + 4] == '.' ||
str[f_this + 4] == '\0')) ||
(f_that != string::npos && f_that == 0 &&
(str[f_that + 4] == ' ' || str[f_that + 4] == '.' ||
str[f_that + 4] == '\0')))
cout << str << endl;
else if ((f_the != string::npos &&
(str[(f_the - 1 < 0) ? 0 : f_the - 1] == ' ' ||
str[(f_the - 1 < 0) ? 0 : f_the - 1] == '.' ||
str[(f_the - 1 < 0) ? 0 : f_the - 1] == '\n') &&
(str[f_the + 3] == ' ' || str[f_the + 3] == '.' ||
str[f_the + 3] == '\0')) ||
(f_this != string::npos &&
(str[(f_this - 1 < 0) ? 0 : f_this - 1] == ' ' ||
str[(f_this - 1 < 0) ? 0 : f_this - 1] == '.' ||
str[(f_this - 1 < 0) ? 0 : f_this - 1] == '\n') &&
(str[f_this + 4] == ' ' || str[f_this + 4] == '.' ||
str[f_this + 4] == '\0')) ||
(f_that != string::npos &&
(str[(f_that - 1 < 0) ? 0 : f_that - 1] == ' ' ||
str[(f_that - 1 < 0) ? 0 : f_that - 1] == '.' ||
str[(f_that - 1 < 0) ? 0 : f_that - 1] == '\n') &&
(str[f_that + 4] == ' ' || str[f_that + 4] == '.' ||
str[f_that + 4] == '\0')))
cout << str << endl;
}
}
} | replace | 17 | 20 | 17 | 20 | -11 | |
p00017 | C++ | Time Limit Exceeded | #include <iostream>
#include <string>
char chshift(char ch) {
if (ch >= 'a' && ch <= 'z') {
return (ch - 'a' + 1) % 26 + 'a';
} else {
return ch;
}
}
std::string strshift(std::string s) {
for (int i = 0; i < s.length(); i++) {
s[i] = chshift(s[i]);
}
return s;
}
bool valid_text_p(std::string str) {
return str.find("the") != -1 && str.find("that") != -1 &&
str.find("this") != -1;
}
int main() {
std::string s;
while (std::getline(std::cin, s), !std::cin.eof()) {
for (;; s = strshift(s)) {
if (valid_text_p(s)) {
std::cout << s << std::endl;
break;
}
}
}
return 0;
} | #include <iostream>
#include <string>
char chshift(char ch) {
if (ch >= 'a' && ch <= 'z') {
return (ch - 'a' + 1) % 26 + 'a';
} else {
return ch;
}
}
std::string strshift(std::string s) {
for (int i = 0; i < s.length(); i++) {
s[i] = chshift(s[i]);
}
return s;
}
bool valid_text_p(std::string str) {
return str.find("the") != -1 || str.find("that") != -1 ||
str.find("this") != -1;
}
int main() {
std::string s;
while (std::getline(std::cin, s), !std::cin.eof()) {
for (;; s = strshift(s)) {
if (valid_text_p(s)) {
std::cout << s << std::endl;
break;
}
}
}
return 0;
} | replace | 19 | 20 | 19 | 20 | TLE | |
p00017 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
void f(string &s) {
for (char &c : s) {
if ('a' <= c && c <= 'z')
c = (c + 25) % 26 + 'a';
}
}
int main() {
string s;
while (getline(cin, s)) {
if (s.empty())
break;
while (s.find("the") == string::npos && s.find("this") == string::npos &&
s.find("that") == string::npos)
f(s);
cout << s << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
void f(string &s) {
for (char &c : s) {
if ('a' <= c && c <= 'z')
c = (c - 'a' + 25) % 26 + 'a';
}
}
int main() {
string s;
while (getline(cin, s)) {
if (s.empty())
break;
while (s.find("the") == string::npos && s.find("this") == string::npos &&
s.find("that") == string::npos)
f(s);
cout << s << endl;
}
} | replace | 7 | 8 | 7 | 8 | TLE | |
p00017 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, a, b) for ((i) = (a); (i) < (int)(b); (i)++)
#define rep(i, n) REP(i, 0, n)
// BEGIN CUT HERE
#define foreach(itr, c) \
for (typeof((c).begin()) itr = (c).begin(); itr != (c).end(); itr++)
template <class T> inline string toString(T x) {
ostringstream sout;
sout << x;
return sout.str();
}
// END CUT HERE
int main() {
string str;
while (getline(cin, str)) {
int i, N = str.size();
while (1) {
rep(i, N) if ('a' <= str[i] && str[i] <= 'z') str[i]--;
if (str.find("this") != -1 || str.find("the") != -1 ||
str.find("that") != -1) {
cout << str << endl;
break;
}
}
}
return 0;
} | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, a, b) for ((i) = (a); (i) < (int)(b); (i)++)
#define rep(i, n) REP(i, 0, n)
// BEGIN CUT HERE
#define foreach(itr, c) \
for (typeof((c).begin()) itr = (c).begin(); itr != (c).end(); itr++)
template <class T> inline string toString(T x) {
ostringstream sout;
sout << x;
return sout.str();
}
// END CUT HERE
int main() {
string str;
while (getline(cin, str)) {
int i, N = str.size();
while (1) {
rep(i, N) if ('a' <= str[i] && str[i] <= 'z') {
str[i]--;
if (str[i] < 'a')
str[i] = 'z';
}
if (str.find("this") != -1 || str.find("the") != -1 ||
str.find("that") != -1) {
cout << str << endl;
break;
}
}
}
return 0;
} | replace | 36 | 37 | 36 | 41 | TLE | |
p00017 | C++ | Time Limit Exceeded | #include <cstring>
#include <iostream>
using namespace std;
int main(void) {
while (true) {
string str;
if (!getline(cin, str))
break;
;
while (true) {
for (int i = 0; i < str.size(); i++) {
if (isalpha(str[i]) && str[i] == 'z') {
str[i] = 'a';
} else if (isalpha(str[i])) {
str[i]++;
}
}
if (str.find("that") != string::npos || str.find("the") != string::npos ||
str.find("the") != string::npos)
break;
}
cout << str << endl;
}
return 0;
} | #include <cstring>
#include <iostream>
using namespace std;
int main(void) {
while (true) {
string str;
if (!getline(cin, str))
break;
;
while (true) {
for (int i = 0; i < str.size(); i++) {
if (isalpha(str[i]) && str[i] == 'z') {
str[i] = 'a';
} else if (isalpha(str[i])) {
str[i]++;
}
}
if (str.find("that") != string::npos ||
str.find("this") != string::npos || str.find("the") != string::npos)
break;
}
cout << str << endl;
}
return 0;
} | replace | 18 | 20 | 18 | 20 | TLE | |
p00017 | C++ | Time Limit Exceeded | #include <iostream>
#include <string>
bool NotMatch(const std::string &str) {
return str.find("the") == std::string::npos &&
str.find("this") == std::string::npos &&
str.find("that") == std::string::npos;
}
int main() {
std::string str;
while (getline(std::cin, str)) {
while (NotMatch(str)) {
for (unsigned i = 0; i < str.length(); ++i) {
if (str[i] == '.' || str[i] == ' ' || str[i] == '\n') {
continue;
}
if (str[i] == 'z') {
str[i] = 'a';
} else {
--str[i];
}
}
}
std::cout << str << '\n';
}
} | #include <iostream>
#include <string>
bool NotMatch(const std::string &str) {
return str.find("the") == std::string::npos &&
str.find("this") == std::string::npos &&
str.find("that") == std::string::npos;
}
int main() {
std::string str;
while (getline(std::cin, str)) {
while (NotMatch(str)) {
for (unsigned i = 0; i < str.length(); ++i) {
if (str[i] == '.' || str[i] == ' ' || str[i] == '\n') {
continue;
}
if (str[i] == 'z') {
str[i] = 'a';
} else {
++str[i];
}
}
}
std::cout << str << '\n';
}
} | replace | 21 | 22 | 21 | 22 | TLE | |
p00017 | C++ | Time Limit Exceeded | #include <cctype>
#include <cstdio>
#include <cstring>
char str[1000000] = {0};
using namespace std;
int main() {
int f = 0;
while (scanf("%[^\n]", str) != EOF) {
fflush(stdin);
for (int i = 0; i <= 25; i++) {
for (int j = 0; j < strlen(str); j++) {
if (str[j] == ' ' || str[j] == '.')
continue;
str[j]++;
if (str[j] > 122)
str[j] = str[j] - 26;
}
for (int j = 0; j < strlen(str); j++) {
if (str[j] == 't' && str[j + 1] == 'h' && str[j + 2] == 'e')
goto hoge;
if (str[j] == 't' && str[j + 1] == 'h' && str[j + 2] == 'i' &&
str[j + 3] == 's')
goto hoge;
if (str[j] == 't' && str[j + 1] == 'h' && str[j + 2] == 'a' &&
str[j + 3] == 't')
goto hoge;
}
}
for (int i = 0; i < strlen(str); i++) {
if (str[i] == ' ' || str[i] == '.')
continue;
str[i] -= 25;
}
for (int i = 0; i <= 25; i++) {
for (int j = 0; j < strlen(str); j++) {
if (str[j] == ' ' || str[j] == '.')
continue;
str[j]--;
if (str[j] < 97)
str[j] = str[j] + 25;
}
for (int j = 0; j < strlen(str); j++) {
if (str[j] == 't' && str[j + 1] == 'h' && str[j + 2] == 'e')
goto hoge;
if (str[j] == 't' && str[j + 1] == 'h' && str[j + 2] == 'i' &&
str[j + 3] == 's')
goto hoge;
if (str[j] == 't' && str[j + 1] == 'h' && str[j + 2] == 'a' &&
str[j + 3] == 't')
goto hoge;
}
}
hoge:
printf("%s\n", str);
memset(str, 0, sizeof(str));
}
return 0;
} | #include <cctype>
#include <cstdio>
#include <cstring>
char str[1000000] = {0};
using namespace std;
int main() {
int f = 0;
while (scanf("%[^\n]", str) != EOF) {
getchar();
for (int i = 0; i <= 25; i++) {
for (int j = 0; j < strlen(str); j++) {
if (str[j] == ' ' || str[j] == '.')
continue;
str[j]++;
if (str[j] > 122)
str[j] = str[j] - 26;
}
for (int j = 0; j < strlen(str); j++) {
if (str[j] == 't' && str[j + 1] == 'h' && str[j + 2] == 'e')
goto hoge;
if (str[j] == 't' && str[j + 1] == 'h' && str[j + 2] == 'i' &&
str[j + 3] == 's')
goto hoge;
if (str[j] == 't' && str[j + 1] == 'h' && str[j + 2] == 'a' &&
str[j + 3] == 't')
goto hoge;
}
}
for (int i = 0; i < strlen(str); i++) {
if (str[i] == ' ' || str[i] == '.')
continue;
str[i] -= 25;
}
for (int i = 0; i <= 25; i++) {
for (int j = 0; j < strlen(str); j++) {
if (str[j] == ' ' || str[j] == '.')
continue;
str[j]--;
if (str[j] < 97)
str[j] = str[j] + 25;
}
for (int j = 0; j < strlen(str); j++) {
if (str[j] == 't' && str[j + 1] == 'h' && str[j + 2] == 'e')
goto hoge;
if (str[j] == 't' && str[j + 1] == 'h' && str[j + 2] == 'i' &&
str[j + 3] == 's')
goto hoge;
if (str[j] == 't' && str[j + 1] == 'h' && str[j + 2] == 'a' &&
str[j + 3] == 't')
goto hoge;
}
}
hoge:
printf("%s\n", str);
memset(str, 0, sizeof(str));
}
return 0;
} | replace | 8 | 9 | 8 | 9 | TLE | |
p00017 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <ctype.h>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <utility>
#include <vector>
using namespace std;
char c[85];
bool search_th() {
bool f = false;
for (int i = 0; i < strlen(c); i++) {
if ((c[i] == 't' && c[i + 1] == 'h' && c[i + 2] == 'e') ||
(c[i] == 't' && c[i + 1] == 'h' && c[i + 2] == 'i' &&
c[i + 3] == 's') ||
(c[i] == 't' && c[i + 1] == 'h' && c[i + 2] == 'a' &&
c[i + 3] == 't')) {
f = true;
break;
}
}
return f;
}
int main() {
while (cin.getline(c, sizeof(c))) {
while (1) {
if (search_th() == true) {
cout << c << endl;
break;
}
for (int j = 0; j < strlen(c); j++) {
if (c[j] >= 'a' && c[j] <= 'y')
c[j]++;
if (c[j] == 'z')
c[j] = 'a';
}
}
for (int i = strlen(c); i < 85; i++) {
c[i] = '\0';
}
}
return 0;
}
| #include <algorithm>
#include <cmath>
#include <cstdio>
#include <ctype.h>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <utility>
#include <vector>
using namespace std;
char c[85];
bool search_th() {
bool f = false;
for (int i = 0; i < strlen(c); i++) {
if ((c[i] == 't' && c[i + 1] == 'h' && c[i + 2] == 'e') ||
(c[i] == 't' && c[i + 1] == 'h' && c[i + 2] == 'i' &&
c[i + 3] == 's') ||
(c[i] == 't' && c[i + 1] == 'h' && c[i + 2] == 'a' &&
c[i + 3] == 't')) {
f = true;
break;
}
}
return f;
}
int main() {
while (cin.getline(c, sizeof(c))) {
while (1) {
if (search_th() == true) {
cout << c << endl;
break;
}
for (int j = 0; j < strlen(c); j++) {
if (c[j] >= 'a' && c[j] <= 'y')
c[j]++;
else if (c[j] == 'z')
c[j] = 'a';
}
}
for (int i = strlen(c); i < 85; i++) {
c[i] = '\0';
}
}
return 0;
}
| replace | 47 | 48 | 47 | 48 | TLE | |
p00017 | C++ | Time Limit Exceeded | #include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int main() {
int f = 0, i;
for (;;) {
char word[100] = {0};
for (i = 0;; i++) {
if (scanf("%c", &word[i]) == EOF) {
f = 1;
word[i] = 10;
break;
}
if (word[i] == 10) {
break;
}
}
for (;;) {
for (i = 0; i < (int)strlen(word); i++) {
if (word[i] == 't' && word[i + 1] == 'h' && word[i + 2] == 'i' &&
word[i + 3] == 's' && word[i + 4] == ' ') {
break;
} else if (word[i] == 't' && word[i + 1] == 'h' && word[i + 2] == 'a' &&
word[i + 3] == 't' && word[i + 4] == ' ') {
break;
} else if (word[i] == 't' && word[i + 1] == 'h' && word[i + 2] == 'e' &&
word[i + 3] == ' ') {
break;
} else if (word[i] == 't' && word[i + 1] == 'h' && word[i + 2] == 'i' &&
word[i + 3] == 's' && word[i + 4] == '\n') {
break;
} else if (word[i] == 't' && word[i + 1] == 'h' && word[i + 2] == 'a' &&
word[i + 3] == 't' && word[i + 4] == '\n') {
break;
} else if (word[i] == 't' && word[i + 1] == 'h' && word[i + 2] == 'e' &&
word[i + 3] == '\n') {
break;
}
}
if (i != (int)strlen(word)) {
cout << word;
break;
}
for (i = 0; i < (int)strlen(word); i++) {
if (word[i] == 122) {
word[i] = 97;
} else if (word[i] >= 97 && word[i] < 122) {
word[i]++;
}
}
}
if (f == 1) {
break;
}
}
return 0;
} | #include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int main() {
int f = 0, i;
for (;;) {
char word[100] = {0};
for (i = 0;; i++) {
if (scanf("%c", &word[i]) == EOF) {
f = 1;
word[i] = 10;
break;
}
if (word[i] == 10) {
break;
}
}
for (int l = 0; l < 26; l++) {
for (i = 0; i < (int)strlen(word); i++) {
if (word[i] == 't' && word[i + 1] == 'h' && word[i + 2] == 'i' &&
word[i + 3] == 's' && word[i + 4] == ' ') {
break;
} else if (word[i] == 't' && word[i + 1] == 'h' && word[i + 2] == 'a' &&
word[i + 3] == 't' && word[i + 4] == ' ') {
break;
} else if (word[i] == 't' && word[i + 1] == 'h' && word[i + 2] == 'e' &&
word[i + 3] == ' ') {
break;
} else if (word[i] == 't' && word[i + 1] == 'h' && word[i + 2] == 'i' &&
word[i + 3] == 's' && word[i + 4] == '\n') {
break;
} else if (word[i] == 't' && word[i + 1] == 'h' && word[i + 2] == 'a' &&
word[i + 3] == 't' && word[i + 4] == '\n') {
break;
} else if (word[i] == 't' && word[i + 1] == 'h' && word[i + 2] == 'e' &&
word[i + 3] == '\n') {
break;
}
}
if (i != (int)strlen(word)) {
cout << word;
break;
}
for (i = 0; i < (int)strlen(word); i++) {
if (word[i] == 122) {
word[i] = 97;
} else if (word[i] >= 97 && word[i] < 122) {
word[i]++;
}
}
}
if (f == 1) {
break;
}
}
return 0;
} | replace | 18 | 19 | 18 | 19 | TLE | |
p00017 | C++ | Time Limit Exceeded | #include <iostream>
#include <string>
using namespace std;
int main() {
string s;
while (getline(cin, s)) {
string dec = s;
while (true) {
if (dec.find("the") != -1 || dec.find("this") != -1 ||
dec.find("that") != -1) {
cout << dec << endl;
break;
}
for (int i = 0; i < dec.size(); i++) {
if ('a' <= dec[i] && dec[i] < 'z')
dec[i]++;
if (dec[i] == 'z')
dec[i] = 'a';
}
}
}
return 0;
} | #include <iostream>
#include <string>
using namespace std;
int main() {
string s;
while (getline(cin, s)) {
string dec = s;
while (true) {
if (dec.find("the") != -1 || dec.find("this") != -1 ||
dec.find("that") != -1) {
cout << dec << endl;
break;
}
for (int i = 0; i < dec.size(); i++) {
if ('a' <= dec[i] && dec[i] < 'z')
dec[i]++;
else if (dec[i] == 'z')
dec[i] = 'a';
}
}
}
return 0;
} | replace | 17 | 18 | 17 | 18 | TLE | |
p00017 | C++ | Runtime Error | #include <cassert>
#include <iostream>
#include <string>
using namespace std;
bool IncludeKeyWords(const string &Sentence) {
if (Sentence.find("the") <= 80)
return true;
if (Sentence.find("this") <= 80)
return true;
if (Sentence.find("that") <= 80)
return true;
return false;
}
string OneShift(string Sentence) {
for (int i = 0; i < Sentence.size(); i++) {
if (97 < Sentence[i] && Sentence[i] < 123) {
Sentence[i]--;
} else if (Sentence[i] == 97) {
Sentence[i] = 123;
}
}
return Sentence;
}
string Decrypt(string Sentence) {
int RoopCount = 0;
while (IncludeKeyWords(Sentence) == false) {
assert(RoopCount < 26);
Sentence = OneShift(Sentence);
RoopCount++;
}
return Sentence;
}
int main() {
while (true) {
string Sentence;
getline(cin, Sentence);
if (cin.eof() == true)
break;
string DecryptedSentence = Decrypt(Sentence);
cout << DecryptedSentence << endl;
}
return 0;
} | #include <cassert>
#include <iostream>
#include <string>
using namespace std;
bool IncludeKeyWords(const string &Sentence) {
if (Sentence.find("the") <= 80)
return true;
if (Sentence.find("this") <= 80)
return true;
if (Sentence.find("that") <= 80)
return true;
return false;
}
string OneShift(string Sentence) {
for (int i = 0; i < Sentence.size(); i++) {
if (97 < Sentence[i] && Sentence[i] < 123) {
Sentence[i]--;
} else if (Sentence[i] == 97) {
Sentence[i] = 122;
}
}
return Sentence;
}
string Decrypt(string Sentence) {
int RoopCount = 0;
while (IncludeKeyWords(Sentence) == false) {
assert(RoopCount < 26);
Sentence = OneShift(Sentence);
RoopCount++;
}
return Sentence;
}
int main() {
while (true) {
string Sentence;
getline(cin, Sentence);
if (cin.eof() == true)
break;
string DecryptedSentence = Decrypt(Sentence);
cout << DecryptedSentence << endl;
}
return 0;
} | replace | 20 | 21 | 20 | 21 | 0 | |
p00017 | C++ | Time Limit Exceeded | #include <iostream>
#include <string>
using namespace std;
int main() {
string str;
while (getline(cin, str)) {
while (str.find("this", 0) == string::npos ||
str.find("that", 0) == string::npos ||
str.find("the", 0) == string::npos) {
for (int i = 0; i < str.size(); ++i) {
if (str[i] >= 'a' && str[i] <= 'z') {
if (str[i] != 'z')
++str[i];
else
str[i] = 'a';
}
}
}
cout << str << endl;
}
return 0;
} | #include <iostream>
#include <string>
using namespace std;
int main() {
string str;
while (getline(cin, str)) {
while (str.find("this", 0) == string::npos &&
str.find("that", 0) == string::npos &&
str.find("the", 0) == string::npos) {
for (int i = 0; i < str.size(); ++i) {
if (str[i] >= 'a' && str[i] <= 'z') {
if (str[i] != 'z')
++str[i];
else
str[i] = 'a';
}
}
}
cout << str << endl;
}
return 0;
} | replace | 7 | 9 | 7 | 9 | TLE | |
p00017 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
void f(string &s) {
for (char &c : s) {
if ('a' <= c && c <= 'z')
c = (c - 'a' + 25) % 26 + 'a';
}
}
int main() {
string s;
while (getline(cin, s)) {
if (s == "")
break;
while (s.find("the") == string::npos || s.find("this") == string::npos ||
s.find("that") == string::npos)
f(s);
cout << s << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
void f(string &s) {
for (char &c : s) {
if ('a' <= c && c <= 'z')
c = (c - 'a' + 25) % 26 + 'a';
}
}
int main() {
string s;
while (getline(cin, s)) {
if (s == "")
break;
while (s.find("the") == string::npos && s.find("this") == string::npos &&
s.find("that") == string::npos)
f(s);
cout << s << endl;
}
} | replace | 17 | 18 | 17 | 18 | TLE | |
p00018 | C++ | Time Limit Exceeded | #include <algorithm>
#include <iostream>
using namespace std;
int main() {
int num[5];
for (int i = 0; i = 4; i++)
cin >> num[i];
sort(num, num + 5);
for (int i = 4; i = 1; i--)
cout << num[i] << " ";
cout << num[0] << "\n";
} | #include <algorithm>
#include <iostream>
using namespace std;
int main() {
int in[5];
for (int i = 0; i < 5; i++)
cin >> in[i];
sort(in, in + 5, greater<int>());
for (int i = 0; i < 4; i++)
cout << in[i] << " ";
cout << in[4] << endl;
} | replace | 4 | 15 | 4 | 11 | TLE | |
p00018 | Python | Runtime Error | print(*sorted(map(int, input().spilt()))[::-1])
| print(*sorted(map(int, input().split()))[::-1])
| replace | 0 | 1 | 0 | 1 | AttributeError: 'str' object has no attribute 'spilt'. Did you mean: 'split'? | Traceback (most recent call last):
File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p00018/Python/s371735785.py", line 1, in <module>
print(*sorted(map(int, input().spilt()))[::-1])
AttributeError: 'str' object has no attribute 'spilt'. Did you mean: 'split'?
|
p00019 | C++ | Time Limit Exceeded | #include "bits/stdc++.h"
#include <unordered_map>
#include <unordered_set>
#pragma warning(disable : 4996)
using namespace std;
using ld = long double;
template <class t> using table = vector<vector<t>>;
const ld eps = 1e-9;
//// < "d:\d_download\visual studio
///2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual
///studio 2015\projects\programing_contest_c++\debug\b.answer"
int main() {
int N;
cin >> N;
long long int ans = 1;
while (1) {
ans *= N;
N--;
}
cout << ans << endl;
return 0;
} | #include "bits/stdc++.h"
#include <unordered_map>
#include <unordered_set>
#pragma warning(disable : 4996)
using namespace std;
using ld = long double;
template <class t> using table = vector<vector<t>>;
const ld eps = 1e-9;
//// < "d:\d_download\visual studio
///2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual
///studio 2015\projects\programing_contest_c++\debug\b.answer"
int main() {
int N;
cin >> N;
long long int ans = 1;
while (N) {
ans *= N;
N--;
}
cout << ans << endl;
return 0;
} | replace | 16 | 17 | 16 | 17 | TLE | |
p00019 | C++ | Time Limit Exceeded |
#include <algorithm>
#include <cctype>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
int main() {
long long int n;
long long result = 1;
cin >> n;
while (n > 1) {
result *= n;
}
cout << result << endl;
// while(1);
return 0;
}
|
#include <algorithm>
#include <cctype>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
int main() {
long long int n;
long long result = 1;
cin >> n;
while (n > 1) {
result *= n;
n--;
}
cout << result << endl;
// while(1);
return 0;
}
| insert | 23 | 23 | 23 | 24 | TLE | |
p00020 | C++ | Runtime Error | #include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int main() {
char cent[100];
for (int i = 0;; i++) {
if (scanf("%c", ¢[i]) == EOF) {
break;
}
if (cent[i] >= 97 && cent[i] <= 122) {
cent[i] -= 32;
}
}
cout << cent;
return 0;
} | #include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int main() {
char cent[10000];
for (int i = 0;; i++) {
if (scanf("%c", ¢[i]) == EOF) {
break;
}
if (cent[i] >= 97 && cent[i] <= 122) {
cent[i] -= 32;
}
}
cout << cent;
return 0;
} | replace | 5 | 6 | 5 | 6 | 0 | |
p00020 | C++ | Time Limit Exceeded | #include <stdio.h>
int main(void) {
char a;
while ((a = getchar()) != '\0') {
if ('a' <= a && a <= 'z')
a -= 32;
putchar(a);
}
return 0;
} | #include <stdio.h>
int main(void) {
char a;
while ((a = getchar()) != EOF) {
if ('a' <= a && a <= 'z')
a -= 32;
putchar(a);
}
return 0;
} | replace | 5 | 6 | 5 | 6 | TLE | |
p00020 | C++ | Time Limit Exceeded | #include <iostream>
#include <stdio.h>
using namespace std;
int main() {
char ch;
while (1) {
scanf("%c", &ch);
if (ch == '\n') {
cout << endl;
}
ch = toupper(ch);
cout << ch;
}
return 0;
} | #include <iostream>
#include <stdio.h>
using namespace std;
int main() {
char ch;
while (1) {
scanf("%c", &ch);
if (ch == '\n') {
cout << endl;
break;
}
ch = toupper(ch);
cout << ch;
}
return 0;
} | insert | 15 | 15 | 15 | 16 | TLE | |
p00020 | C++ | Runtime Error | #include <algorithm>
#include <cstdio>
#include <cstring>
#include <functional>
using namespace std;
int main() {
char str[100];
scanf("%[a-z .]", str);
for (int i = 0; str[i]; i++) {
if ('a' <= str[i] && str[i] <= 'z')
str[i] += 'A' - 'a';
}
printf("%s\n", str);
return 0;
} | #include <algorithm>
#include <cstdio>
#include <cstring>
#include <functional>
using namespace std;
int main() {
static char str[100000];
scanf("%[a-z .]", str);
for (int i = 0; str[i]; i++) {
if ('a' <= str[i] && str[i] <= 'z')
str[i] += 'A' - 'a';
}
printf("%s\n", str);
return 0;
} | replace | 7 | 8 | 7 | 8 | 0 | |
p00020 | C++ | Time Limit Exceeded | #include <stdio.h>
int main() {
char c;
while (scanf("%c", &c)) {
if (c == ' ')
printf(" ");
else if (c == '.')
printf(".");
else if (c == '\n')
printf("\n");
else
printf("%c", c - 32);
}
} | #include <stdio.h>
int main() {
for (char c; scanf("%c", &c) != -1;)
putchar((c > 96) ? (c - 32) : c);
} | replace | 2 | 13 | 2 | 4 | TLE | |
p00022 | C++ | Time Limit Exceeded | #include <iostream>
int maxSum(int *a, int n) {
int sum, max = a[0];
for (int num = 1; num <= n; ++num) {
for (int i = 0; i < n - num + 1; ++i) {
sum = 0;
for (int j = 0; j < num; ++j) {
sum += a[i + j];
}
if (sum > max) {
max = sum;
}
}
}
return max;
}
int main() {
int n;
int *a;
for (;;) {
std::cin >> n;
if (n <= 0) {
break;
}
a = new int[n];
for (int i = 0; i < n; ++i) {
std::cin >> a[i];
}
std::cout << maxSum(a, n) << '\n';
delete[] a;
}
return 0;
} | #include <iostream>
int maxSum(int *a, int n) {
int sum, max = a[0];
for (int i = 0; i < n; ++i) {
sum = 0;
for (int j = i; j < n; ++j) {
sum += a[j];
if (sum > max) {
max = sum;
}
}
}
return max;
}
int main() {
int n;
int *a;
for (;;) {
std::cin >> n;
if (n <= 0) {
break;
}
a = new int[n];
for (int i = 0; i < n; ++i) {
std::cin >> a[i];
}
std::cout << maxSum(a, n) << '\n';
delete[] a;
}
return 0;
} | replace | 4 | 10 | 4 | 8 | TLE | |
p00022 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (i = 0; i < n; ++i)
#define each(itr, c) \
for (__typeof(c.begin()) itr = c.begin(); itr != c.end(); itr++)
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
int main(int argc, char const *argv[]) {
int i, j;
while (1) {
int n;
cin >> n;
if (n == 0)
break;
std::vector<long> a(n + 1);
rep(i, n) scanf(" %ld", &a[i + 1]);
std::vector<long> sum(n); // a[1]~a[i]??????
sum[0] = 0;
for (i = 1; i <= n; ++i)
sum[i] = sum[i - 1] + a[i];
long ans = -5000 * 100000 - 1;
for (i = 1; i <= n; ++i) {
for (j = i; j <= n; ++j) {
ans = max(ans, sum[j] - sum[i - 1]);
}
}
std::cout << ans << std::endl;
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (i = 0; i < n; ++i)
#define each(itr, c) \
for (__typeof(c.begin()) itr = c.begin(); itr != c.end(); itr++)
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
int main(int argc, char const *argv[]) {
int i, j;
while (1) {
int n;
cin >> n;
if (n == 0)
break;
std::vector<long> a(n + 1);
rep(i, n) scanf(" %ld", &a[i + 1]);
std::vector<long> sum(n + 1); // a[1]~a[i]??????
sum[0] = 0;
for (i = 1; i <= n; ++i)
sum[i] = sum[i - 1] + a[i];
long ans = -5000 * 100000 - 1;
for (i = 1; i <= n; ++i) {
for (j = i; j <= n; ++j) {
ans = max(ans, sum[j] - sum[i - 1]);
}
}
std::cout << ans << std::endl;
}
return 0;
} | replace | 24 | 25 | 24 | 25 | -6 | Fatal glibc error: malloc assertion failure in sysmalloc: (old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)
|
p00022 | C++ | Runtime Error | #include <stdio.h>
int main() {
int n, a[5000];
while (scanf("%d", &n) != EOF) {
int max = -10001;
scanf("%d", &n);
if (n == 0)
break;
for (int i = 0; i < n; i++)
scanf("%d", &a[i]);
for (int i = 0; i < n; i++) {
int sum = 0;
for (int j = i; j < n; j++) {
sum += a[j];
if (max < sum)
max = sum;
}
}
printf("%d\n", max);
}
return 0;
} | #include <stdio.h>
int main() {
int n, a[5000];
while (1) {
int max = -100001;
scanf("%d", &n);
if (n == 0)
break;
for (int i = 0; i < n; i++)
scanf("%d", &a[i]);
for (int i = 0; i < n; i++) {
int sum = 0;
for (int j = i; j < n; j++) {
sum += a[j];
if (max < sum)
max = sum;
}
}
printf("%d\n", max);
}
return 0;
} | replace | 3 | 5 | 3 | 5 | 0 | |
p00022 | C++ | Runtime Error | #include <climits>
#include <iostream>
using namespace std;
template <typename Type> long long Maximum_Sum_Sequence(Type N[], int size) {
long long max = LLONG_MIN;
for (int i = 0; i < size; i++) {
long long sum = 0;
for (int j = i; j < size; j++) {
sum += N[j];
if (sum > max) {
max = sum;
}
}
}
return max;
}
int main() {
const int DATASETS = 20000;
int n[DATASETS], a[DATASETS][5000], c = 0;
while (true) {
cin >> n[c];
if (n[c] == 0) {
break;
}
for (int i = 0; i < n[c]; i++) {
cin >> a[c][i];
}
c++;
}
for (int i = 0; i < c; i++) {
cout << Maximum_Sum_Sequence(a[i], n[i]) << endl;
}
return 0;
} | #include <climits>
#include <iostream>
using namespace std;
template <typename Type> long long Maximum_Sum_Sequence(Type N[], int size) {
long long max = LLONG_MIN;
for (int i = 0; i < size; i++) {
long long sum = 0;
for (int j = i; j < size; j++) {
sum += N[j];
if (sum > max) {
max = sum;
}
}
}
return max;
}
int main() {
const int DATASETS = 100;
int n[DATASETS], a[DATASETS][5000], c = 0;
while (true) {
cin >> n[c];
if (n[c] == 0) {
break;
}
for (int i = 0; i < n[c]; i++) {
cin >> a[c][i];
}
c++;
}
for (int i = 0; i < c; i++) {
cout << Maximum_Sum_Sequence(a[i], n[i]) << endl;
}
return 0;
} | replace | 24 | 25 | 24 | 25 | -11 | |
p00022 | C++ | Runtime Error | #include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef vector<pair<int, int>> vpii;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define foreach(itr, c) \
for (__typeof(c.begin()) itr = c.begin(); itr != c.end(); itr++)
#define dbg(x) cout << #x "=" << (x) << endl
#define mp(a, b) make_pair((a), (b))
#define pb(a) push_back(a)
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second
using namespace std;
int sum[2500];
int main() {
int N;
int ans = 0;
while (cin >> N && N) {
int index = 0;
ans = INT_MIN;
FOR(i, 1, N + 1) {
cin >> sum[i];
sum[i] += sum[i - 1];
}
FOR(i, 1, N + 1) {
FOR(j, i, N + 1) { ans = max(ans, sum[j] - sum[i - 1]); }
}
cout << ans << endl;
}
} | #include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef vector<pair<int, int>> vpii;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define foreach(itr, c) \
for (__typeof(c.begin()) itr = c.begin(); itr != c.end(); itr++)
#define dbg(x) cout << #x "=" << (x) << endl
#define mp(a, b) make_pair((a), (b))
#define pb(a) push_back(a)
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second
using namespace std;
int sum[3000];
int main() {
int N;
int ans = 0;
while (cin >> N && N) {
int index = 0;
ans = INT_MIN;
FOR(i, 1, N + 1) {
cin >> sum[i];
sum[i] += sum[i - 1];
}
FOR(i, 1, N + 1) {
FOR(j, i, N + 1) { ans = max(ans, sum[j] - sum[i - 1]); }
}
cout << ans << endl;
}
} | replace | 41 | 42 | 41 | 42 | 0 | |
p00022 | C++ | Runtime Error | #include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef vector<pair<int, int>> vpii;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define foreach(itr, c) \
for (__typeof(c.begin()) itr = c.begin(); itr != c.end(); itr++)
#define dbg(x) cout << #x "=" << (x) << endl
#define mp(a, b) make_pair((a), (b))
#define pb(a) push_back(a)
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second
using namespace std;
int sum[2000];
int main() {
int N;
int ans = 0;
while (cin >> N && N) {
int index = 0;
ans = INT_MIN;
FOR(i, 1, N + 1) {
cin >> sum[i];
sum[i] += sum[i - 1];
}
FOR(i, 1, N + 1) {
FOR(j, i, N + 1) { ans = max(ans, sum[j] - sum[i - 1]); }
}
cout << ans << endl;
}
} | #include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef vector<pair<int, int>> vpii;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define foreach(itr, c) \
for (__typeof(c.begin()) itr = c.begin(); itr != c.end(); itr++)
#define dbg(x) cout << #x "=" << (x) << endl
#define mp(a, b) make_pair((a), (b))
#define pb(a) push_back(a)
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second
using namespace std;
int sum[3000];
int main() {
int N;
int ans = 0;
while (cin >> N && N) {
int index = 0;
ans = INT_MIN;
FOR(i, 1, N + 1) {
cin >> sum[i];
sum[i] += sum[i - 1];
}
FOR(i, 1, N + 1) {
FOR(j, i, N + 1) { ans = max(ans, sum[j] - sum[i - 1]); }
}
cout << ans << endl;
}
} | replace | 41 | 42 | 41 | 42 | 0 | |
p00022 | C++ | Time Limit Exceeded | #include <iostream>
#include <vector>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
// ?¨±?????????????????
#define EPS (1e-10)
int main() {
int n;
while (cin >> n && n != 0) {
vector<int> a(n);
REP(i, n) cin >> a[i];
int ret = 0;
REP(i, a.size()) {
FOR(j, i, a.size()) {
int sum = 0;
FOR(k, i, j + 1) sum += a[k];
ret = max(ret, sum);
}
}
cout << ret << endl;
}
return 0;
} | #include <iostream>
#include <vector>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
// ?¨±?????????????????
#define EPS (1e-10)
int main() {
int n;
while (cin >> n && n != 0) {
vector<int> a(n);
REP(i, n) cin >> a[i];
vector<int> sum(n);
sum[0] = a[0];
FOR(i, 1, n) sum[i] = sum[i - 1] + a[i];
int ret = sum[0];
FOR(i, -1, n)
FOR(j, i + 1, n) ret =
i > -1 ? max(ret, sum[j] - sum[i]) : max(ret, sum[j]);
cout << ret << endl;
}
return 0;
} | replace | 14 | 22 | 14 | 21 | TLE | |
p00022 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define INF 1000000000
int main() {
while (1) {
int n;
cin >> n;
if (!n)
break;
vector<int> a(n);
for (int i = 1; i <= n; i++) {
cin >> a[i];
if (i > 0)
a[i] += a[i - 1];
}
a[0] = 0;
int ans = a[1];
for (int i = 0; i < n; i++) {
for (int j = i + 1; j <= n; j++) {
ans = max(ans, a[j] - a[i]);
}
}
cout << ans << endl;
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define INF 1000000000
int main() {
while (1) {
int n;
cin >> n;
if (!n)
break;
vector<int> a(n + 1);
for (int i = 1; i <= n; i++) {
cin >> a[i];
if (i > 0)
a[i] += a[i - 1];
}
a[0] = 0;
int ans = a[1];
for (int i = 0; i < n; i++) {
for (int j = i + 1; j <= n; j++) {
ans = max(ans, a[j] - a[i]);
}
}
cout << ans << endl;
}
return 0;
} | replace | 11 | 12 | 11 | 12 | 0 | |
p00022 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <stdio.h>
using namespace std;
int main(void) {
int n, a[1000];
while (1) {
cin >> n;
if (n == 0)
break;
for (int i = 1; i <= n; i++)
cin >> a[i];
int goukei = 0, led = -10000000;
for (int i = 1; i <= n; i++) {
goukei = 0;
for (int j = i; j <= n; j++) {
goukei = goukei + a[j];
led = max(goukei, led);
}
}
cout << led << endl;
}
return 0;
} | #include <algorithm>
#include <iostream>
#include <stdio.h>
using namespace std;
int main(void) {
int n, a[10000];
while (1) {
cin >> n;
if (n == 0)
break;
for (int i = 1; i <= n; i++)
cin >> a[i];
int goukei = 0, led = -10000000;
for (int i = 1; i <= n; i++) {
goukei = 0;
for (int j = i; j <= n; j++) {
goukei = goukei + a[j];
led = max(goukei, led);
}
}
cout << led << endl;
}
return 0;
} | replace | 6 | 7 | 6 | 7 | 0 | |
p00022 | C++ | Time Limit Exceeded | #include <math.h>
#include <stdio.h>
using namespace std;
int main() {
int n, maximum, sum;
while (true) {
scanf("%d", &n);
if (n == 0)
break;
int array[n];
for (int i = 0; i < n; i++)
scanf("%d", &array[i]);
maximum = -600000000;
for (int k = 0; k < n; k++) { //?§????????????????
for (int j = k; j < n; j++) { //??????????????????
sum = 0;
for (int p = k; p <= j; p++) { //??????????????????
sum += array[p];
}
maximum = (maximum >= sum) ? maximum : sum;
}
}
printf("%d\n", maximum);
}
return 0;
} | #include <math.h>
#include <stdio.h>
using namespace std;
int main() {
int n, maximum, sum;
while (true) {
scanf("%d", &n);
if (n == 0)
break;
int array[n];
for (int i = 0; i < n; i++)
scanf("%d", &array[i]);
maximum = -600000000;
for (int k = 0; k < n; k++) { //?§????????????????
sum = 0;
for (int p = k; p <= n - 1; p++) { //??????????????????
sum += array[p];
maximum = (maximum >= sum) ? maximum : sum;
}
}
printf("%d\n", maximum);
}
return 0;
} | replace | 15 | 21 | 15 | 19 | TLE | |
p00022 | C++ | Time Limit Exceeded | #include <iostream>
#include <vector>
using namespace std;
int main() {
int n;
while (cin >> n, n) {
vector<int> vec;
for (int i = 0; i < n; i++) {
int a;
cin >> a;
vec.push_back(a);
}
int max = vec[0] + vec[1];
for (int i = 0; i < vec.size(); i++) {
for (int j = i + 1; j < vec.size(); j++) {
int add = 0;
for (int k = i; k <= j; k++) {
add += vec[k];
}
if (max < add)
max = add;
}
}
cout << max << endl;
}
} | #include <iostream>
#include <vector>
using namespace std;
int main() {
int n;
while (cin >> n, n) {
vector<int> vec;
for (int i = 0; i < n; i++) {
int a;
cin >> a;
vec.push_back(a);
}
int max = vec[0] + vec[1];
for (int i = 0; i < vec.size(); i++) {
int add = 0;
for (int j = i; j < vec.size(); j++) {
add += vec[j];
if (max < add)
max = add;
}
}
cout << max << endl;
}
} | replace | 16 | 21 | 16 | 19 | TLE | |
p00022 | C++ | Runtime Error | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define LOOP(i, x, n) for (int i = x; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define PB push_back
#define MP make_pair
#define FR first
#define SC second
#define int long long
using namespace std;
const int MOD = 1000000007;
const int INF = 9000000009;
const double eps = 1e-10;
signed main() {
int n;
while (cin >> n, n) {
vector<int> a(n);
REP(i, n) {
int x;
cin >> x;
a[i + 1] = a[i] + x;
}
int ans = -INF;
REP(i, n + 1) LOOP(j, i + 1, n + 1) ans = max(ans, a[j] - a[i]);
cout << ans << endl;
}
return 0;
}
| #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define LOOP(i, x, n) for (int i = x; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define PB push_back
#define MP make_pair
#define FR first
#define SC second
#define int long long
using namespace std;
const int MOD = 1000000007;
const int INF = 9000000009;
const double eps = 1e-10;
signed main() {
int n;
while (cin >> n, n) {
vector<int> a(n + 100);
REP(i, n) {
int x;
cin >> x;
a[i + 1] = a[i] + x;
}
int ans = -INF;
REP(i, n + 1) LOOP(j, i + 1, n + 1) ans = max(ans, a[j] - a[i]);
cout << ans << endl;
}
return 0;
}
| replace | 18 | 19 | 18 | 19 | -6 | Fatal glibc error: malloc assertion failure in sysmalloc: (old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)
|
p00022 | C++ | Runtime Error | #include <algorithm>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define REP(i, x, y) for (int i = (x); i < (y); ++i)
#define MP(a, b) make_pair((a), (b))
#define F_ first
#define S_ second
typedef long long int lli;
typedef pair<int, int> Pi;
const int INF = 100000000;
const long long int INF_ = 1000000000000000000;
int main() {
int N;
while (cin >> N && N) {
vector<int> A(N + 1);
REP(i, 1, N + 1) cin >> A[i];
vector<int> s(N);
REP(i, 1, N + 1) s[i] = s[i - 1] + A[i];
lli ans = -INF_;
REP(i, 0, N + 1)
REP(j, i + 1, N + 1) if (ans < s[j] - s[i]) ans = s[j] - s[i];
cout << ans << endl;
}
return 0;
} | #include <algorithm>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define REP(i, x, y) for (int i = (x); i < (y); ++i)
#define MP(a, b) make_pair((a), (b))
#define F_ first
#define S_ second
typedef long long int lli;
typedef pair<int, int> Pi;
const int INF = 100000000;
const long long int INF_ = 1000000000000000000;
int main() {
int N;
while (cin >> N && N) {
vector<int> A(N + 1);
REP(i, 1, N + 1) cin >> A[i];
vector<int> s(N + 1);
REP(i, 1, N + 1) s[i] = s[i - 1] + A[i];
lli ans = -INF_;
REP(i, 0, N + 1)
REP(j, i + 1, N + 1) if (ans < s[j] - s[i]) ans = s[j] - s[i];
cout << ans << endl;
}
return 0;
} | replace | 32 | 33 | 32 | 33 | 0 | |
p00022 | C++ | Time Limit Exceeded | #include <iostream>
using namespace std;
int main() {
int n, i, j, k, max, sum;
while (1) {
int max = -100000;
cin >> n;
int a[n];
if (n == 0)
break;
for (i = 0; i < n; i++) {
cin >> a[i];
}
for (i = 0; i < n; i++) {
for (j = 1; j <= n - i; j++) {
sum = 0;
for (k = i; k < j; k++) {
sum = sum + a[k];
}
if (max < sum)
max = sum;
}
}
cout << max << endl;
}
} | #include <iostream>
using namespace std;
int main() {
int n, i, j, k, max, sum;
while (1) {
int max = -100000;
cin >> n;
int a[n];
if (n == 0)
break;
for (i = 0; i < n; i++) {
cin >> a[i];
}
for (i = 0; i < n; i++) {
sum = 0;
for (j = 0; j < n - i; j++) {
sum = sum + a[i + j];
if (max < sum)
max = sum;
}
}
cout << max << endl;
}
} | replace | 15 | 20 | 15 | 18 | TLE | |
p00023 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
struct circle {
double r, x, y;
};
int main() {
int n;
while (scanf("%d", &n) == 1, n) {
for (int x = 0; x < n; ++x) {
circle a, b;
scanf("%lf %lf %lf %lf %lf %lf", &a.x, &a.y, &a.r, &b.x, &b.y, &b.r);
double d = sqrt(pow(a.x - b.x, 2) + pow(a.y - b.y, 2));
if (d > a.r + b.r) {
cout << 0 << endl;
} else if (a.r + d < b.r) {
cout << -2 << endl;
} else if (b.r + d < a.r) {
cout << 2 << endl;
} else {
cout << 1 << endl;
}
}
}
return 0;
} | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
struct circle {
double r, x, y;
};
int main() {
int n;
scanf("%d", &n);
for (int x = 0; x < n; ++x) {
circle a, b;
scanf("%lf %lf %lf %lf %lf %lf", &a.x, &a.y, &a.r, &b.x, &b.y, &b.r);
double d = sqrt(pow(a.x - b.x, 2) + pow(a.y - b.y, 2));
if (d > a.r + b.r) {
cout << 0 << endl;
} else if (a.r + d < b.r) {
cout << -2 << endl;
} else if (b.r + d < a.r) {
cout << 2 << endl;
} else {
cout << 1 << endl;
}
}
return 0;
} | replace | 23 | 37 | 23 | 36 | TLE | |
p00024 | C++ | Time Limit Exceeded | #include <stdio.h>
int main(void) {
double N;
double v;
while (scanf("%lf", &v)) {
// 1/2*v^2=g*5(N-1)
//??????????????§?????????????????¨?????????????????????
N = v * v / (10.0 * 9.8) + 1.0;
printf("%d\n", (int)(N) + 1);
}
return 0;
} | #include <stdio.h>
int main(void) {
double N;
double v;
while (scanf("%lf", &v) != EOF) {
N = v * v / (10.0 * 9.8) + 1.0;
printf("%d\n", (int)(N) + 1);
}
return 0;
} | replace | 5 | 8 | 5 | 6 | TLE | |
p00024 | C++ | Time Limit Exceeded | #include <cmath>
#include <iostream>
using namespace std;
void solve() {
double v;
while (cin >> v, v) {
int N = 2;
while (true) {
double velocity = 1.4 * sqrt(10.0 * (5 * N - 5));
if (velocity >= v) {
cout << N << endl;
break;
}
++N;
}
}
}
int main() {
solve();
return (0);
} | #include <cmath>
#include <iostream>
using namespace std;
void solve() {
double v;
while (cin >> v) {
int N = 2;
while (true) {
double velocity = 1.4 * sqrt(10.0 * (5 * N - 5));
if (velocity >= v) {
cout << N << endl;
break;
}
++N;
}
}
}
int main() {
solve();
return (0);
} | replace | 7 | 8 | 7 | 8 | TLE | |
p00024 | C++ | Time Limit Exceeded | #include <iostream>
using namespace std;
int main(void) {
int c, n;
double v, y;
while (cin >> v, v != '\0') {
y = 4.9 * ((v * v) / (9.8 * 9.8));
n = 1;
while (1) {
if (y < 5 * n - 5)
break;
n++;
}
cout << n << endl;
}
} | #include <iostream>
using namespace std;
int main(void) {
int c, n;
double v, y;
while (cin >> v) {
y = 4.9 * ((v * v) / (9.8 * 9.8));
n = 1;
while (1) {
if (y < 5 * n - 5)
break;
n++;
}
cout << n << endl;
}
} | replace | 5 | 6 | 5 | 6 | TLE | |
p00024 | C++ | Time Limit Exceeded | #include <iostream>
using namespace std;
int main() {
while (1) {
double v, t, h;
int ans;
cin >> v;
t = v / 9.8;
h = 4.9 * t * t;
for (int i = 1; i < 100000; i++) {
if (h < 5 * i - 5) {
ans = i;
break;
}
}
cout << ans << endl;
}
return 0;
} | #include <iostream>
using namespace std;
int main() {
double v, t, h;
int ans;
while (cin >> v) {
t = v / 9.8;
h = 4.9 * t * t;
for (int i = 1; i < 100000; i++) {
if (h < 5 * i - 5) {
ans = i;
break;
}
}
cout << ans << endl;
}
return 0;
} | replace | 4 | 8 | 4 | 7 | TLE | |
p00024 | C++ | Time Limit Exceeded | #include <iostream>
#include <math.h>
using namespace std;
int main() {
double a;
while (cin >> a, a) {
double t = a / 9.8;
double y = 4.9 * t * t;
int y_c = ceil(y);
int N = y_c / 5 + (y_c % 5 > 0);
cout << N + 1 << endl;
}
return 0;
} | #include <iostream>
#include <math.h>
using namespace std;
int main() {
double a;
while (cin >> a) {
double t = a / 9.8;
double y = 4.9 * t * t;
int y_c = ceil(y);
int N = y_c / 5 + (y_c % 5 > 0);
cout << N + 1 << endl;
}
return 0;
} | replace | 6 | 7 | 6 | 7 | TLE | |
p00024 | C++ | Time Limit Exceeded | #include "bits/stdc++.h"
using namespace std;
int main() {
double v;
while (cin >> v, v) {
int N = 0;
double V = 0;
do {
N++;
double h = 5 * N - 5;
V = 9.8 * pow(h / 4.9, 0.5);
} while (V < v);
cout << N << endl;
}
} | #include "bits/stdc++.h"
using namespace std;
int main() {
double v;
while (cin >> v) {
int N = 0;
double V = 0;
do {
N++;
double h = 5 * N - 5;
V = 9.8 * pow(h / 4.9, 0.5);
} while (V < v);
cout << N << endl;
}
} | replace | 4 | 5 | 4 | 5 | TLE | |
p00025 | C++ | Time Limit Exceeded | #include <cstdio>
#include <iostream>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
int main() {
int a[4], b[4];
while (1) {
rep(i, 4) cin >> a[i];
rep(i, 4) cin >> b[i];
int blow = 0, hit = 0;
rep(i, 4) {
if (a[i] == b[i])
hit++;
}
rep(i, 4) for (int j = 0; j < 4; j++) {
if (a[i] == b[j] && i != j)
blow++;
}
cout << hit << " " << blow << endl;
}
} | #include <cstdio>
#include <iostream>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
int main() {
int a[4], b[4];
while (1) {
rep(i, 4) cin >> a[i];
rep(i, 4) cin >> b[i];
if (cin.eof())
break;
int blow = 0, hit = 0;
rep(i, 4) {
if (a[i] == b[i])
hit++;
}
rep(i, 4) for (int j = 0; j < 4; j++) {
if (a[i] == b[j] && i != j)
blow++;
}
cout << hit << " " << blow << endl;
}
} | insert | 10 | 10 | 10 | 12 | TLE | |
p00025 | C++ | Time Limit Exceeded | #include <iostream>
using namespace std;
int main() {
int a[4], b[4];
while (1) {
for (int i = 0; i < 4; i++)
cin >> a[i];
for (int i = 0; i < 4; i++)
cin >> b[i];
// hit
int hit = 0;
for (int i = 0; i < 4; i++)
hit += (a[i] == b[i]);
// blow
int blow = 0;
for (int i = 0; i < 4; i++)
blow += ((a[i] == b[0]) || (a[i] == b[1]) || (a[i] == b[2]) ||
(a[i] == b[3]));
cout << hit << " " << blow - hit << endl;
}
return 0;
} | #include <iostream>
using namespace std;
int main() {
int a[4], b[4];
while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) {
// hit
int hit = 0;
for (int i = 0; i < 4; i++)
hit += (a[i] == b[i]);
// blow
int blow = 0;
for (int i = 0; i < 4; i++)
blow += ((a[i] == b[0]) || (a[i] == b[1]) || (a[i] == b[2]) ||
(a[i] == b[3]));
cout << hit << " " << blow - hit << endl;
}
return 0;
} | replace | 7 | 13 | 7 | 8 | TLE | |
p00025 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 1000000
using namespace std;
int main() {
while (1) {
vector<int> a(4);
vector<int> b(4);
rep(i, 4) cin >> a[i];
rep(i, 4) cin >> b[i];
int hit = 0, blow = 0;
rep(i, 4) {
if (a[i] == b[i])
hit++;
else {
rep(j, 4) if (a[j] == b[i]) blow++;
}
}
cout << hit << " " << blow << endl;
}
return 0;
}
| #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 1000000
using namespace std;
int main() {
vector<int> a(4);
vector<int> b(4);
while (cin >> a[0] >> a[1] >> a[2] >> a[3]) {
rep(i, 4) cin >> b[i];
int hit = 0, blow = 0;
rep(i, 4) {
if (a[i] == b[i])
hit++;
else {
rep(j, 4) if (a[j] == b[i]) blow++;
}
}
cout << hit << " " << blow << endl;
}
return 0;
}
| replace | 5 | 9 | 5 | 8 | TLE | |
p00025 | C++ | Time Limit Exceeded | #include <iostream>
#include <vector>
using namespace std;
int main() {
while (true) {
vector<int> a(4);
for (int i = 0; i < 4; i++)
cin >> a[i];
int hit = 0, blow = 0;
for (int i = 0; i < 4; i++) {
int b;
cin >> b;
for (int j = 0; j < 4; j++) {
if (a[j] == b) {
if (i == j)
hit++;
else
blow++;
}
}
}
cout << hit << " " << blow << endl;
}
return 0;
} | #include <iostream>
#include <vector>
using namespace std;
int main() {
vector<int> a(4);
while (cin >> a[0] >> a[1] >> a[2] >> a[3]) {
int hit = 0, blow = 0;
for (int i = 0; i < 4; i++) {
int b;
cin >> b;
for (int j = 0; j < 4; j++) {
if (a[j] == b) {
if (i == j)
hit++;
else
blow++;
}
}
}
cout << hit << " " << blow << endl;
}
return 0;
} | replace | 4 | 8 | 4 | 6 | TLE | |
p00025 | C++ | Time Limit Exceeded | #include <iostream>
using namespace std;
int main() {
int a[4], b[4];
int hit, blow;
while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) {
hit = blow = 0;
for (int i = 0; i < 4; i++) {
if (a[i] == b[i]) {
hit++;
}
for (int j = 0; i < 4; j++) {
if (a[i] == b[j]) {
blow++;
}
}
}
blow -= hit;
cout << hit << " " << blow << endl;
}
return 0;
} | #include <iostream>
using namespace std;
int main() {
int a[4], b[4];
int hit, blow;
while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) {
hit = blow = 0;
for (int i = 0; i < 4; i++) {
if (a[i] == b[i]) {
hit++;
}
for (int j = 0; j < 4; j++) {
if (a[i] == b[j]) {
blow++;
}
}
}
blow -= hit;
cout << hit << " " << blow << endl;
}
return 0;
} | replace | 12 | 13 | 12 | 13 | TLE | |
p00025 | C++ | Time Limit Exceeded | #include <iostream>
int main(int argc, char **argv) {
while (true) {
int a[4];
int b[4];
std::cin >> a[0] >> a[1] >> a[2] >> a[3];
std::cin >> b[0] >> b[1] >> b[2] >> b[3];
int hit = 0, blow = 0;
for (int i = 0; i < 4; i++) {
if (a[i] == b[i]) {
hit++;
} else {
for (int j = 0; j < 4; j++) {
if (a[i] == b[j]) {
blow++;
}
}
}
}
std::cout << hit << " " << blow << std::endl;
}
return 0;
} | #include <iostream>
int main(int argc, char **argv) {
int a[4];
int b[4];
while (std::cin >> a[0] >> a[1] >> a[2] >> a[3]) {
std::cin >> b[0] >> b[1] >> b[2] >> b[3];
int hit = 0, blow = 0;
for (int i = 0; i < 4; i++) {
if (a[i] == b[i]) {
hit++;
} else {
for (int j = 0; j < 4; j++) {
if (a[i] == b[j]) {
blow++;
}
}
}
}
std::cout << hit << " " << blow << std::endl;
}
return 0;
} | replace | 3 | 7 | 3 | 6 | TLE | |
p00025 | C++ | Time Limit Exceeded | #include <array>
#include <iostream>
/*This function is a counter for "hit" and "blow".*/
void counter(int *n_a, int *n_b, int *hit, int *blow) {
*hit = 0;
*blow = 0;
for (int i = 0; i < 4; ++i) {
for (int j = 0; j < 4; ++j) {
// the case of factor and place are same
if (n_a[i] == n_b[j] && i == j) {
*hit = *hit + 1;
}
// the case of only factor is same
else if (n_a[i] == n_b[j]) {
*blow = *blow + 1;
}
}
}
}
int main() {
std::array<int, 4> n_a; // selection of "A"
std::array<int, 4> n_b; // selection of "B"
while (true) {
std::cin >> n_a[0] >> n_a[1] >> n_a[2] >> n_a[3];
std::cin >> n_b[0] >> n_b[1] >> n_b[2] >> n_b[3];
int hit = 0; // factor and place are same
int blow = 0; // only factor is same
counter(n_a.data(), n_b.data(), &hit, &blow);
std::cout << hit << " " << blow << std::endl;
}
return 0;
} | #include <array>
#include <iostream>
/*This function is a counter for "hit" and "blow".*/
void counter(int *n_a, int *n_b, int *hit, int *blow) {
*hit = 0;
*blow = 0;
for (int i = 0; i < 4; ++i) {
for (int j = 0; j < 4; ++j) {
// the case of factor and place are same
if (n_a[i] == n_b[j] && i == j) {
*hit = *hit + 1;
}
// the case of only factor is same
else if (n_a[i] == n_b[j]) {
*blow = *blow + 1;
}
}
}
}
int main() {
std::array<int, 4> n_a; // selection of "A"
std::array<int, 4> n_b; // selection of "B"
while (std::cin >> n_a[0] >> n_a[1] >> n_a[2] >> n_a[3] &&
std::cin >> n_b[0] >> n_b[1] >> n_b[2] >> n_b[3]) {
// std::cin >> n_a[0] >> n_a[1] >> n_a[2] >> n_a[3];
// std::cin >> n_b[0] >> n_b[1] >> n_b[2] >> n_b[3];
int hit = 0; // factor and place are same
int blow = 0; // only factor is same
counter(n_a.data(), n_b.data(), &hit, &blow);
std::cout << hit << " " << blow << std::endl;
}
return 0;
} | replace | 28 | 31 | 28 | 32 | TLE | |
p00025 | C++ | Time Limit Exceeded | #include <cstdio>
#include <iostream>
using namespace std;
int main() {
int a[4], b[4];
while (scanf("%d %d %d %d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &b[0],
&b[1], &b[2], &b[3])) {
int hit = 0;
int blow = 0;
for (int i = 0; i < 4; i++)
for (int j = 0; j < 4; j++)
if (a[i] == b[j])
if (i == j)
hit++;
else
blow++;
printf("%d %d\n", hit, blow);
}
return 0;
} | #include <cstdio>
#include <iostream>
using namespace std;
int main() {
int a[4], b[4];
while (scanf("%d %d %d %d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &b[0],
&b[1], &b[2], &b[3]) != EOF) {
int hit = 0;
int blow = 0;
for (int i = 0; i < 4; i++)
for (int j = 0; j < 4; j++)
if (a[i] == b[j])
if (i == j)
hit++;
else
blow++;
printf("%d %d\n", hit, blow);
}
return 0;
} | replace | 8 | 9 | 8 | 9 | TLE | |
p00025 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
int main() {
for (;;) {
vector<int> a(4), b(4);
for (int i = 0; i < 4; i++) {
cin >> a.at(i);
}
for (int i = 0; i < 4; i++) {
cin >> b.at(i);
}
int hit = 0, blow = 0;
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
if (a.at(i) == b.at(j)) {
if (i == j) {
hit++;
} else {
blow++;
}
}
}
}
cout << hit << " " << blow << endl;
}
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
vector<int> a(4), b(4);
while (cin >> a.at(0) >> a.at(1) >> a.at(2) >> a.at(3) >> b.at(0) >>
b.at(1) >> b.at(2) >> b.at(3)) {
int hit = 0, blow = 0;
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
if (a.at(i) == b.at(j)) {
if (i == j) {
hit++;
} else {
blow++;
}
}
}
}
cout << hit << " " << blow << endl;
}
}
| replace | 4 | 12 | 4 | 8 | TLE | |
p00026 | C++ | Runtime Error | #include <iostream>
#include <string>
using namespace std;
int main() {
int area[10][10] = {0};
int x, nx, ny, y, size;
int count = 0;
int max = 0;
char ch1, ch2;
while (cin >> x >> ch1 >> y >> ch2 >> size) {
nx = x + 2;
ny = y + 2;
switch (size) {
case 3:
area[nx - 2][ny]++;
area[nx + 2][ny]++;
area[nx][ny - 2]++;
area[nx][ny + 2]++;
case 2:
area[nx - 1][ny - 1]++;
area[nx + 1][ny - 1]++;
area[nx - 1][ny + 1]++;
area[nx + 1][ny + 1]++;
case 1:
area[nx - 1][ny]++;
area[nx + 1][ny]++;
area[nx][ny - 1]++;
area[nx][ny + 1]++;
}
area[nx][ny]++;
}
for (int i = 2; i < 12; i++) {
for (int j = 2; j < 12; j++) {
if (area[i][j] == 0) {
count++;
}
if (max < area[i][j]) {
max = area[i][j];
}
}
}
cout << count << endl;
cout << max << endl;
return 0;
} | #include <iostream>
#include <string>
using namespace std;
int main() {
int area[14][14] = {0};
int x, nx, ny, y, size;
int count = 0;
int max = 0;
char ch1, ch2;
while (cin >> x >> ch1 >> y >> ch2 >> size) {
nx = x + 2;
ny = y + 2;
switch (size) {
case 3:
area[nx - 2][ny]++;
area[nx + 2][ny]++;
area[nx][ny - 2]++;
area[nx][ny + 2]++;
case 2:
area[nx - 1][ny - 1]++;
area[nx + 1][ny - 1]++;
area[nx - 1][ny + 1]++;
area[nx + 1][ny + 1]++;
case 1:
area[nx - 1][ny]++;
area[nx + 1][ny]++;
area[nx][ny - 1]++;
area[nx][ny + 1]++;
}
area[nx][ny]++;
}
for (int i = 2; i < 12; i++) {
for (int j = 2; j < 12; j++) {
if (area[i][j] == 0) {
count++;
}
if (max < area[i][j]) {
max = area[i][j];
}
}
}
cout << count << endl;
cout << max << endl;
return 0;
} | replace | 5 | 6 | 5 | 6 | 0 | |
p00026 | C++ | Time Limit Exceeded | #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
int main() {
li dx[13] = {0, -1, 1, 0, 0, 1, 1, -1, -1, 2, -2, 0, 0};
li dy[13] = {0, 0, 0, -1, 1, 1, -1, 1, -1, 0, 0, 2, -2};
li lim[3] = {5, 9, 13};
li kami[10][10];
rep(i, 10) rep(j, 10) kami[i][j] = 0;
int x, y, s;
while (scanf("%d,%d,%d", &x, &y, &s)) {
rep(i, lim[s - 1]) {
li nx = x + dx[i];
li ny = y + dy[i];
if (min(nx, ny) >= 0 && max(nx, ny) < 10)
kami[nx][ny]++;
}
}
li siro = 0;
li ma = 0;
rep(i, 10) {
rep(j, 10) {
ma = max(ma, kami[i][j]);
if (kami[i][j] == 0)
siro++;
}
}
cout << siro << endl << ma << 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
int main() {
li dx[13] = {0, -1, 1, 0, 0, 1, 1, -1, -1, 2, -2, 0, 0};
li dy[13] = {0, 0, 0, -1, 1, 1, -1, 1, -1, 0, 0, 2, -2};
li lim[3] = {5, 9, 13};
li kami[10][10];
rep(i, 10) rep(j, 10) kami[i][j] = 0;
int x, y, s;
while (~scanf("%d,%d,%d", &x, &y, &s)) {
rep(i, lim[s - 1]) {
li nx = x + dx[i];
li ny = y + dy[i];
if (min(nx, ny) >= 0 && max(nx, ny) < 10)
kami[nx][ny]++;
}
}
li siro = 0;
li ma = 0;
rep(i, 10) {
rep(j, 10) {
ma = max(ma, kami[i][j]);
if (kami[i][j] == 0)
siro++;
}
}
cout << siro << endl << ma << endl;
return 0;
} | replace | 46 | 47 | 46 | 47 | TLE | |
p00026 | C++ | Time Limit Exceeded | #include <iostream>
#include <stdio.h>
using namespace std;
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 field[10][10] = {0};
int x, y, size;
while (scanf("%d,%d,%d", &x, &y, &size)) {
++field[x][y];
int n = 4 * size;
for (int i = 0; i < n; ++i) {
if ((0 <= x + dx[i] && x + dx[i] < 10) &&
(0 <= y + dy[i] && y + dy[i] < 10)) {
++field[x + dx[i]][y + dy[i]];
}
}
}
int count = 0;
int max = 0;
for (int i = 0; i < 10; ++i) {
for (int j = 0; j < 10; ++j) {
if (field[i][j] >= 1) {
++count;
}
if (field[i][j] > max) {
max = field[i][j];
}
}
}
cout << 100 - count << endl;
cout << max << endl;
}
int main() {
solve();
return (0);
} | #include <iostream>
#include <stdio.h>
using namespace std;
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 field[10][10] = {0};
int x, y, size;
while (scanf("%d,%d,%d", &x, &y, &size) != EOF) {
++field[x][y];
int n = 4 * size;
for (int i = 0; i < n; ++i) {
if ((0 <= x + dx[i] && x + dx[i] < 10) &&
(0 <= y + dy[i] && y + dy[i] < 10)) {
++field[x + dx[i]][y + dy[i]];
}
}
}
int count = 0;
int max = 0;
for (int i = 0; i < 10; ++i) {
for (int j = 0; j < 10; ++j) {
if (field[i][j] >= 1) {
++count;
}
if (field[i][j] > max) {
max = field[i][j];
}
}
}
cout << 100 - count << endl;
cout << max << endl;
}
int main() {
solve();
return (0);
} | replace | 9 | 10 | 9 | 10 | TLE | |
p00026 | C++ | Time Limit Exceeded | #include <cstdio>
#include <iostream>
int paper[10][10] = {};
void drop(int x, int y) {
if (x >= 0 && y >= 0 && x <= 9 && y <= 9) {
++paper[x][y];
}
}
void ink(int x, int y, int s) {
switch (s) {
case 3:
drop(x + 2, y);
drop(x - 2, y);
drop(x, y + 2);
drop(x, y - 2);
case 2:
drop(x + 1, y + 1);
drop(x - 1, y + 1);
drop(x - 1, y - 1);
drop(x + 1, y - 1);
case 1:
drop(x, y);
drop(x + 1, y);
drop(x - 1, y);
drop(x, y + 1);
drop(x, y - 1);
}
}
int main() {
int x, y, s;
// drop(9,9);
/*for(int i=0;i<10;i++){
for(int j=0;j<10;j++){
std::cout << paper[i][j] << std::endl;
}
}*/
while (std::scanf(" %d,%d,%d", &x, &y, &s)) {
// std::cout << x << y << s;
ink(x, y, s);
}
int spase = 0, max = 0;
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) {
if (paper[i][j] == 0) {
++spase;
}
if (paper[i][j] > max) {
max = paper[i][j];
}
}
}
std::cout << spase << std::endl;
std::cout << max << std::endl;
} | #include <cstdio>
#include <iostream>
int paper[10][10] = {};
void drop(int x, int y) {
if (x >= 0 && y >= 0 && x <= 9 && y <= 9) {
++paper[x][y];
}
}
void ink(int x, int y, int s) {
switch (s) {
case 3:
drop(x + 2, y);
drop(x - 2, y);
drop(x, y + 2);
drop(x, y - 2);
case 2:
drop(x + 1, y + 1);
drop(x - 1, y + 1);
drop(x - 1, y - 1);
drop(x + 1, y - 1);
case 1:
drop(x, y);
drop(x + 1, y);
drop(x - 1, y);
drop(x, y + 1);
drop(x, y - 1);
}
}
int main() {
int x, y, s;
// drop(9,9);
/*for(int i=0;i<10;i++){
for(int j=0;j<10;j++){
std::cout << paper[i][j] << std::endl;
}
}*/
while (std::scanf(" %d,%d,%d", &x, &y, &s) + 1) {
// std::cout << x << y << s;
ink(x, y, s);
}
int spase = 0, max = 0;
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) {
if (paper[i][j] == 0) {
++spase;
}
if (paper[i][j] > max) {
max = paper[i][j];
}
}
}
std::cout << spase << std::endl;
std::cout << max << std::endl;
} | replace | 43 | 44 | 43 | 44 | TLE | |
p00026 | C++ | Time Limit Exceeded | #include <cstring>
#include <iostream>
using namespace std;
int small_x[4] = {-1, 0, 0, 1};
int small_y[4] = {0, -1, 1, 0};
int medium_x[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
int medium_y[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
int large_x[12] = {-2, -1, -1, -1, 0, 0, 0, 0, 1, 1, 1, 2};
int large_y[12] = {0, -1, 0, 1, -2, -1, 1, 2, -1, 0, 1, 0};
void solve() {
int Field[14][14];
memset(Field, 0, sizeof(Field));
int a, b, c;
while (scanf("%d,%d,%d", &a, &b, &c)) {
++Field[b + 2][a + 2];
if (c == 1) {
for (int i = 0; i < 4; ++i) {
++Field[b + 2 + small_y[i]][a + 2 + small_x[i]];
}
} else if (c == 2) {
for (int i = 0; i < 8; ++i) {
++Field[b + 2 + medium_y[i]][a + 2 + medium_x[i]];
}
} else if (c == 3) {
for (int i = 0; i < 12; ++i) {
++Field[b + 2 + large_y[i]][a + 2 + large_x[i]];
}
}
}
int count = 0;
int Max = 0;
for (int i = 2; i < 12; ++i) {
for (int j = 2; j < 12; ++j) {
if (Field[i][j] == 0) {
++count;
}
if (Max < Field[i][j]) {
Max = Field[i][j];
}
}
}
cout << count << endl;
cout << Max << endl;
}
int main() {
solve();
return (0);
} | #include <cstring>
#include <iostream>
using namespace std;
int small_x[4] = {-1, 0, 0, 1};
int small_y[4] = {0, -1, 1, 0};
int medium_x[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
int medium_y[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
int large_x[12] = {-2, -1, -1, -1, 0, 0, 0, 0, 1, 1, 1, 2};
int large_y[12] = {0, -1, 0, 1, -2, -1, 1, 2, -1, 0, 1, 0};
void solve() {
int Field[14][14];
memset(Field, 0, sizeof(Field));
int a, b, c;
while (~scanf("%d,%d,%d", &a, &b, &c)) {
++Field[b + 2][a + 2];
if (c == 1) {
for (int i = 0; i < 4; ++i) {
++Field[b + 2 + small_y[i]][a + 2 + small_x[i]];
}
} else if (c == 2) {
for (int i = 0; i < 8; ++i) {
++Field[b + 2 + medium_y[i]][a + 2 + medium_x[i]];
}
} else if (c == 3) {
for (int i = 0; i < 12; ++i) {
++Field[b + 2 + large_y[i]][a + 2 + large_x[i]];
}
}
}
int count = 0;
int Max = 0;
for (int i = 2; i < 12; ++i) {
for (int j = 2; j < 12; ++j) {
if (Field[i][j] == 0) {
++count;
}
if (Max < Field[i][j]) {
Max = Field[i][j];
}
}
}
cout << count << endl;
cout << Max << endl;
}
int main() {
solve();
return (0);
} | replace | 18 | 19 | 18 | 19 | TLE | |
p00026 | C++ | Time Limit Exceeded | #include <iostream>
#include <stdio.h>
using namespace std;
int m[10][10];
void small(int x, int y, int r) {
if (y - r >= 0)
m[x][y - r]++;
if (x - r >= 0)
m[x - r][y]++;
if (x + r <= 9)
m[x + r][y]++;
if (y + r <= 9)
m[x][y + r]++;
m[x][y]++;
}
void middle(int x, int y) {
for (int i = -1; i < 2; i++)
for (int j = -1; j < 2; j++)
if (x + i >= 0 && x + i <= 9 && y + j >= 0 && y + j <= 9)
m[x + i][y + j]++;
}
void large(int x, int y) {
middle(x, y);
small(x, y, 2);
m[x][y]--;
}
int main() {
int x, y, n, i, j, h, k;
while (scanf("%d,%d,%d", &x, &y, &n)) {
if (n == 1)
small(x, y, 1);
if (n == 2)
middle(x, y);
if (n == 3)
large(x, y);
}
n = 0;
h = 0;
k = 0;
for (i = 0; i < 10; i++)
for (j = 0; j < 10; j++) {
if (m[i][j] == 0)
k++;
else
h = h < m[i][j] ? m[i][j] : h;
}
cout << k << endl << h << endl;
return 0;
} | #include <iostream>
#include <stdio.h>
using namespace std;
int m[10][10];
void small(int x, int y, int r) {
if (y - r >= 0)
m[x][y - r]++;
if (x - r >= 0)
m[x - r][y]++;
if (x + r <= 9)
m[x + r][y]++;
if (y + r <= 9)
m[x][y + r]++;
m[x][y]++;
}
void middle(int x, int y) {
for (int i = -1; i < 2; i++)
for (int j = -1; j < 2; j++)
if (x + i >= 0 && x + i <= 9 && y + j >= 0 && y + j <= 9)
m[x + i][y + j]++;
}
void large(int x, int y) {
middle(x, y);
small(x, y, 2);
m[x][y]--;
}
int main() {
int x, y, n, i, j, h, k;
while (scanf("%d,%d,%d", &x, &y, &n) != EOF) {
if (n == 1)
small(x, y, 1);
if (n == 2)
middle(x, y);
if (n == 3)
large(x, y);
}
n = 0;
h = 0;
k = 0;
for (i = 0; i < 10; i++)
for (j = 0; j < 10; j++) {
if (m[i][j] == 0)
k++;
else
h = h < m[i][j] ? m[i][j] : h;
}
cout << k << endl << h << endl;
return 0;
} | replace | 29 | 30 | 29 | 30 | TLE | |
p00026 | C++ | Runtime Error | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
const double eps = 1e-10;
int main() {
int x, y, s, c[14][14] = {0};
while (scanf("%d,%d,%d", &x, &y, &s)) {
x += 2;
y += 2;
c[y][x]++;
c[y + 1][x]++;
c[y - 1][x]++;
c[y][x + 1]++;
c[y][x - 1]++;
if (s >= 2) {
c[y - 1][x - 1]++;
c[y - 1][x + 1]++;
c[y + 1][x - 1]++;
c[y + 1][x + 1]++;
}
if (s == 3) {
c[y - 2][x]++;
c[y + 2][x]++;
c[y][x - 2]++;
c[y][x + 2]++;
}
}
int w = 0, d = 0;
for (int i = 2; i < 12; i++) {
for (int j = 2; j < 12; j++) {
if (c[i][j] == 0)
w++;
d = max(d, c[i][j]);
}
}
cout << w << endl << d << endl;
return 0;
} | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
const double eps = 1e-10;
int main() {
int x, y, s, c[14][14] = {0};
char dummy;
while (cin >> x >> dummy >> y >> dummy >> s) {
x += 2;
y += 2;
c[y][x]++;
c[y + 1][x]++;
c[y - 1][x]++;
c[y][x + 1]++;
c[y][x - 1]++;
if (s >= 2) {
c[y - 1][x - 1]++;
c[y - 1][x + 1]++;
c[y + 1][x - 1]++;
c[y + 1][x + 1]++;
}
if (s == 3) {
c[y - 2][x]++;
c[y + 2][x]++;
c[y][x - 2]++;
c[y][x + 2]++;
}
}
int w = 0, d = 0;
for (int i = 2; i < 12; i++) {
for (int j = 2; j < 12; j++) {
if (c[i][j] == 0)
w++;
d = max(d, c[i][j]);
}
}
cout << w << endl << d << endl;
return 0;
} | replace | 19 | 20 | 19 | 21 | -11 | |
p00026 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, a) FOR(i, 0, a)
int f[10][10];
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int main() {
int x, y, size;
while (scanf("%d,%d,%d", &x, &y, &size)) {
int x2, y2;
switch (size) {
case 1:
f[y][x]++;
REP(i, 4) {
x2 = x + dx[i];
y2 = y + dy[i];
if (x2 >= 0 && x2 < 10 && y2 >= 0 && y2 < 10) {
f[y2][x2]++;
}
}
break;
case 2:
FOR(i, -1, 2) {
FOR(j, -1, 2) {
x2 = x + i;
y2 = y + j;
if (x2 >= 0 && x2 < 10 && y2 >= 0 && y2 < 10) {
f[y2][x2]++;
}
}
}
break;
case 3:
FOR(i, -1, 2) {
FOR(j, -1, 2) {
x2 = x + i;
y2 = y + j;
if (x2 >= 0 && x2 < 10 && y2 >= 0 && y2 < 10) {
f[y2][x2]++;
}
}
}
REP(i, 4) {
x2 = x + dx[i] * 2;
y2 = y + dy[i] * 2;
if (x2 >= 0 && x2 < 10 && y2 >= 0 && y2 < 10) {
f[y2][x2]++;
}
}
break;
}
}
int e = 0;
int m = 0;
REP(i, 10) {
REP(j, 10) { m = max(m, f[i][j]); }
}
REP(i, 10) {
REP(j, 10) {
if (f[i][j] == 0) {
e++;
}
}
}
printf("%d\n%d\n", e, m);
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, a) FOR(i, 0, a)
int f[10][10];
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int main() {
int x, y, size;
while (scanf("%d,%d,%d", &x, &y, &size) != -1) {
int x2, y2;
switch (size) {
case 1:
f[y][x]++;
REP(i, 4) {
x2 = x + dx[i];
y2 = y + dy[i];
if (x2 >= 0 && x2 < 10 && y2 >= 0 && y2 < 10) {
f[y2][x2]++;
}
}
break;
case 2:
FOR(i, -1, 2) {
FOR(j, -1, 2) {
x2 = x + i;
y2 = y + j;
if (x2 >= 0 && x2 < 10 && y2 >= 0 && y2 < 10) {
f[y2][x2]++;
}
}
}
break;
case 3:
FOR(i, -1, 2) {
FOR(j, -1, 2) {
x2 = x + i;
y2 = y + j;
if (x2 >= 0 && x2 < 10 && y2 >= 0 && y2 < 10) {
f[y2][x2]++;
}
}
}
REP(i, 4) {
x2 = x + dx[i] * 2;
y2 = y + dy[i] * 2;
if (x2 >= 0 && x2 < 10 && y2 >= 0 && y2 < 10) {
f[y2][x2]++;
}
}
break;
}
}
int e = 0;
int m = 0;
REP(i, 10) {
REP(j, 10) { m = max(m, f[i][j]); }
}
REP(i, 10) {
REP(j, 10) {
if (f[i][j] == 0) {
e++;
}
}
}
printf("%d\n%d\n", e, m);
return 0;
} | replace | 13 | 14 | 13 | 14 | TLE | |
p00026 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <list>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define PUSH(n, v) \
for (int i = 0; i < (n); i++) { \
int j; \
cin >> j; \
v.push_back(j); \
}
#define ALL(v) v.begin(), v.end()
vector<vector<int>> vv;
void ink(int x, int y) {
if (x >= 0 && x < 10 && y >= 0 && y < 10) {
vv[x][y]++;
}
}
void big(int x, int y) {
ink(x - 2, y);
ink(x - 1, y);
ink(x, y);
ink(x + 1, y);
ink(x + 2, y);
ink(x - 1, y - 1);
ink(x, y - 1);
ink(x + 1, y - 1);
ink(x - 1, y + 1);
ink(x, y + 1);
ink(x + 1, y + 1);
ink(x, y - 2);
ink(x, y + 2);
}
void mid(int x, int y) {
ink(x - 1, y);
ink(x, y);
ink(x + 1, y);
ink(x - 1, y - 1);
ink(x, y - 1);
ink(x + 1, y - 1);
ink(x - 1, y + 1);
ink(x, y + 1);
ink(x + 1, y + 1);
}
void small(int x, int y) {
ink(x - 1, y);
ink(x, y);
ink(x + 1, y);
ink(x, y - 1);
ink(x, y + 1);
}
int countBlank() {
int cnt = 0;
REP(i, 10) REP(j, 10) if (vv[i][j] == 0) cnt++;
return cnt;
}
int getThickest() {
int t = 0;
REP(i, 10) REP(j, 10) if (vv[i][j] > t) t = vv[i][j];
return t;
}
int main() {
REP(i, 10) {
vector<int> v(10, 0);
vv.push_back(v);
}
int x, y, s;
while (scanf("%d,%d,%d", &x, &y, &s)) {
switch (s) {
case 1:
small(x, y);
break;
case 2:
mid(x, y);
break;
case 3:
big(x, y);
break;
default:
break;
}
}
cout << countBlank() << endl << getThickest() << endl;
return 0;
} | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <list>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define PUSH(n, v) \
for (int i = 0; i < (n); i++) { \
int j; \
cin >> j; \
v.push_back(j); \
}
#define ALL(v) v.begin(), v.end()
vector<vector<int>> vv;
void ink(int x, int y) {
if (x >= 0 && x < 10 && y >= 0 && y < 10) {
vv[x][y]++;
}
}
void big(int x, int y) {
ink(x - 2, y);
ink(x - 1, y);
ink(x, y);
ink(x + 1, y);
ink(x + 2, y);
ink(x - 1, y - 1);
ink(x, y - 1);
ink(x + 1, y - 1);
ink(x - 1, y + 1);
ink(x, y + 1);
ink(x + 1, y + 1);
ink(x, y - 2);
ink(x, y + 2);
}
void mid(int x, int y) {
ink(x - 1, y);
ink(x, y);
ink(x + 1, y);
ink(x - 1, y - 1);
ink(x, y - 1);
ink(x + 1, y - 1);
ink(x - 1, y + 1);
ink(x, y + 1);
ink(x + 1, y + 1);
}
void small(int x, int y) {
ink(x - 1, y);
ink(x, y);
ink(x + 1, y);
ink(x, y - 1);
ink(x, y + 1);
}
int countBlank() {
int cnt = 0;
REP(i, 10) REP(j, 10) if (vv[i][j] == 0) cnt++;
return cnt;
}
int getThickest() {
int t = 0;
REP(i, 10) REP(j, 10) if (vv[i][j] > t) t = vv[i][j];
return t;
}
int main() {
REP(i, 10) {
vector<int> v(10, 0);
vv.push_back(v);
}
int x, y, s;
string t;
while (cin >> t) {
x = t[0] - '0';
y = t[2] - '0';
s = t[4] - '0';
switch (s) {
case 1:
small(x, y);
break;
case 2:
mid(x, y);
break;
case 3:
big(x, y);
break;
default:
break;
}
}
cout << countBlank() << endl << getThickest() << endl;
return 0;
} | replace | 83 | 84 | 83 | 88 | TLE | |
p00027 | C++ | Runtime Error | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
int dayNum[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string day[7] = {"Monday", "Tuesday", "Wednesday",
"Thursday", // <- 2004/1/1
"Friday", "Saturday", "Sunday"};
int main() {
int m, d;
cin >> m >> d;
while (m != 0 && d != 0) {
int daySum = 0;
for (int i = 0; i < m - 1; i++) {
daySum += dayNum[i];
}
daySum += d;
cout << day[daySum % 7 + 2] << endl;
cin >> m >> d;
}
return 0;
} | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
int dayNum[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string day[7] = {"Monday", "Tuesday", "Wednesday",
"Thursday", // <- 2004/1/1
"Friday", "Saturday", "Sunday"};
int main() {
int m, d;
cin >> m >> d;
while (m != 0 && d != 0) {
int daySum = 0;
for (int i = 0; i < m - 1; i++) {
daySum += dayNum[i];
}
daySum += d;
cout << day[(daySum + 2) % 7] << endl;
cin >> m >> d;
}
return 0;
} | replace | 30 | 31 | 30 | 31 | 0 | |
p00027 | C++ | Runtime Error | #define _USE_MATH_DEFINES
#include <algorithm>
#include <cctype>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define INF (1 << 20)
#define EPS (1e-10)
#define EQ(a, b) (fabs((a) - (b)) < EPS)
int main() {
int dn[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string youbi[7] = {"Monday", "Tuesday", "Wednesday", "Thursday",
"Friday", "Saturday", "Sunday"};
int m, d;
while (cin >> m >> d) {
if (m == 0)
break;
int sum = 0;
for (int i = 1; i < m; ++i) {
sum += dn[i];
}
sum += d;
cout << youbi[sum % 7 + 2] << endl;
}
return 0;
} | #define _USE_MATH_DEFINES
#include <algorithm>
#include <cctype>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define INF (1 << 20)
#define EPS (1e-10)
#define EQ(a, b) (fabs((a) - (b)) < EPS)
int main() {
int dn[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string youbi[7] = {"Monday", "Tuesday", "Wednesday", "Thursday",
"Friday", "Saturday", "Sunday"};
int m, d;
while (cin >> m >> d) {
if (m == 0)
break;
int sum = 0;
for (int i = 1; i < m; ++i) {
sum += dn[i];
}
sum += d;
cout << youbi[(sum + 2) % 7] << endl;
}
return 0;
} | replace | 30 | 31 | 30 | 31 | 0 | |
p00027 | C++ | Runtime Error | #include <algorithm>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string.h>
#include <string>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)
#define FOR(i, b, e) for (int i = b; i < e; i++)
#define to_bit(i) static_cast<bitset<8>>(i)
#define INF (1 << 28)
#define int(n) \
int n; \
cin >> n;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef queue<int> QI;
typedef priority_queue<int> maxpq;
typedef priority_queue<int, vector<int>, greater<int>> minpq;
struct edge {
int to, cost;
};
void begin() {
cin.tie(0);
ios::sync_with_stdio(false);
};
int gcd(int a, int b) {
if (a % b == 0) {
return (b);
} else {
return (gcd(b, a % b));
}
};
int lcm(int m, int n) {
if ((0 == m) || (0 == n)) {
return 0;
}
return ((m / gcd(m, n)) * n);
};
unsigned long long comb(long n, long m) {
unsigned long long c = 1;
m = (n - m < m ? n - m : m);
for (long ns = n - m + 1, ms = 1; ms <= m; ns++, ms++) {
c *= ns;
c /= ms;
}
return c;
};
void cp(int a1[], int a2[], int l) { REP(i, l) a2[i] = a1[i]; };
void cp(string a1[], string a2[], int l) { REP(i, l) a2[i] = a1[i]; };
double sq(double d) { return d * d; };
int sq(int i) { return i * i; };
double sqdist(int x1, int y1, int x2, int y2) {
double dx = x1 - x2, dy = y1 - y2;
return dx * dx + dy * dy;
};
bool inside(int y, int x, int h, int w) {
return 0 <= y && y <= (h - 1) && 0 <= x && x <= (w - 1);
};
// 線分の交差判定
bool isCross(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) {
// 並行な場合
int m = (x2 - x1) * (y4 - y3) - (y2 - y1) * (x4 - x3);
if (m == 0)
return false;
// 媒介変数の値が0より大きく1以下なら交差する、これは問題の状況によって変わるかも。
double r = (double)((y4 - y3) * (x3 - x1) - (x4 - x3) * (y3 - y1)) / m;
double s = (double)((y2 - y1) * (x3 - x1) - (x2 - x1) * (y3 - y1)) / m;
return (0 < r && r <= 1 && 0 < s && s <= 1);
};
// 外積の計算 AB CD の内積を求める
int crossProdct(int ax, int ay, int bx, int by, int cx, int cy, int dx,
int dy) {
int abx = bx - ax;
int aby = by - ay;
int cdx = dx - cx;
int cdy = dy - cy;
return abx * cdy - cdx * aby;
};
double crossProdct(double ax, double ay, double bx, double by, double cx,
double cy, double dx, double dy) {
double abx = bx - ax;
double aby = by - ay;
double cdx = dx - cx;
double cdy = dy - cy;
return abx * cdy - cdx * aby;
};
double innerProduct(double ax, double ay, double bx, double by, double cx,
double cy, double dx, double dy) {
double abx = bx - ax;
double aby = by - ay;
double cdx = dx - cx;
double cdy = dy - cy;
return abx * cdx + aby * cdy;
};
// 三角形の内部判定 ABCの中にPがあるか判定
bool inTriangle(int ax, int ay, int bx, int by, int cx, int cy, int px,
int py) {
int c1 = crossProdct(ax, ay, bx, by, bx, by, px, py);
int c2 = crossProdct(bx, by, cx, cy, cx, cy, px, py);
int c3 = crossProdct(cx, cy, ax, ay, ax, ay, px, py);
return (c1 > 0 && c2 > 0 && c3 > 0) || (c1 < 0 && c2 < 0 && c3 < 0);
};
bool inTriangle(double ax, double ay, double bx, double by, double cx,
double cy, double px, double py) {
double c1 = crossProdct(ax, ay, bx, by, bx, by, px, py);
double c2 = crossProdct(bx, by, cx, cy, cx, cy, px, py);
double c3 = crossProdct(cx, cy, ax, ay, ax, ay, px, py);
return (c1 > 0 && c2 > 0 && c3 > 0) || (c1 < 0 && c2 < 0 && c3 < 0);
};
// 三角形の外心
void circumcenter(double x1, double y1, double x2, double y2, double x3,
double y3, double res[3]) {
double xp1 = (y1 - y3) * (y1 * y1 - y2 * y2 + x1 * x1 - x2 * x2) -
(y1 - y2) * (y1 * y1 - y3 * y3 + x1 * x1 - x3 * x3);
double xp2 = 2 * (y1 - y3) * (x1 - x2) - 2 * (y1 - y2) * (x1 - x3);
res[0] = xp1 / xp2;
double yp1 = (x1 - x3) * (x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2) -
(x1 - x2) * (x1 * x1 - x3 * x3 + y1 * y1 - y3 * y3);
double yp2 = 2 * (x1 - x3) * (y1 - y2) - 2 * (x1 - x2) * (y1 - y3);
res[1] = yp1 / yp2;
double r = (x3 - res[0]) * (x3 - res[0]) + (y3 - res[1]) * (y3 - res[1]);
res[2] = sqrt(r);
}
class BinaryIndexedTree {
public:
int n;
vector<int> bit;
BinaryIndexedTree(int _n) {
n = _n;
bit.resize(n + 1, 0);
}
int sum(int i) {
int sum = 0;
while (i > 0) {
sum += bit[i];
i -= i & -i;
}
return sum;
}
void add(int i, int v) {
while (i <= n) {
bit[i] += v;
i += i & -i;
}
}
};
class UnionFindTree {
public:
vector<int> parent, rank;
int n;
std::set<int> set;
// 初期化
UnionFindTree(int _n) {
n = _n;
for (int i = 0; i < n; i++) {
parent.resize(n);
rank.resize(n);
parent[i] = i;
rank[i] = 0;
}
}
// 根を求める
int find(int x) {
if (parent[x] == x) {
return x;
} else {
return parent[x] = find(parent[x]);
}
}
// xとyの集合を結合
void unite(int x, int y) {
x = find(x);
y = find(y);
if (x == y) {
set.insert(x);
return;
}
if (rank[x] < rank[y]) {
parent[x] = y;
set.erase(x);
set.insert(y);
} else {
parent[y] = x;
set.erase(y);
set.insert(x);
if (rank[x] == rank[y])
rank[x]++;
}
}
// xとyが同じ集合か
bool same(int x, int y) { return find(x) == find(y); }
// 集合の数を数える
int count() { return (int)set.size(); }
};
// ワーシャルフロイド法
void warshallFloyd(int graph[100][100], int graph_size) {
for (int mid_node = 0; mid_node < graph_size; mid_node++)
for (int s_node = 0; s_node < graph_size; s_node++)
for (int g_node = 0; g_node < graph_size; g_node++)
if (s_node == g_node)
graph[s_node][g_node] = 0;
else
graph[s_node][g_node] =
min(graph[s_node][g_node],
graph[s_node][mid_node] + graph[mid_node][g_node]);
};
// d:隣接行列 n:グラフのサイズ s:始点 dist:始点からの距離が入る配列
void dijkstra(int graph[1000][1000], int node_count, int start_node,
int distances[1000]) {
REP(i, node_count) distances[i] = -1;
distances[start_node] = 0;
priority_queue<PII, vector<PII>, greater<PII>> dijkstra_pq;
dijkstra_pq.push(PII(0, start_node));
while (!dijkstra_pq.empty()) {
PII p = dijkstra_pq.top();
dijkstra_pq.pop();
int i = p.second;
if (distances[i] < p.first)
continue;
for (int j = 0; j < node_count; j++) {
if (graph[i][j] == -1)
continue;
if (distances[j] == -1) {
distances[j] = distances[i] + graph[i][j];
dijkstra_pq.push(PII(distances[j], j));
} else if (distances[j] > distances[i] + graph[i][j]) {
distances[j] = distances[i] + graph[i][j];
dijkstra_pq.push(PII(distances[j], j));
}
}
}
};
// return とかの位置によってうまい具合にする
int vi[4] = {-1, 1, 0, 0}, vj[4] = {0, 0, -1, 1};
void dfs2d(int i, int j, int r, int c){// 終了条件とかをここに書く
REP(k, 4){int ni = i + vi[k];
int nj = j + vj[k];
if (inside(ni, nj, r, c)) {
dfs2d(ni, nj, r, c);
}
}
}
;
/**
* start
* @author yoshikyoto
*/
string week[7] = {"Thursday", "Friday", "Saturday", "Sunday",
"Monday", "Tuesday", "Wednesday"};
int month[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
vector<string> cal[12];
int main(int argc, const char *argv[]) {
begin();
// カレンダーの作成
int counter = 0;
REP(i, 12) {
REP(j, month[i]) {
cal[i].push_back(week[counter % 7]);
counter++;
}
}
while (true) {
int(m);
int(d);
m--;
d--;
cout << cal[m][d] << endl;
}
} | #include <algorithm>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string.h>
#include <string>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)
#define FOR(i, b, e) for (int i = b; i < e; i++)
#define to_bit(i) static_cast<bitset<8>>(i)
#define INF (1 << 28)
#define int(n) \
int n; \
cin >> n;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef queue<int> QI;
typedef priority_queue<int> maxpq;
typedef priority_queue<int, vector<int>, greater<int>> minpq;
struct edge {
int to, cost;
};
void begin() {
cin.tie(0);
ios::sync_with_stdio(false);
};
int gcd(int a, int b) {
if (a % b == 0) {
return (b);
} else {
return (gcd(b, a % b));
}
};
int lcm(int m, int n) {
if ((0 == m) || (0 == n)) {
return 0;
}
return ((m / gcd(m, n)) * n);
};
unsigned long long comb(long n, long m) {
unsigned long long c = 1;
m = (n - m < m ? n - m : m);
for (long ns = n - m + 1, ms = 1; ms <= m; ns++, ms++) {
c *= ns;
c /= ms;
}
return c;
};
void cp(int a1[], int a2[], int l) { REP(i, l) a2[i] = a1[i]; };
void cp(string a1[], string a2[], int l) { REP(i, l) a2[i] = a1[i]; };
double sq(double d) { return d * d; };
int sq(int i) { return i * i; };
double sqdist(int x1, int y1, int x2, int y2) {
double dx = x1 - x2, dy = y1 - y2;
return dx * dx + dy * dy;
};
bool inside(int y, int x, int h, int w) {
return 0 <= y && y <= (h - 1) && 0 <= x && x <= (w - 1);
};
// 線分の交差判定
bool isCross(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) {
// 並行な場合
int m = (x2 - x1) * (y4 - y3) - (y2 - y1) * (x4 - x3);
if (m == 0)
return false;
// 媒介変数の値が0より大きく1以下なら交差する、これは問題の状況によって変わるかも。
double r = (double)((y4 - y3) * (x3 - x1) - (x4 - x3) * (y3 - y1)) / m;
double s = (double)((y2 - y1) * (x3 - x1) - (x2 - x1) * (y3 - y1)) / m;
return (0 < r && r <= 1 && 0 < s && s <= 1);
};
// 外積の計算 AB CD の内積を求める
int crossProdct(int ax, int ay, int bx, int by, int cx, int cy, int dx,
int dy) {
int abx = bx - ax;
int aby = by - ay;
int cdx = dx - cx;
int cdy = dy - cy;
return abx * cdy - cdx * aby;
};
double crossProdct(double ax, double ay, double bx, double by, double cx,
double cy, double dx, double dy) {
double abx = bx - ax;
double aby = by - ay;
double cdx = dx - cx;
double cdy = dy - cy;
return abx * cdy - cdx * aby;
};
double innerProduct(double ax, double ay, double bx, double by, double cx,
double cy, double dx, double dy) {
double abx = bx - ax;
double aby = by - ay;
double cdx = dx - cx;
double cdy = dy - cy;
return abx * cdx + aby * cdy;
};
// 三角形の内部判定 ABCの中にPがあるか判定
bool inTriangle(int ax, int ay, int bx, int by, int cx, int cy, int px,
int py) {
int c1 = crossProdct(ax, ay, bx, by, bx, by, px, py);
int c2 = crossProdct(bx, by, cx, cy, cx, cy, px, py);
int c3 = crossProdct(cx, cy, ax, ay, ax, ay, px, py);
return (c1 > 0 && c2 > 0 && c3 > 0) || (c1 < 0 && c2 < 0 && c3 < 0);
};
bool inTriangle(double ax, double ay, double bx, double by, double cx,
double cy, double px, double py) {
double c1 = crossProdct(ax, ay, bx, by, bx, by, px, py);
double c2 = crossProdct(bx, by, cx, cy, cx, cy, px, py);
double c3 = crossProdct(cx, cy, ax, ay, ax, ay, px, py);
return (c1 > 0 && c2 > 0 && c3 > 0) || (c1 < 0 && c2 < 0 && c3 < 0);
};
// 三角形の外心
void circumcenter(double x1, double y1, double x2, double y2, double x3,
double y3, double res[3]) {
double xp1 = (y1 - y3) * (y1 * y1 - y2 * y2 + x1 * x1 - x2 * x2) -
(y1 - y2) * (y1 * y1 - y3 * y3 + x1 * x1 - x3 * x3);
double xp2 = 2 * (y1 - y3) * (x1 - x2) - 2 * (y1 - y2) * (x1 - x3);
res[0] = xp1 / xp2;
double yp1 = (x1 - x3) * (x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2) -
(x1 - x2) * (x1 * x1 - x3 * x3 + y1 * y1 - y3 * y3);
double yp2 = 2 * (x1 - x3) * (y1 - y2) - 2 * (x1 - x2) * (y1 - y3);
res[1] = yp1 / yp2;
double r = (x3 - res[0]) * (x3 - res[0]) + (y3 - res[1]) * (y3 - res[1]);
res[2] = sqrt(r);
}
class BinaryIndexedTree {
public:
int n;
vector<int> bit;
BinaryIndexedTree(int _n) {
n = _n;
bit.resize(n + 1, 0);
}
int sum(int i) {
int sum = 0;
while (i > 0) {
sum += bit[i];
i -= i & -i;
}
return sum;
}
void add(int i, int v) {
while (i <= n) {
bit[i] += v;
i += i & -i;
}
}
};
class UnionFindTree {
public:
vector<int> parent, rank;
int n;
std::set<int> set;
// 初期化
UnionFindTree(int _n) {
n = _n;
for (int i = 0; i < n; i++) {
parent.resize(n);
rank.resize(n);
parent[i] = i;
rank[i] = 0;
}
}
// 根を求める
int find(int x) {
if (parent[x] == x) {
return x;
} else {
return parent[x] = find(parent[x]);
}
}
// xとyの集合を結合
void unite(int x, int y) {
x = find(x);
y = find(y);
if (x == y) {
set.insert(x);
return;
}
if (rank[x] < rank[y]) {
parent[x] = y;
set.erase(x);
set.insert(y);
} else {
parent[y] = x;
set.erase(y);
set.insert(x);
if (rank[x] == rank[y])
rank[x]++;
}
}
// xとyが同じ集合か
bool same(int x, int y) { return find(x) == find(y); }
// 集合の数を数える
int count() { return (int)set.size(); }
};
// ワーシャルフロイド法
void warshallFloyd(int graph[100][100], int graph_size) {
for (int mid_node = 0; mid_node < graph_size; mid_node++)
for (int s_node = 0; s_node < graph_size; s_node++)
for (int g_node = 0; g_node < graph_size; g_node++)
if (s_node == g_node)
graph[s_node][g_node] = 0;
else
graph[s_node][g_node] =
min(graph[s_node][g_node],
graph[s_node][mid_node] + graph[mid_node][g_node]);
};
// d:隣接行列 n:グラフのサイズ s:始点 dist:始点からの距離が入る配列
void dijkstra(int graph[1000][1000], int node_count, int start_node,
int distances[1000]) {
REP(i, node_count) distances[i] = -1;
distances[start_node] = 0;
priority_queue<PII, vector<PII>, greater<PII>> dijkstra_pq;
dijkstra_pq.push(PII(0, start_node));
while (!dijkstra_pq.empty()) {
PII p = dijkstra_pq.top();
dijkstra_pq.pop();
int i = p.second;
if (distances[i] < p.first)
continue;
for (int j = 0; j < node_count; j++) {
if (graph[i][j] == -1)
continue;
if (distances[j] == -1) {
distances[j] = distances[i] + graph[i][j];
dijkstra_pq.push(PII(distances[j], j));
} else if (distances[j] > distances[i] + graph[i][j]) {
distances[j] = distances[i] + graph[i][j];
dijkstra_pq.push(PII(distances[j], j));
}
}
}
};
// return とかの位置によってうまい具合にする
int vi[4] = {-1, 1, 0, 0}, vj[4] = {0, 0, -1, 1};
void dfs2d(int i, int j, int r, int c){// 終了条件とかをここに書く
REP(k, 4){int ni = i + vi[k];
int nj = j + vj[k];
if (inside(ni, nj, r, c)) {
dfs2d(ni, nj, r, c);
}
}
}
;
/**
* start
* @author yoshikyoto
*/
string week[7] = {"Thursday", "Friday", "Saturday", "Sunday",
"Monday", "Tuesday", "Wednesday"};
int month[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
vector<string> cal[12];
int main(int argc, const char *argv[]) {
begin();
// カレンダーの作成
int counter = 0;
REP(i, 12) {
REP(j, month[i]) {
cal[i].push_back(week[counter % 7]);
counter++;
}
}
while (true) {
int(m);
int(d);
if (m == 0 && d == 0)
return 0;
m--;
d--;
cout << cal[m][d] << endl;
}
} | insert | 292 | 292 | 292 | 294 | -11 |