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
|
---|---|---|---|---|---|---|---|---|---|---|---|
p00027 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
const int INF = 1e+9 * 2;
double eps = 1e-10;
string days[] = {"Thursday", "Friday", "Saturday", "Sunday",
"Monday", "Tuesday", "Wednesday"};
int main() {
int m, d;
while (cin >> m >> d && (m || d)) {
int cnt = 0;
for (int i = 1; i <= 12; ++i) {
for (int j = 1; j <= 31; ++j) {
if (m == i && j == d) {
cout << days[cnt % 8] << endl;
goto end;
}
cnt++;
if (i == 2 && j == 29)
break;
else if ((i == 4 || i == 6 || i == 9 || i == 11) && j == 30)
break;
}
}
end:;
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
const int INF = 1e+9 * 2;
double eps = 1e-10;
string days[] = {"Thursday", "Friday", "Saturday", "Sunday",
"Monday", "Tuesday", "Wednesday"};
int main() {
int m, d;
while (cin >> m >> d && (m || d)) {
int cnt = 0;
for (int i = 1; i <= 12; ++i) {
for (int j = 1; j <= 31; ++j) {
if (m == i && j == d) {
cout << days[cnt % 7] << endl;
goto end;
}
cnt++;
if (i == 2 && j == 29)
break;
else if ((i == 4 || i == 6 || i == 9 || i == 11) && j == 30)
break;
}
}
end:;
}
return 0;
} | replace | 15 | 16 | 15 | 16 | 0 | |
p00027 | C++ | Runtime Error | #include <iostream>
using namespace std;
int getDay(int y, int m, int d) {
if (m < 3)
m += 12, y--;
int J = y / 100, K = y % 100;
return (d + ((m + 1) * 26) / 10 + K + K / 4 + J / 4 - 2 * J) % 7;
}
int main() {
string table[] = {"Saturday", "Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday"};
int m, d;
while (cin >> m >> d, m) {
cout << table[getDay(2004, m, d)] << endl;
}
} | #include <iostream>
using namespace std;
int getDay(int y, int m, int d) {
if (m < 3)
m += 12, y--;
int J = y / 100, K = y % 100;
return (d + (((m + 1) * 26) / 10) + K + (K / 4) + (J / 4) + 5 * J) % 7;
}
int main() {
string table[] = {"Saturday", "Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday"};
int m, d;
while (cin >> m >> d, m) {
cout << table[getDay(2004, m, d)] << endl;
}
} | replace | 7 | 8 | 7 | 8 | 0 | |
p00027 | C++ | Runtime Error | #include <algorithm>
#include <cmath>
#include <fstream>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
using namespace std;
int main() {
ifstream cin("../test.txt");
int year[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string day[7] = {"Monday", "Tuesday", "Wednesday", "Thursday",
"Friday", "Saturday", "Sunday"};
int first = 3;
int m, d;
while (true) {
cin >> m >> d;
if (!(m | d))
break;
int n = first;
for (int i = 0; i < m - 1; i++) {
n += year[i];
}
n += d - 1;
n %= 7;
cout << day[n] << endl;
}
} | #include <algorithm>
#include <cmath>
#include <fstream>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
using namespace std;
int main() {
int year[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string day[7] = {"Monday", "Tuesday", "Wednesday", "Thursday",
"Friday", "Saturday", "Sunday"};
int first = 3;
int m, d;
while (true) {
cin >> m >> d;
if (!(m | d))
break;
int n = first;
for (int i = 0; i < m - 1; i++) {
n += year[i];
}
n += d - 1;
n %= 7;
cout << day[n] << endl;
}
} | delete | 10 | 12 | 10 | 10 | -11 | |
p00027 | C++ | Runtime Error | #define _USE_MATH_DEFINES
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
string a[7] = {"Monday", "Tuesday", "Wednesday", "Thursday",
"Friday", "Saturday", "Sunday"};
int b[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main() {
for (int m, d; cin >> m >> d && m;) {
while (m)
d += b[--m];
cout << a[d % 7 - 1 + 3] << endl;
}
return 0;
} | #define _USE_MATH_DEFINES
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
string a[7] = {"Monday", "Tuesday", "Wednesday", "Thursday",
"Friday", "Saturday", "Sunday"};
int b[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main() {
for (int m, d; cin >> m >> d && m;) {
while (m)
d += b[--m];
cout << a[(d - 1 + 3) % 7] << endl;
}
return 0;
} | replace | 26 | 27 | 26 | 27 | 0 | |
p00027 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
int main() {
int m, d;
string week[] = {"Monday", "Tuesday", "Wednesday", "Thursday",
"Friday", "Saturday", "Sunday"};
int day[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
while (cin >> m >> d) {
if (m == 0)
break;
bool flag = false;
int mc = 1;
int cnt = 3;
while (1) {
for (int i = 1; i < day[mc - 1]; ++i, cnt++) {
if (mc == m && d == i) {
cout << week[cnt % 7] << endl;
flag = true;
break;
}
}
if (flag)
break;
mc++;
}
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int m, d;
string week[] = {"Monday", "Tuesday", "Wednesday", "Thursday",
"Friday", "Saturday", "Sunday"};
int day[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
while (cin >> m >> d) {
if (m == 0)
break;
bool flag = false;
int mc = 1;
int cnt = 3;
while (1) {
for (int i = 1; i <= day[mc - 1]; ++i, cnt++) {
if (mc == m && d == i) {
cout << week[cnt % 7] << endl;
flag = true;
break;
}
}
if (flag)
break;
mc++;
}
}
return 0;
} | replace | 15 | 16 | 15 | 16 | TLE | |
p00027 | C++ | Time Limit Exceeded | #include <iostream>
#include <string>
using namespace std;
int main() {
int k, m, d;
string today[7] = {"Monday", "Tuesday", "Wednesday", "Thursday",
"Friday", "Saturday", "Sunday"};
int mon[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
while (cin >> m >> d) {
if (m == 0)
break;
for (int i = 0; m - 1 > i; i++)
d += mon[i];
k = d % 7 + 2;
cout << today[k] << endl;
}
} | #include <iostream>
#include <string>
using namespace std;
int main() {
int k, m, d;
string today[7] = {"Monday", "Tuesday", "Wednesday", "Thursday",
"Friday", "Saturday", "Sunday"};
int mon[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
while (cin >> m >> d) {
if (m == 0)
break;
for (int i = 0; m - 1 > i; i++)
d += mon[i];
k = d % 7 + 2;
cout << today[k % 7] << endl;
}
} | replace | 18 | 19 | 18 | 19 | TLE | |
p00027 | C++ | Runtime Error | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
int main() {
int M[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string w[7] = {"Wednesday", "Thursday", "Friday", "Saturday",
"Sunday", "Monday", "Tuesday"};
int m, d;
while (cin >> m >> d) {
if (m == 0 || d == 0)
break;
int tmp = d;
for (int i = 0; i < m; i++)
tmp += M[i];
cerr << tmp << endl;
cout << w[tmp % 7] << endl;
}
return 0;
} | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
int main() {
int M[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string w[7] = {"Wednesday", "Thursday", "Friday", "Saturday",
"Sunday", "Monday", "Tuesday"};
int m, d;
while (cin >> m >> d) {
if (m == 0 || d == 0)
break;
int tmp = d;
for (int i = 0; i < m; i++)
tmp += M[i];
cout << w[tmp % 7] << endl;
}
return 0;
} | delete | 25 | 26 | 25 | 25 | 0 | 1
60
|
p00028 | C++ | Time Limit Exceeded | #include <iostream>
#include <map>
using namespace std;
void solve() {
map<int, int> Map;
int n;
while (cin >> n, n) {
++Map[n];
}
int Max = 0;
for (map<int, int>::iterator Ite = Map.begin(); Ite != Map.end(); ++Ite) {
if (Max < Ite->second) {
Max = Ite->second;
}
}
for (map<int, int>::iterator Ite = Map.begin(); Ite != Map.end(); ++Ite) {
if (Ite->second == Max) {
cout << Ite->first << endl;
}
}
}
int main() {
solve();
return (0);
} | #include <iostream>
#include <map>
using namespace std;
void solve() {
map<int, int> Map;
int n;
while (~scanf("%d", &n)) {
++Map[n];
}
int Max = 0;
for (map<int, int>::iterator Ite = Map.begin(); Ite != Map.end(); ++Ite) {
if (Max < Ite->second) {
Max = Ite->second;
}
}
for (map<int, int>::iterator Ite = Map.begin(); Ite != Map.end(); ++Ite) {
if (Ite->second == Max) {
cout << Ite->first << endl;
}
}
}
int main() {
solve();
return (0);
} | replace | 8 | 9 | 8 | 9 | TLE | |
p00028 | C++ | Runtime Error | #include <iostream>
using namespace std;
int main(void) {
int n = 0, i, a[100], b[100] = {};
while (cin >> i)
a[n++] = i;
for (int i = 0; i < n; ++i)
++b[a[i]];
int max = 0;
for (int i = 1; i <= 100; ++i)
if (b[i] > max)
max = b[i];
for (int i = 1; i <= 100; ++i)
if (max == b[i])
cout << i << endl;
return 0;
}
| #include <iostream>
using namespace std;
int main(void) {
int n = 0, i, a[100], b[101] = {};
while (cin >> i)
a[n++] = i;
for (int i = 0; i < n; ++i)
++b[a[i]];
int max = 0;
for (int i = 1; i <= 100; ++i)
if (b[i] > max)
max = b[i];
for (int i = 1; i <= 100; ++i)
if (max == b[i])
cout << i << endl;
return 0;
}
| replace | 4 | 5 | 4 | 5 | 0 | |
p00028 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define LOG(...) printf(__VA_ARGS__)
// #define LOG(...)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define RSORT(c) sort((c).rbegin(), (c).rend())
#define CLR(a) memset((a), 0, sizeof(a))
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
int main() {
int a[100] = {0};
int n;
while (cin >> n, n)
a[n - 1]++;
int ma = 0;
REP(i, 100) { ma = max(ma, a[i]); }
REP(i, 100) {
if (a[i] == ma)
cout << (i + 1) << endl;
}
return 0;
} | #include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define LOG(...) printf(__VA_ARGS__)
// #define LOG(...)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define RSORT(c) sort((c).rbegin(), (c).rend())
#define CLR(a) memset((a), 0, sizeof(a))
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
int main() {
int a[100] = {0};
int n;
while (cin >> n)
a[n - 1]++;
int ma = 0;
REP(i, 100) { ma = max(ma, a[i]); }
REP(i, 100) {
if (a[i] == ma)
cout << (i + 1) << endl;
}
return 0;
} | replace | 49 | 50 | 49 | 50 | TLE | |
p00028 | C++ | Time Limit Exceeded | #include <iostream>
using namespace std;
int main() {
int n, max = 0, x[100] = {0};
int x_max;
while (scanf("%d", &n)) {
if (n == 0) {
break;
}
x[n - 1]++;
}
for (int i = 0; i < 100; i++) {
if (max < x[i]) {
max = x[i];
x_max = i;
}
}
cout << x_max + 1 << endl;
for (int i = x_max + 1; i < 100; i++) {
if (x[x_max] == x[i]) {
cout << i + 1 << endl;
}
}
return 0;
} | #include <iostream>
using namespace std;
int main() {
int n, max = 0, x[100] = {0};
int x_max;
while (scanf("%d", &n) != EOF) {
x[n - 1]++;
}
for (int i = 0; i < 100; i++) {
if (max < x[i]) {
max = x[i];
x_max = i;
}
}
cout << x_max + 1 << endl;
for (int i = x_max + 1; i < 100; i++) {
if (x[x_max] == x[i]) {
cout << i + 1 << endl;
}
}
return 0;
} | replace | 8 | 12 | 8 | 9 | TLE | |
p00028 | C++ | Time Limit Exceeded | #include <iostream>
#include <string>
using namespace std;
int main() {
int a[100];
int b;
b = 0;
while (b < 100) {
a[b] = 0;
}
int n;
while (cin >> n) {
a[n] = a[n] + 1;
}
int c;
c = 0;
b = 0;
while (b < 100) {
if (a[b] > c) {
c = a[b];
}
b = b + 1;
}
b = 0;
while (b < 100) {
if (c == a[b]) {
cout << b << endl;
}
b = b + 1;
}
} | #include <iostream>
#include <string>
using namespace std;
int main() {
int a[100];
int b;
b = 0;
while (b < 100) {
a[b] = 0;
b = b + 1;
}
int n;
while (cin >> n) {
a[n] = a[n] + 1;
}
int c;
c = 0;
b = 0;
while (b < 100) {
if (a[b] > c) {
c = a[b];
}
b = b + 1;
}
b = 0;
while (b < 100) {
if (c == a[b]) {
cout << b << endl;
}
b = b + 1;
}
} | insert | 9 | 9 | 9 | 10 | TLE | |
p00028 | C++ | Runtime Error | #include <iostream>
using namespace std;
int main() {
int n, max = 0;
int in[100] = {0};
while (cin >> n) {
in[n]++;
if (max < in[n])
max = in[n];
}
for (int i = 1; i <= 100; i++) {
if (max == in[i])
cout << i << endl;
}
return 0;
} | #include <iostream>
using namespace std;
int main() {
int n, max = 0;
int in[100] = {0};
while (cin >> n) {
in[n]++;
if (max < in[n])
max = in[n];
}
for (int i = 0; i < 100; i++) {
if (max == in[i])
cout << i << endl;
}
return 0;
} | replace | 12 | 13 | 12 | 13 | 0 | |
p00028 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main(int argc, char *argv[]) {
int x;
vector<int> freq;
int X[100] = {0};
while (cin >> x) {
freq.push_back(x);
}
int maxf = 0;
for (int i = 0; i < freq.size(); i++) {
X[freq[i]]++;
maxf = max(maxf, X[freq[i]]);
}
for (int j = 0; j < 100; j++) {
if (X[j] == maxf) {
cout << j << endl;
}
}
return 0;
} | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main(int argc, char *argv[]) {
int x;
vector<int> freq;
int X[120] = {0};
while (cin >> x) {
freq.push_back(x);
}
int maxf = 0;
for (int i = 0; i < freq.size(); i++) {
X[freq[i]]++;
maxf = max(maxf, X[freq[i]]);
}
for (int j = 0; j < 100; j++) {
if (X[j] == maxf) {
cout << j << endl;
}
}
return 0;
} | replace | 8 | 9 | 8 | 9 | 0 | |
p00028 | C++ | Time Limit Exceeded | #include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
typedef long long Int;
#define REP(i, n) for (int i = 0; i < n; ++i)
using namespace std;
Int aa[120];
int main() {
int a = -1;
while (cin >> a, a != -1) {
++aa[a];
}
Int b = 0;
REP(i, 120) { b = max(b, aa[i]); }
REP(i, 120) {
if (aa[i] == b)
cout << i << endl;
}
return 0;
} | #include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
typedef long long Int;
#define REP(i, n) for (int i = 0; i < n; ++i)
using namespace std;
Int aa[120];
int main() {
int a = -1;
while (cin >> a) {
++aa[a];
}
Int b = 0;
REP(i, 120) { b = max(b, aa[i]); }
REP(i, 120) {
if (aa[i] == b)
cout << i << endl;
}
return 0;
} | replace | 20 | 21 | 20 | 21 | TLE | |
p00028 | C++ | Time Limit Exceeded | #include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeinfo>
#include <utility>
#include <vector>
using namespace std;
int main(void) {
int a;
int maxa = 0;
vector<int> ans;
map<int, int> f;
for (a = 0; a <= 100; a++) {
f.insert(map<int, int>::value_type(a, 0));
}
while (~scanf("%d", &a)) {
f[a]++;
}
for (a = 0; a <= 100; a++) {
maxa = max(maxa, f[a]);
}
for (a = 0; a <= 100; a++) {
if (maxa == f[a])
ans.push_back(a);
}
sort(ans.begin(), ans.end());
while (!ans.empty()) {
cout << ans[a] << endl;
}
return 0;
} | #include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeinfo>
#include <utility>
#include <vector>
using namespace std;
int main(void) {
int a;
int maxa = 0;
vector<int> ans;
map<int, int> f;
for (a = 0; a <= 100; a++) {
f.insert(map<int, int>::value_type(a, 0));
}
while (~scanf("%d", &a)) {
f[a]++;
}
for (a = 0; a <= 100; a++) {
maxa = max(maxa, f[a]);
}
for (a = 0; a <= 100; a++) {
if (maxa == f[a])
ans.push_back(a);
}
sort(ans.begin(), ans.end());
for (a = 0; a < ans.size(); a++) {
cout << ans[a] << endl;
}
return 0;
} | replace | 48 | 49 | 48 | 49 | TLE | |
p00028 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int, int> pint;
#define foreach(i, n) for (i = 0; i < n; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define F first
#define S second
int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
int main() {
pair<int, int> a[101];
rep(i, 101) { a[i].second = -i; }
for (int k; cin >> k, k;) {
a[k].first++;
}
sort(a, a + 101, greater<pair<int, int>>());
for (int i = 0; cout << -a[i].second << endl, a[i].F == a[i + 1].F; i++)
;
return 0;
} | #include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int, int> pint;
#define foreach(i, n) for (i = 0; i < n; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define F first
#define S second
int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
int main() {
pair<int, int> a[101];
rep(i, 101) { a[i].second = -i; }
for (int k; cin >> k;) {
a[k].first++;
}
sort(a, a + 101, greater<pair<int, int>>());
for (int i = 0; cout << -a[i].second << endl, a[i].F == a[i + 1].F; i++)
;
return 0;
} | replace | 31 | 32 | 31 | 32 | TLE | |
p00028 | C++ | Runtime Error | #include <iostream>
using namespace std;
int main() {
int ans[100] = {0}, i, n;
int b = 0;
while (cin >> n) {
ans[n]++;
if (ans[n] > b) {
b = ans[n];
}
}
for (i = 1; i <= 100; i++) {
if (b == ans[i]) {
cout << i << endl;
}
}
return 0;
} | #include <iostream>
using namespace std;
int main() {
int ans[101] = {0}, i, n;
int b = 0;
while (cin >> n) {
ans[n]++;
if (ans[n] > b) {
b = ans[n];
}
}
for (i = 1; i <= 100; i++) {
if (b == ans[i]) {
cout << i << endl;
}
}
return 0;
} | replace | 5 | 6 | 5 | 6 | 0 | |
p00028 | C++ | Runtime Error | #define _USE_MATH_DEFINES
#include <algorithm>
#include <cctype>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define EPS 1e-10
using namespace std;
typedef long long llong;
int main() {
int n;
int a[101] = {};
int max = 0;
while (cin >> n) {
a[n]++;
if (max < a[n])
max = a[n];
}
for (int i = 0; i < 102; i++)
if (max == a[i])
cout << i << endl;
return 0;
} | #define _USE_MATH_DEFINES
#include <algorithm>
#include <cctype>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define EPS 1e-10
using namespace std;
typedef long long llong;
int main() {
int n;
int a[101] = {};
int max = 0;
while (cin >> n) {
a[n]++;
if (max < a[n])
max = a[n];
}
for (int i = 0; i < 101; i++)
if (max == a[i])
cout << i << endl;
return 0;
} | replace | 25 | 26 | 25 | 26 | 0 | |
p00029 | C++ | Time Limit Exceeded | #include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
int main() {
int i, i1, len, len1, check, max1, memo1, max2, memo2;
max1 = 0;
max2 = 0;
memo1 = 0;
memo2 = 0;
string t;
vector<string> s;
vector<int> a, u;
for (int h = 0; h < 500; h++) {
u.push_back(0);
}
while (cin >> t) {
check = 0;
len = s.size();
for (i = 0; i < len; i++) {
if (t == s[i]) {
u[i] += 1;
check = 1;
}
}
if (check == 0) {
s.push_back(t);
len1 = t.size();
a.push_back(len1);
}
}
len = s.size();
for (i1 = 0; i1 < len; i1++) {
while (max1 < u[i1]) {
max1 = u[i1];
memo1 = i1;
}
while (max2 < a[i1]) {
max2 = u[i1];
memo2 = i1;
}
}
cout << s[memo1] << " " << s[memo2] << endl;
return 0;
} | #include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
int main() {
int i, i1, len, len1, check, max1, memo1, max2, memo2;
max1 = 0;
max2 = 0;
memo1 = 0;
memo2 = 0;
string t;
vector<string> s;
vector<int> a, u;
for (int h = 0; h < 500; h++) {
u.push_back(0);
}
while (cin >> t) {
check = 0;
len = s.size();
for (i = 0; i < len; i++) {
if (t == s[i]) {
u[i] += 1;
check = 1;
}
}
if (check == 0) {
s.push_back(t);
len1 = t.size();
a.push_back(len1);
}
}
len = s.size();
for (i1 = 0; i1 < len; i1++) {
while (max1 < u[i1]) {
max1 = u[i1];
memo1 = i1;
}
while (max2 < a[i1]) {
max2 = a[i1];
memo2 = i1;
}
}
cout << s[memo1] << " " << s[memo2] << endl;
return 0;
} | replace | 41 | 42 | 41 | 42 | TLE | |
p00029 | C++ | Runtime Error | #include <cmath>
#include <cstdio>
#include <iostream>
#include <string.h>
#include <string>
#include <utility>
using namespace std;
int main() {
string str;
char word[35][35];
int x = 0, y = 0, i = 0, j, length = 0, maxl = 0, maxq[35], q, p = 0;
maxq[0] = 0;
getline(cin, str);
while (1) {
if (str[i] == ' ') {
word[y][x] = '\0';
x = 0;
y++;
} else if (str[i] == '\0') {
word[y][x] = '\0';
word[y + 1][0] = '\0';
break;
} else {
word[y][x] = str[i];
x++;
}
i++;
}
for (i = 0; i < y; i++) {
for (j = 0; j < y - i; j++) {
if (strcmp(word[j], word[j + 1]) > 0) {
for (x = 0; x < 35; x++) {
swap(word[j][x], word[j + 1][x]);
}
}
}
}
for (i = 0; i <= y; i++) {
for (j = 0; word[i][j] != '\0'; j++) {
}
if (maxl < j) {
maxl = j;
length = i;
}
if (strcmp(word[i], word[i + 1]) == 0) {
maxq[i + 1] = maxq[i] + 1;
} else {
maxq[i + 1] = 0;
}
}
for (i = 0; i <= y; i++) {
if (p < maxq[i]) {
p = maxq[i];
q = i;
}
}
printf("%s %s\n", word[q], word[length]);
return 0;
} | #include <cmath>
#include <cstdio>
#include <iostream>
#include <string.h>
#include <string>
#include <utility>
using namespace std;
int main() {
string str;
char word[1010][35];
int x = 0, y = 0, i = 0, j, length = 0, maxl = 0, maxq[35], q, p = 0;
maxq[0] = 0;
getline(cin, str);
while (1) {
if (str[i] == ' ') {
word[y][x] = '\0';
x = 0;
y++;
} else if (str[i] == '\0') {
word[y][x] = '\0';
word[y + 1][0] = '\0';
break;
} else {
word[y][x] = str[i];
x++;
}
i++;
}
for (i = 0; i < y; i++) {
for (j = 0; j < y - i; j++) {
if (strcmp(word[j], word[j + 1]) > 0) {
for (x = 0; x < 35; x++) {
swap(word[j][x], word[j + 1][x]);
}
}
}
}
for (i = 0; i <= y; i++) {
for (j = 0; word[i][j] != '\0'; j++) {
}
if (maxl < j) {
maxl = j;
length = i;
}
if (strcmp(word[i], word[i + 1]) == 0) {
maxq[i + 1] = maxq[i] + 1;
} else {
maxq[i + 1] = 0;
}
}
for (i = 0; i <= y; i++) {
if (p < maxq[i]) {
p = maxq[i];
q = i;
}
}
printf("%s %s\n", word[q], word[length]);
return 0;
} | replace | 10 | 11 | 10 | 11 | 0 | |
p00029 | C++ | Runtime Error | #include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
int main() {
char a[1100] = {0};
scanf("%[^\n]", a);
int cnt = 0;
int mx = 0;
int len[50] = {0};
string ans[50];
for (int i = 0, j = 0; i <= strlen(a); i++) {
if ('a' <= a[i] && a[i] <= 'z' || 'A' <= a[i] && a[i] <= 'Z') {
ans[cnt] += a[i];
j++;
} else {
len[cnt] = j;
cnt++;
mx = max(mx, j);
j = 0;
}
}
string date;
for (int i = 0; i < cnt; i++) {
if (len[i] == mx) {
date = ans[i];
break;
}
}
sort(ans, ans + cnt);
fill(len, len + 50, 0);
string mx_date = ans[0];
ans[cnt] = ' ';
mx = 0;
for (int i = 1; i <= cnt; i++) {
if (mx_date == ans[i]) {
mx++;
} else {
mx_date = ans[i];
len[i - 1] = mx;
mx = 0;
}
}
for (int i = 0; i < cnt; i++) {
mx = max(mx, len[i]);
}
for (int i = 0; i < cnt; i++) {
if (len[i] == mx) {
cout << ans[i] << ' ' << date << endl;
break;
}
}
return 0;
} | #include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
int main() {
char a[1100] = {0};
scanf("%[^\n]", a);
int cnt = 0;
int mx = 0;
int len[1100] = {0};
string ans[1100];
for (int i = 0, j = 0; i <= strlen(a); i++) {
if ('a' <= a[i] && a[i] <= 'z' || 'A' <= a[i] && a[i] <= 'Z') {
ans[cnt] += a[i];
j++;
} else {
len[cnt] = j;
cnt++;
mx = max(mx, j);
j = 0;
}
}
string date;
for (int i = 0; i < cnt; i++) {
if (len[i] == mx) {
date = ans[i];
break;
}
}
sort(ans, ans + cnt);
fill(len, len + 50, 0);
string mx_date = ans[0];
ans[cnt] = ' ';
mx = 0;
for (int i = 1; i <= cnt; i++) {
if (mx_date == ans[i]) {
mx++;
} else {
mx_date = ans[i];
len[i - 1] = mx;
mx = 0;
}
}
for (int i = 0; i < cnt; i++) {
mx = max(mx, len[i]);
}
for (int i = 0; i < cnt; i++) {
if (len[i] == mx) {
cout << ans[i] << ' ' << date << endl;
break;
}
}
return 0;
} | replace | 11 | 13 | 11 | 13 | 0 | |
p00030 | C++ | Runtime Error | #include <algorithm>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int A[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
int cunt = 0;
void depth(int n, int s, int i) {
if (n == 0 && s == 0) {
cunt++;
return;
} else if (n == 0)
return;
else if (s < 0)
return;
else if (i == 10)
return;
depth(n - 1, s - A[i], ++i);
depth(n, s, ++i);
}
int main() {
int n, s;
while (cin >> n >> s) {
if (n == 0 && s == 0)
break;
depth(n, s, 0);
cout << cunt << endl;
cunt = 0;
}
return 0;
} | #include <algorithm>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int A[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
int cunt = 0;
void depth(int n, int s, int i) {
if (n == 0 && s == 0) {
cunt++;
return;
} else if (n == 0)
return;
else if (s < 0)
return;
else if (i == 10)
return;
depth(n - 1, s - A[i], i + 1);
depth(n, s, i + 1);
}
int main() {
int n, s;
while (cin >> n >> s) {
if (n == 0 && s == 0)
break;
depth(n, s, 0);
cout << cunt << endl;
cunt = 0;
}
return 0;
} | replace | 25 | 27 | 25 | 27 | -11 | |
p00030 | C++ | Runtime Error |
#include <algorithm>
#include <cctype>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
int a[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
int n, s;
int count_2;
void dfs(int step, int i, int sum) {
if (sum > s || step > n)
return;
if (step == n && i == 10 && sum == s) {
count_2++;
return;
}
dfs(step, i + 1, sum);
dfs(step + 1, i + 1, sum + a[i]);
return;
}
int main() {
while (cin >> n >> s) {
if (n == 0 && s == 0)
break;
else {
count_2 = 0;
dfs(0, 0, 0);
}
cout << count_2 << endl;
}
// while(1);
return 0;
}
|
#include <algorithm>
#include <cctype>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
int a[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
int n, s;
int count_2;
void dfs(int step, int i, int sum) {
if (sum > s || step > n)
return;
if (i == 10) {
if (step == n && i == 10 && sum == s) {
count_2++;
return;
} else
return;
}
dfs(step, i + 1, sum);
dfs(step + 1, i + 1, sum + a[i]);
return;
}
int main() {
while (cin >> n >> s) {
if (n == 0 && s == 0)
break;
else {
count_2 = 0;
dfs(0, 0, 0);
}
cout << count_2 << endl;
}
// while(1);
return 0;
}
| replace | 25 | 28 | 25 | 31 | -11 | |
p00030 | C++ | Time Limit Exceeded | #include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
const int INF = 1 << 29;
typedef long long ll;
typedef pair<int, int> PI;
int n, s, t, res;
void dfs(int n, int t, int sum) {
if (n == 0 && sum == s) {
res++;
return;
}
if (sum > s || n <= 0 || t > s - sum)
return;
for (int i = t + 1; i <= s; ++i) {
dfs(n - 1, i, sum + i - 1);
}
}
int main(void) {
while (cin >> n >> s, n | s) {
if (n == 0 && s == 0)
break;
res = 0;
int ans;
dfs(n, 0, 0);
cout << res << endl;
}
return 0;
} | #include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
const int INF = 1 << 29;
typedef long long ll;
typedef pair<int, int> PI;
int n, s, t, res;
void dfs(int n, int t, int sum) {
if (n == 0 && sum == s) {
res++;
return;
}
if (sum > s || n <= 0 || t > s - sum)
return;
for (int i = t + 1; i <= 10; ++i) {
dfs(n - 1, i, sum + i - 1);
}
}
int main(void) {
while (cin >> n >> s, n | s) {
if (n == 0 && s == 0)
break;
res = 0;
int ans;
dfs(n, 0, 0);
cout << res << endl;
}
return 0;
} | replace | 40 | 41 | 40 | 41 | TLE | |
p00030 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cmath>
#include <fstream>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
using namespace std;
int cnt_sum_s(int n, int k, int s, int tmp_sum) {
if (n == 0) {
return (tmp_sum == s) ? 1 : 0;
}
int res = 0;
for (int i = k + 1; i < 10; i++) {
res += cnt_sum_s(n - 1, i, s, tmp_sum + i);
}
return res;
}
int main() {
ifstream cin("../test.txt");
while (true) {
int n, s;
cin >> n >> s;
if (!(n | s))
break;
int res = cnt_sum_s(n, -1, s, 0);
cout << res << endl;
}
} | #include <algorithm>
#include <cmath>
#include <fstream>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
using namespace std;
int cnt_sum_s(int n, int k, int s, int tmp_sum) {
if (n == 0) {
return (tmp_sum == s) ? 1 : 0;
}
int res = 0;
for (int i = k + 1; i < 10; i++) {
res += cnt_sum_s(n - 1, i, s, tmp_sum + i);
}
return res;
}
int main() {
// ifstream cin("../test.txt");
while (true) {
int n, s;
cin >> n >> s;
if (!(n | s))
break;
int res = cnt_sum_s(n, -1, s, 0);
cout << res << endl;
}
} | replace | 23 | 24 | 23 | 24 | TLE | |
p00030 | C++ | Time Limit Exceeded | #include <iostream>
using namespace std;
int n, s;
int recursion(int sum, int num, int cnt) {
if (sum > s || cnt > n)
return 0;
if (cnt == n && sum == s)
return 1;
if (num > s)
return 0;
int hoge = 0;
hoge += recursion(sum + num, num + 1, cnt + 1);
hoge += recursion(sum, num + 1, cnt);
return hoge;
}
int main() {
while (cin >> n >> s, n || s) {
cout << recursion(0, 0, 0) << endl;
}
} | #include <iostream>
using namespace std;
int n, s;
int recursion(int sum, int num, int cnt) {
if (sum > s || cnt > n)
return 0;
if (cnt == n && sum == s)
return 1;
if (num > 9)
return 0;
int hoge = 0;
hoge += recursion(sum + num, num + 1, cnt + 1);
hoge += recursion(sum, num + 1, cnt);
return hoge;
}
int main() {
while (cin >> n >> s, n || s) {
cout << recursion(0, 0, 0) << endl;
}
} | replace | 10 | 11 | 10 | 11 | TLE | |
p00030 | C++ | Time Limit Exceeded | #include <iostream>
using namespace std;
int a;
int f(int n, int s, int i) {
if (n == 1 && i >= s && s >= 0) {
a++;
return 0;
}
if (s <= 0)
return 0;
for (int j = i; j >= n - 1; j--)
f(n - 1, s - j, j - 1);
}
int main() {
int n, s;
while (cin >> n >> s) {
a = 0;
if (n == 0 && s == 0)
break;
f(n, s, 9);
cout << a << endl;
}
return 0;
} | #include <iostream>
using namespace std;
int a;
int f(int n, int s, int i) {
if (n == 1 && i >= s && s >= 0) {
a++;
return 0;
}
if (s <= 0 || s >= i * n)
return 0;
for (int j = i; j >= n - 1; j--)
f(n - 1, s - j, j - 1);
}
int main() {
int n, s;
while (cin >> n >> s) {
a = 0;
if (n == 0 && s == 0)
break;
f(n, s, 9);
cout << a << endl;
}
return 0;
} | replace | 9 | 10 | 9 | 10 | TLE | |
p00030 | C++ | Time Limit Exceeded | #include <cstring>
#include <iostream>
#include <vector>
using namespace std;
int n, s, *num, pattern;
void search(int th) {
if (th == n) {
int sum = 0;
for (int i = 0; i < n; i++)
sum += num[i];
if (s == sum) {
for (int j = 0; j + 1 < n; j++)
if (num[j] >= num[j + 1])
return;
/*
for (int j = 0; j < n; j++)
cout << num[j];
cout << endl;
*/
pattern++;
}
} else {
for (int i = 0; i < 10; i++) {
num[th] = i;
search(th + 1);
}
}
}
int main(int argc, char *argv[]) {
vector<int> result;
while (true) {
cin >> n >> s;
if (n == 0 && s == 0)
break;
num = new int[n];
memset(num, 0, sizeof(int) * n);
pattern = 0;
search(0);
result.push_back(pattern);
}
for (int i = 0; i < result.size(); i++)
cout << result[i] << endl;
return 0;
} | #include <cstring>
#include <iostream>
#include <vector>
using namespace std;
int n, s, *num, pattern;
void search(int th) {
if (th == n) {
int sum = 0;
for (int i = 0; i < n; i++)
sum += num[i];
if (s == sum) {
for (int j = 0; j + 1 < n; j++)
if (num[j] >= num[j + 1])
return;
/*
for (int j = 0; j < n; j++)
cout << num[j];
cout << endl;
*/
pattern++;
}
} else {
int start = 0;
if (th > 0)
start = num[th - 1] + 1;
for (int i = start; i < 10; i++) {
num[th] = i;
search(th + 1);
}
}
}
int main(int argc, char *argv[]) {
vector<int> result;
while (true) {
cin >> n >> s;
if (n == 0 && s == 0)
break;
num = new int[n];
memset(num, 0, sizeof(int) * n);
pattern = 0;
search(0);
result.push_back(pattern);
}
for (int i = 0; i < result.size(); i++)
cout << result[i] << endl;
return 0;
} | replace | 24 | 25 | 24 | 28 | TLE | |
p00030 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL << 30)
#define LLINF (1LL << 60)
#define PI 3.14159265359
#define EPS 1e-12
#define int ll
int dp[105][10][10], s, n;
int f(int a, int b, int c) {
if (dp[a][b][c] != -1)
return dp[a][b][c];
if (a == s && c == n && b <= 10)
return 1;
if (a > s || c > n || b == 10)
return 0;
int res = 0;
res += f(a + b, b + 1, c + 1);
res += f(a, b + 1, c);
return dp[a][b][c] = res;
}
signed main(void) {
while (1) {
cin >> n >> s;
REP(i, 105) REP(j, 10) REP(k, 10) dp[i][j][k] = -1;
cout << f(0, 0, 0) << endl;
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL << 30)
#define LLINF (1LL << 60)
#define PI 3.14159265359
#define EPS 1e-12
#define int ll
int dp[105][10][10], s, n;
int f(int a, int b, int c) {
if (dp[a][b][c] != -1)
return dp[a][b][c];
if (a == s && c == n && b <= 10)
return 1;
if (a > s || c > n || b == 10)
return 0;
int res = 0;
res += f(a + b, b + 1, c + 1);
res += f(a, b + 1, c);
return dp[a][b][c] = res;
}
signed main(void) {
while (1) {
cin >> n >> s;
if (!n && !s)
break;
REP(i, 105) REP(j, 10) REP(k, 10) dp[i][j][k] = -1;
cout << f(0, 0, 0) << endl;
}
return 0;
} | insert | 39 | 39 | 39 | 41 | TLE | |
p00030 | C++ | Runtime Error | #include <stdio.h>
#include <string.h>
int dp[20][55][20];
int cnt_sum(int n, int s, int x) {
if (dp[n][s][x] != -1) {
return dp[n][s][x];
}
if (n == 0 && s == 0) {
return (1);
}
if (x > 9) {
return (0);
}
return dp[n][s][x] = (cnt_sum(n - 1, s - x, x + 1) + cnt_sum(n, s, x + 1));
}
int main() {
int n, s;
memset(dp, -1, sizeof(dp));
while (1) {
scanf("%d %d", &n, &s);
if (n == 0 && s == 0) {
break;
}
if (n >= 11 || s >= 46)
printf("0\n");
else
printf("%d\n", cnt_sum(n, s, 0));
}
return 0;
} | #include <stdio.h>
#include <string.h>
int dp[20][55][20];
int cnt_sum(int n, int s, int x) {
if (n < 0 || s < 0) {
return 0;
}
if (dp[n][s][x] != -1) {
return dp[n][s][x];
}
if (n == 0 && s == 0) {
return (1);
}
if (x > 9) {
return (0);
}
return dp[n][s][x] = (cnt_sum(n - 1, s - x, x + 1) + cnt_sum(n, s, x + 1));
}
int main() {
int n, s;
memset(dp, -1, sizeof(dp));
while (1) {
scanf("%d %d", &n, &s);
if (n == 0 && s == 0) {
break;
}
if (n >= 11 || s >= 46)
printf("0\n");
else
printf("%d\n", cnt_sum(n, s, 0));
}
return 0;
} | insert | 6 | 6 | 6 | 9 | 0 | |
p00030 | C++ | Runtime Error | #include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int dp[16][64];
int main() {
dp[0][0] = 1;
rep(k, 10) {
for (int i = 10; i >= 0; i--) {
rep(j, 64) if (dp[i][j]) dp[i + 1][j + k] += dp[i][j];
}
}
for (;;) {
int n, s;
scanf("%d%d", &n, &s);
if (n == 0 && s == 0)
return 0;
printf("%d\n", dp[n][s]);
}
} | #include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int dp[16][64];
int main() {
dp[0][0] = 1;
rep(k, 10) {
for (int i = 10; i >= 0; i--) {
rep(j, 64) if (dp[i][j]) dp[i + 1][j + k] += dp[i][j];
}
}
for (;;) {
int n, s;
scanf("%d%d", &n, &s);
if (n == 0 && s == 0)
return 0;
printf("%d\n", n < 16 && s < 64 ? dp[n][s] : 0);
}
} | replace | 17 | 18 | 17 | 18 | 0 | |
p00030 | C++ | Time Limit Exceeded | #define _CRT_SECURE_NO_WARNINGS
#include <iomanip>
#include <iostream>
#include <list>
#include <math.h>
#include <stack>
#include <string>
using namespace std;
int n = 0;
int s = 0;
static int ans;
void check(int atai, int num, int count) {
if (num > s || atai > s) {
if (count == n && atai == s) {
ans++;
}
return;
}
check(atai + num, num + 1, count + 1);
check(atai, num + 1, count);
}
int main(int argc, char **argv) {
while (cin >> n >> s) {
ans = 0;
if (n == 0 && s == 0) {
break;
}
check(0, 0, 0);
cout << ans << endl;
}
} | #define _CRT_SECURE_NO_WARNINGS
#include <iomanip>
#include <iostream>
#include <list>
#include <math.h>
#include <stack>
#include <string>
using namespace std;
int n = 0;
int s = 0;
static int ans;
void check(int atai, int num, int count) {
if (num > 9) {
if (atai == s && count == n) {
ans++;
}
return;
}
check(atai + num, num + 1, count + 1);
check(atai, num + 1, count);
}
int main(int argc, char **argv) {
while (cin >> n >> s) {
ans = 0;
if (n == 0 && s == 0) {
break;
}
check(0, 0, 0);
cout << ans << endl;
}
} | replace | 16 | 18 | 16 | 18 | TLE | |
p00030 | C++ | Runtime Error | #include <iostream>
using namespace std;
int dp[11][46] = {0};
int main() {
dp[0][0] = 1;
for (int k = 0; k < 10; k++) {
for (int i = k; i >= 0; i--)
for (int j = 0; j < 46 - k; j++) {
dp[i + 1][j + k] += dp[i][j];
}
}
int N, S;
while (cin >> N >> S, N || S) {
cout << dp[N][S] << endl;
}
} | #include <iostream>
using namespace std;
int dp[11][46] = {0};
int main() {
dp[0][0] = 1;
for (int k = 0; k < 10; k++) {
for (int i = k; i >= 0; i--)
for (int j = 0; j < 46 - k; j++) {
dp[i + 1][j + k] += dp[i][j];
}
}
int N, S;
while (cin >> N >> S, N || S) {
if (0 <= N && N < 11 && 0 <= S && S < 46) {
cout << dp[N][S] << endl;
} else {
cout << 0 << endl;
}
}
} | replace | 16 | 17 | 16 | 21 | 0 | |
p00030 | C++ | Time Limit Exceeded | #include <iostream>
using namespace std;
int n, s;
int dfs(int i, int c, int sum) {
int res = 0;
if (c + 10 - i < n || s < sum)
return 0;
if (c == n && sum == s)
return 1;
res += dfs(i + 1, c, sum);
res += dfs(i + 1, c + 1, sum + i);
return res;
}
int main() {
while (cin >> n >> s, n || s)
cout << dfs(0, 0, 0) << endl;
return 0;
} | #include <iostream>
using namespace std;
int n, s;
int dfs(int i, int c, int sum) {
int res = 0;
if (n < c || c + 10 - i < n || s < sum)
return 0;
if (c == n && sum == s)
return 1;
res += dfs(i + 1, c, sum);
res += dfs(i + 1, c + 1, sum + i);
return res;
}
int main() {
while (cin >> n >> s, n || s)
cout << dfs(0, 0, 0) << endl;
return 0;
} | replace | 7 | 8 | 7 | 8 | TLE | |
p00030 | C++ | Runtime Error | #include <iostream>
using namespace std;
int main() {
int n, s, j, k;
int a[11][46];
for (int s = 0; s < 46; s++)
for (int n = 0; n < 11; n++)
a[n][s] = 0;
n = s = 0;
for (int i = 0; i < 1024; i++) {
for (j = i, n = 0; j > 0; j /= 2)
n += j % 2;
for (j = i, s = 0, k = 0; j > 0; j /= 2, k++)
s += j % 2 * k;
a[n][s]++;
}
while (true) {
cin >> n >> s;
if (!n && !s)
break;
cout << a[n][s] << endl;
}
return 0;
}
// for(cin>>n>>s;n||s;cout<<a[n][s]<<endl,cin>>n>>s); | #include <iostream>
using namespace std;
int main() {
int n, s, j, k;
int a[11][46];
for (int s = 0; s < 46; s++)
for (int n = 0; n < 11; n++)
a[n][s] = 0;
n = s = 0;
for (int i = 0; i < 1024; i++) {
for (j = i, n = 0; j > 0; j /= 2)
n += j % 2;
for (j = i, s = 0, k = 0; j > 0; j /= 2, k++)
s += j % 2 * k;
a[n][s]++;
}
while (true) {
cin >> n >> s;
if (!n && !s)
break;
if (s < 46)
cout << a[n][s] << endl;
else
cout << 0 << endl;
}
return 0;
}
// for(cin>>n>>s;n||s;cout<<a[n][s]<<endl,cin>>n>>s); | replace | 20 | 21 | 20 | 24 | 0 | |
p00031 | C++ | Runtime Error | #include <iostream>
#include <vector>
using namespace std;
int main() {
int weight[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
int gram;
vector<int> ans;
while (cin >> gram) {
for (int i = 9; i >= 0; i--) {
if (gram >= weight[i]) {
ans.push_back(i);
gram -= weight[i];
}
}
for (size_t i = ans.size() - 1; i >= 0; i--) {
cout << weight[ans[i]];
if (i != 0)
cout << ' ';
}
cout << endl;
ans.clear();
}
return 0;
} | #include <iostream>
#include <vector>
using namespace std;
int main() {
int weight[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
int gram;
vector<int> ans;
while (cin >> gram) {
for (int i = 9; i >= 0; i--) {
if (gram >= weight[i]) {
ans.push_back(i);
gram -= weight[i];
}
}
for (int i = ans.size() - 1; i >= 0; i--) {
cout << weight[ans[i]];
if (i != 0)
cout << ' ';
}
cout << endl;
ans.clear();
}
return 0;
} | replace | 17 | 18 | 17 | 18 | -11 | |
p00031 | C++ | Runtime Error | #include <stdio.h>
#include <string.h>
int main(void) {
char line[80];
int w;
int f[10];
int u[10];
int k = 512;
for (int &d : f) {
d = k;
k >>= 1;
}
while (true) {
if (fgets(line, sizeof line, stdin) == NULL) {
break;
}
if (sscanf(line, "%d", &w) != 1) {
break;
}
int p;
for (p = 0; p < 10; p++) {
if (w > f[p]) {
break;
}
}
memset(u, 0, sizeof u);
int t = f[p];
u[p] = 1;
p++;
while (true) {
if (t == w) {
break;
} else if (t > w) {
t -= f[p - 1];
u[p - 1] = 0;
}
t += f[p];
u[p] = 1;
p++;
}
const char *sp = "";
for (int i = 9; i >= 0; i--) {
if (u[i]) {
printf("%s%d", sp, f[i]);
if (*sp == 0) {
sp = " ";
}
}
}
printf("\n");
}
return 0;
} | #include <stdio.h>
#include <string.h>
int main(void) {
char line[80];
int w;
int f[10];
int u[10];
int k = 512;
for (int &d : f) {
d = k;
k >>= 1;
}
while (true) {
if (fgets(line, sizeof line, stdin) == NULL) {
break;
}
if (sscanf(line, "%d", &w) != 1) {
break;
}
int p;
for (p = 0; p < 10; p++) {
if (w >= f[p]) {
break;
}
}
memset(u, 0, sizeof u);
int t = f[p];
u[p] = 1;
p++;
while (true) {
if (t == w) {
break;
} else if (t > w) {
t -= f[p - 1];
u[p - 1] = 0;
}
t += f[p];
u[p] = 1;
p++;
}
const char *sp = "";
for (int i = 9; i >= 0; i--) {
if (u[i]) {
printf("%s%d", sp, f[i]);
if (*sp == 0) {
sp = " ";
}
}
}
printf("\n");
}
return 0;
} | replace | 27 | 28 | 27 | 28 | 0 | |
p00031 | C++ | Time Limit Exceeded | #include <cstdio>
int main() {
int n, s;
while (scanf("%d", &n)) {
for (s = 1; n; s *= 2) {
n &s &&printf("%d%c", s, n - s ? 32 : 10);
n -= n & s;
}
}
} | #include <cstdio>
int main() {
int n, s;
while (scanf("%d", &n) + 1) {
for (s = 1; n; s *= 2) {
n &s &&printf("%d%c", s, n - s ? 32 : 10);
n -= n & s;
}
}
} | replace | 3 | 4 | 3 | 4 | TLE | |
p00031 | C++ | Time Limit Exceeded | #include <iostream>
using namespace std;
int main() {
int w;
while (cin >> w) {
bool flag = 0;
for (int i = 1; w >= 0; i *= 2) {
if (w % 2 > 0) {
if (flag) {
cout << ' ';
}
cout << i;
flag = 1;
w--;
}
w /= 2;
}
cout << endl;
}
return 0;
}
| #include <iostream>
using namespace std;
int main() {
int w;
while (cin >> w) {
bool flag = 0;
for (int i = 1; w > 0; i *= 2) {
if (w % 2 > 0) {
if (flag) {
cout << ' ';
}
cout << i;
flag = 1;
w--;
}
w /= 2;
}
cout << endl;
}
return 0;
}
| replace | 6 | 7 | 6 | 7 | TLE | |
p00031 | C++ | Runtime Error | #include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int inf = 1000000000;
int main(void) {
int n;
while (cin >> n) {
cerr << n << endl;
if (n == 0)
break;
int a = 1024;
vector<int> b;
while (a != 0) {
if (n / a != 0) {
n %= a;
b.push_back(a);
}
a /= 2;
}
for (int i = 0; i < b.size(); i++) {
if (i != b.size() - 1)
cout << b[b.size() - 1 - i] << " ";
else
cout << b[b.size() - 1 - i] << endl;
}
}
return 0;
}
// EOF | #include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int inf = 1000000000;
int main(void) {
int n;
while (cin >> n) {
if (n == 0)
break;
int a = 1024;
vector<int> b;
while (a != 0) {
if (n / a != 0) {
n %= a;
b.push_back(a);
}
a /= 2;
}
for (int i = 0; i < b.size(); i++) {
if (i != b.size() - 1)
cout << b[b.size() - 1 - i] << " ";
else
cout << b[b.size() - 1 - i] << endl;
}
}
return 0;
}
// EOF | delete | 20 | 21 | 20 | 20 | 0 | 5
7
127
|
p00031 | Python | Runtime Error | while True:
g = int(input())
now = 512
ans = []
while True:
if g == 0:
break
elif g >= now:
g -= now
ans.append(now)
now //= 2
temp = ""
for i in ans[::-1]:
temp += str(i) + " "
print(temp[:-1])
| import sys
for line in sys.stdin:
g = int(line)
now = 512
ans = []
while True:
if g == 0:
break
elif g >= now:
g -= now
ans.append(now)
now //= 2
temp = ""
for i in ans[::-1]:
temp += str(i) + " "
print(temp[:-1])
| replace | 0 | 2 | 0 | 4 | EOFError: EOF when reading a line | Traceback (most recent call last):
File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p00031/Python/s012591157.py", line 2, in <module>
g = int(input())
EOFError: EOF when reading a line
|
p00032 | C++ | Time Limit Exceeded | #define _USE_MATH_DEFINES
#include <algorithm>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int main() {
int x = 0, y = 0;
int a, b, c;
char comma;
while (cin >> a >> comma >> b >> comma >> c, a != 0) {
if (pow(a, 2) + pow(b, 2) == pow(c, 2))
x++;
if (pow(a, 2) - pow(double(c) / 2, 2) == pow(b, 2) - pow(double(c) / 2, 2))
y++;
}
cout << x << endl;
cout << y << endl;
} | #define _USE_MATH_DEFINES
#include <algorithm>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int main() {
int x = 0, y = 0;
int a, b, c;
char comma;
while (scanf("%d,%d,%d", &a, &b, &c) != EOF) {
if (pow(a, 2) + pow(b, 2) == pow(c, 2))
x++;
if (pow(a, 2) - pow(double(c) / 2, 2) == pow(b, 2) - pow(double(c) / 2, 2))
y++;
}
cout << x << endl;
cout << y << endl;
} | replace | 19 | 20 | 19 | 20 | TLE | |
p00032 | C++ | Time Limit Exceeded | #include <stdio.h>
int main() {
int l1, l2, dia, rc, lc;
rc = lc = 0;
while (scanf("%d %d %d", &l1, &l2, &dia) != EOF) {
if (l1 * l1 + l2 * l2 == dia * dia) {
rc++;
}
if (l1 == l2) {
lc++;
}
}
printf("%d\n%d\n", rc, lc);
return 0;
} | #include <stdio.h>
int main() {
int l1, l2, dia, rc, lc;
rc = lc = 0;
while (scanf("%d,%d,%d", &l1, &l2, &dia) != EOF) {
if (l1 * l1 + l2 * l2 == dia * dia) {
rc++;
}
if (l1 == l2) {
lc++;
}
}
printf("%d\n%d\n", rc, lc);
return 0;
} | replace | 5 | 6 | 5 | 6 | TLE | |
p00032 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int main() {
int a, b, c, t = 0, h = 0;
while (scanf("%d,%d,%d", &a, &b, &c)) {
if (a * a + b * b == c * c) {
t++;
} else if (a == b) {
h++;
}
}
cout << t << endl << h << endl;
} | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int main() {
int a, b, c, t = 0, h = 0;
while (scanf("%d,%d,%d", &a, &b, &c) != EOF) {
if (a * a + b * b == c * c) {
t++;
} else if (a == b) {
h++;
}
}
cout << t << endl << h << endl;
} | replace | 14 | 15 | 14 | 15 | TLE | |
p00032 | C++ | Time Limit Exceeded | #include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
int main() {
int n, m, d, r = 0, l = 0;
char c;
while (cin >> n >> c >> m >> c >> d, n) {
if (n == m)
l++;
if (n * n + m * m == d * d)
r++;
}
cout << r << endl << l << endl;
return 0;
} | #include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
int main() {
int n, m, d, r = 0, l = 0;
char c;
while (cin >> n >> c >> m >> c >> d) {
if (n == m)
l++;
if (n * n + m * m == d * d)
r++;
}
cout << r << endl << l << endl;
return 0;
} | replace | 8 | 9 | 8 | 9 | TLE | |
p00032 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int, int> pii;
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define REPR(i, n) for (ll i = 1; i < n; ++i)
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define DEBUG(x) cout << #x << ": " << x << endl
#define DEBUG_VEC(v) \
cout << #v << ":"; \
REP(i, v.size()) cout << " " << v[i]; \
cout << endl
#define ALL(a) (a).begin(), (a).end()
#define MOD (ll)(1e9 + 7)
#define ADD(a, b) a = ((a) + (b)) % MOD
#define FIX(a) ((a) % MOD + MOD) % MOD
int main() {
int a, b, c;
int x = 0, y = 0;
while (~scanf("%d%d%d", &a, &b, &c)) {
if (a * a + b * b == c * c)
++x;
if (a == b)
++y;
}
cout << x << endl;
cout << y << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int, int> pii;
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define REPR(i, n) for (ll i = 1; i < n; ++i)
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define DEBUG(x) cout << #x << ": " << x << endl
#define DEBUG_VEC(v) \
cout << #v << ":"; \
REP(i, v.size()) cout << " " << v[i]; \
cout << endl
#define ALL(a) (a).begin(), (a).end()
#define MOD (ll)(1e9 + 7)
#define ADD(a, b) a = ((a) + (b)) % MOD
#define FIX(a) ((a) % MOD + MOD) % MOD
int main() {
int a, b, c;
int x = 0, y = 0;
while (~scanf("%d,%d,%d", &a, &b, &c)) {
if (a * a + b * b == c * c)
++x;
if (a == b)
++y;
}
cout << x << endl;
cout << y << endl;
return 0;
} | replace | 27 | 28 | 27 | 28 | TLE | |
p00032 | C++ | Time Limit Exceeded | #define scanf_s scanf
// #define gets_s gets
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
using namespace std;
#define MAX 10
#define MIN -100001
#define _MAX 10
int main(void) {
int a, b, c, s = 0, h = 0;
while (scanf_s("%d,%d,%d", &a, &b, &c)) {
if (a == b)
++h;
else if (c * c == a * a + b * b) {
++s;
}
}
printf("%d\n%d\n", s, h);
} | #define scanf_s scanf
// #define gets_s gets
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
using namespace std;
#define MAX 10
#define MIN -100001
#define _MAX 10
int main(void) {
int a, b, c, s = 0, h = 0;
while (scanf_s("%d,%d,%d", &a, &b, &c) != EOF) {
if (a == b)
++h;
else if (c * c == a * a + b * b) {
++s;
}
}
printf("%d\n%d\n", s, h);
} | replace | 12 | 13 | 12 | 13 | TLE | |
p00032 | C++ | Time Limit Exceeded | #include <cstdio>
#include <iostream>
using namespace std;
int main() {
int ans_a = 0, ans_b = 0;
for (;;) {
int a, b, c;
scanf("%d,%d,%d", &a, &b, &c);
if (a * a + b * b == c * c) {
ans_a++;
}
if (a == b) {
ans_b++;
}
}
cout << ans_a << endl << ans_b << endl;
return 0;
} | #include <cstdio>
#include <iostream>
using namespace std;
int main() {
int ans_a = 0, ans_b = 0;
for (;;) {
int a, b, c;
if (scanf("%d,%d,%d", &a, &b, &c) == EOF) {
break;
}
if (a * a + b * b == c * c) {
ans_a++;
}
if (a == b) {
ans_b++;
}
}
cout << ans_a << endl << ans_b << endl;
return 0;
} | replace | 7 | 8 | 7 | 10 | TLE | |
p00032 | C++ | Time Limit Exceeded | #include <cstdio>
using namespace std;
int main() {
int side[3];
int iso = 0, cho = 0;
while (scanf("%d,%d,%d", &side[0], &side[1], &side[2])) {
if (side[0] == side[1])
iso++;
else if ((side[0] * side[0]) + (side[1] * side[1]) == (side[2] * side[2]))
cho++;
}
printf("%d\n", cho);
printf("%d\n", iso);
return 0;
} | #include <cstdio>
using namespace std;
int main() {
int side[3];
int iso = 0, cho = 0;
while (scanf("%d,%d,%d", &side[0], &side[1], &side[2]) != EOF) {
if (side[0] == side[1])
iso++;
else if ((side[0] * side[0]) + (side[1] * side[1]) == (side[2] * side[2]))
cho++;
}
printf("%d\n", cho);
printf("%d\n", iso);
return 0;
} | replace | 7 | 8 | 7 | 8 | TLE | |
p00032 | C++ | Time Limit Exceeded | #include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
int main() {
int a, b, c, sum1, sum2;
sum1 = 0;
sum2 = 0;
while (scanf("%d,%d,%d", &a, &b, &c)) {
if (a * a + b * b == c * c) {
sum1 += 1;
}
if (a == b) {
sum2 += 1;
}
}
cout << sum1 << endl;
cout << sum2 << endl;
return 0;
} | #include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
int main() {
int a, b, c, sum1, sum2;
sum1 = 0;
sum2 = 0;
while (scanf("%d,%d,%d", &a, &b, &c) != EOF) {
if (a * a + b * b == c * c) {
sum1 += 1;
}
if (a == b) {
sum2 += 1;
}
}
cout << sum1 << endl;
cout << sum2 << endl;
return 0;
} | replace | 11 | 12 | 11 | 12 | TLE | |
p00032 | C++ | Time Limit Exceeded | #include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <stdio.h>
#include <string>
#include <vector>
#define p(n) pow(n, 2)
using namespace std;
int main() {
int a, b, c, rhom = 0, rect = 0;
while (scanf("%d,%d,%d", &a, &b, &c)) {
if (p(a) + p(b) == p(c))
rect++;
if (a == b)
rhom++;
}
cout << rect << endl << rhom << endl;
return 0;
} | #include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <stdio.h>
#include <string>
#include <vector>
#define p(n) pow(n, 2)
using namespace std;
int main() {
int a, b, c, rhom = 0, rect = 0;
while (scanf("%d,%d,%d", &a, &b, &c) != EOF) {
if (p(a) + p(b) == p(c))
rect++;
if (a == b)
rhom++;
}
cout << rect << endl << rhom << endl;
return 0;
} | replace | 11 | 12 | 11 | 12 | TLE | |
p00032 | C++ | Time Limit Exceeded | #include <cstdio>
#include <iostream>
using namespace std;
int main() {
int a, b, c;
int t = 0, h = 0;
while (scanf("%d,%d,%d", &a, &b, &c)) {
// if(a==0)break;
if (a == b)
h++;
if (c * c == a * a + b * b)
t++;
}
cout << t << endl << h << endl;
}
| #include <cstdio>
#include <iostream>
using namespace std;
int main() {
int a, b, c;
int t = 0, h = 0;
while (scanf("%d,%d,%d", &a, &b, &c) + 1) {
// if(a==0)break;
if (a == b)
h++;
if (c * c == a * a + b * b)
t++;
}
cout << t << endl << h << endl;
}
| replace | 6 | 7 | 6 | 7 | TLE | |
p00032 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
int main(void) {
int a, b, c;
int x = 0, y = 0;
while (scanf("%d,%d,%d", &a, &b, &c)) {
if (a * a + b * b == c * c) {
x++;
// cout<<a<<b<<c<<endl;
}
if (a == b) {
y++;
// cout<<a<<b<<c<<'.'<<endl;
}
}
cout << x << endl << y << endl;
return 0;
} | #include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
int main(void) {
int a, b, c;
int x = 0, y = 0;
while (scanf("%d,%d,%d", &a, &b, &c) != EOF) {
if (a * a + b * b == c * c) {
x++;
// cout<<a<<b<<c<<endl;
}
if (a == b) {
y++;
// cout<<a<<b<<c<<'.'<<endl;
}
}
cout << x << endl << y << endl;
return 0;
} | replace | 10 | 11 | 10 | 11 | TLE | |
p00033 | C++ | Runtime Error | #include <cstdio>
#define N 10
int D, Ball[N];
int R, L;
bool solve(int i) {
if (i == N)
return true;
if (R < Ball[i]) {
R = Ball[i];
if (solve(i + 1))
return true;
}
if (L < Ball[i]) {
L = Ball[i];
if (solve(i + 1))
return true;
}
return false;
}
int main() {
scanf("%d", D);
for (int i = 0; i < D; i++) {
R = L = 0;
for (int j = 0; j < N; j++)
scanf("%d", &Ball[j]);
R = Ball[0];
if (solve(1))
printf("YES\n");
else
printf("NO\n");
}
return 0;
} | #include <cstdio>
#define N 10
int D, Ball[N];
int R, L;
bool solve(int i) {
if (i == N)
return true;
if (R < Ball[i]) {
R = Ball[i];
if (solve(i + 1))
return true;
}
if (L < Ball[i]) {
L = Ball[i];
if (solve(i + 1))
return true;
}
return false;
}
int main() {
scanf("%d", &D);
for (int i = 0; i < D; i++) {
R = L = 0;
for (int j = 0; j < N; j++)
scanf("%d", &Ball[j]);
R = Ball[0];
if (solve(1))
printf("YES\n");
else
printf("NO\n");
}
return 0;
} | replace | 24 | 25 | 24 | 25 | -11 | |
p00034 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
int main() {
int l[10], v1, v2;
int len;
while (scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", l, &l[1], &l[2], &l[3],
&l[4], &l[5], &l[6], &l[7], &l[8], &l[9], &v1, &v2)) {
len = 0;
for (int i = 0; i < 10; i++) {
len += l[i];
}
double t = (double)len / (v1 + v2);
double d = (double)v1 * t;
len = 0;
for (int i = 0; i < 10; i++) {
len += l[i];
if (d <= len) {
cout << i + 1 << endl;
break;
}
}
}
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int l[10], v1, v2;
int len;
while (scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", l, &l[1], &l[2], &l[3],
&l[4], &l[5], &l[6], &l[7], &l[8], &l[9], &v1, &v2) != EOF) {
len = 0;
for (int i = 0; i < 10; i++) {
len += l[i];
}
double t = (double)len / (v1 + v2);
double d = (double)v1 * t;
len = 0;
for (int i = 0; i < 10; i++) {
len += l[i];
if (d <= len) {
cout << i + 1 << endl;
break;
}
}
}
} | replace | 8 | 9 | 8 | 9 | TLE | |
p00034 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int inf = 1000000000;
int main(void) {
vector<int> l(10);
vector<int> v(2);
while (scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &l[0], &l[1], &l[2],
&l[3], &l[4], &l[5], &l[6], &l[7], &l[8], &l[9], &v[0], &v[1])) {
int sum = accumulate(l.begin(), l.end(), 0);
// cerr << sum << " ";
double tmp = sum * v[0] * 1.0 / (v[0] + v[1]);
// cerr << tmp << endl;
for (int i = 1; i < 10; i++)
l[i] += l[i - 1];
// int a = 0;
for (int i = 1; i < 10; i++) {
if (l[i - 1] == tmp) {
cout << i << endl;
break;
} else if (l[i - 1] < tmp && tmp < l[i]) {
// cerr << l[i-1] << " " << l[i] << endl;
cout << i + 1 << endl;
// break;
}
}
}
return 0;
}
// EOF | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int inf = 1000000000;
int main(void) {
vector<int> l(10);
vector<int> v(2);
while (scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &l[0], &l[1], &l[2],
&l[3], &l[4], &l[5], &l[6], &l[7], &l[8], &l[9], &v[0],
&v[1]) != EOF) {
int sum = accumulate(l.begin(), l.end(), 0);
// cerr << sum << " ";
double tmp = sum * v[0] * 1.0 / (v[0] + v[1]);
// cerr << tmp << endl;
for (int i = 1; i < 10; i++)
l[i] += l[i - 1];
// int a = 0;
for (int i = 1; i < 10; i++) {
if (l[i - 1] == tmp) {
cout << i << endl;
break;
} else if (l[i - 1] < tmp && tmp < l[i]) {
// cerr << l[i-1] << " " << l[i] << endl;
cout << i + 1 << endl;
// break;
}
}
}
return 0;
}
// EOF | replace | 21 | 22 | 21 | 23 | TLE | |
p00034 | C++ | Time Limit Exceeded | #include <iostream>
using namespace std;
int data[11];
int sum = 0;
bool input() {
fill(data, data + 11, 0);
char c;
int x;
for (int i = 1; i <= 10; i++) {
cin >> x;
cin >> c;
data[i] = data[i - 1] + x;
}
return true;
}
int main() {
while (input()) {
int v1, v2;
char c;
cin >> v1 >> c >> v2;
double t = 1. * data[10] / (v1 + v2);
for (int i = 1; i <= 10; i++) {
if (v1 * t <= data[i]) {
cout << i << endl;
break;
}
}
}
} | #include <iostream>
using namespace std;
int data[11];
int sum = 0;
bool input() {
fill(data, data + 11, 0);
char c;
int x;
for (int i = 1; i <= 10; i++) {
if (!(cin >> x))
return false;
cin >> c;
data[i] = data[i - 1] + x;
}
return true;
}
int main() {
while (input()) {
int v1, v2;
char c;
cin >> v1 >> c >> v2;
double t = 1. * data[10] / (v1 + v2);
for (int i = 1; i <= 10; i++) {
if (v1 * t <= data[i]) {
cout << i << endl;
break;
}
}
}
} | replace | 11 | 12 | 11 | 13 | TLE | |
p00034 | C++ | Time Limit Exceeded | #include <iostream>
#include <stdio.h>
using namespace std;
int main() {
int dis[10], v1, v2;
while (scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &dis[0], &dis[1], &dis[2],
&dis[3], &dis[4], &dis[5], &dis[6], &dis[7], &dis[8], &dis[9],
&v1, &v2)) {
int sum = 0;
for (int i = 0; i < 10; i++)
sum += dis[i];
double col = (double)sum * (double)v1 / (double)(v1 + v2);
// cout<<"col:"<<col<<endl;
sum = 0;
for (int i = 0; i < 10; i++) {
sum += dis[i];
if ((double)sum - col >= -0.000000001) {
sum = i;
break;
}
}
cout << sum + 1 << endl;
}
return 0;
} | #include <iostream>
#include <stdio.h>
using namespace std;
int main() {
int dis[10], v1, v2;
while (scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &dis[0], &dis[1], &dis[2],
&dis[3], &dis[4], &dis[5], &dis[6], &dis[7], &dis[8], &dis[9],
&v1, &v2) != EOF) {
int sum = 0;
for (int i = 0; i < 10; i++)
sum += dis[i];
double col = (double)sum * (double)v1 / (double)(v1 + v2);
// cout<<"col:"<<col<<endl;
sum = 0;
for (int i = 0; i < 10; i++) {
sum += dis[i];
if ((double)sum - col >= -0.000000001) {
sum = i;
break;
}
}
cout << sum + 1 << endl;
}
return 0;
} | replace | 7 | 8 | 7 | 8 | TLE | |
p00034 | C++ | Time Limit Exceeded | #include <algorithm>
#include <stdio.h>
using namespace std;
int pow(int a, int n) {
if (n <= 0) {
return 1;
}
return a * pow(a, n - 1);
}
int main() {
int v1, v2;
int a[10];
int sum1;
int sum2;
int ans = 0;
while (scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &a[0], &a[1], &a[2],
&a[3], &a[4], &a[5], &a[6], &a[7], &a[8], &a[9], &v1,
&v2) != 0) {
sum1 = 0;
sum2 = 0;
for (int i = 0; i < 10; i++) {
sum1 += a[i];
}
for (int i = 0; i < 10; i++) {
sum2 += a[i];
if (sum1 * v1 > sum2 * (v1 + v2)) {
ans = i + 2;
}
}
printf("%d\n", ans);
}
///////////////////////////////////
// Sleep(200000);///////////////////// 提出するときは必ず外す!
///////////////////////////////////
return 0;
} | #include <algorithm>
#include <stdio.h>
using namespace std;
int pow(int a, int n) {
if (n <= 0) {
return 1;
}
return a * pow(a, n - 1);
}
int main() {
int v1, v2;
int a[10];
int sum1;
int sum2;
int ans = 0;
while (scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &a[0], &a[1], &a[2],
&a[3], &a[4], &a[5], &a[6], &a[7], &a[8], &a[9], &v1,
&v2) != EOF) {
sum1 = 0;
sum2 = 0;
for (int i = 0; i < 10; i++) {
sum1 += a[i];
}
for (int i = 0; i < 10; i++) {
sum2 += a[i];
if (sum1 * v1 > sum2 * (v1 + v2)) {
ans = i + 2;
}
}
printf("%d\n", ans);
}
///////////////////////////////////
// Sleep(200000);///////////////////// 提出するときは必ず外す!
///////////////////////////////////
return 0;
} | replace | 19 | 20 | 19 | 20 | TLE | |
p00034 | C++ | Time Limit Exceeded | #include <ctype.h>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
using namespace std;
int main() {
double b[10];
double v1, v2;
while (scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &b[0], &b[1],
&b[2], &b[3], &b[4], &b[5], &b[6], &b[7], &b[8], &b[9], &v1,
&v2)) {
double l =
b[0] + b[1] + b[2] + b[3] + b[4] + b[5] + b[6] + b[7] + b[8] + b[9];
double t = l / (v1 + v2);
double l1 = t * v1;
for (int i = 0; i < 10; i++) {
l1 -= b[i];
if (l1 <= 0) {
cout << i + 1 << endl;
break;
}
}
}
return 0;
} | #include <ctype.h>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
using namespace std;
int main() {
double b[10];
double v1, v2;
while (scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &b[0], &b[1],
&b[2], &b[3], &b[4], &b[5], &b[6], &b[7], &b[8], &b[9], &v1,
&v2) != EOF) {
double l =
b[0] + b[1] + b[2] + b[3] + b[4] + b[5] + b[6] + b[7] + b[8] + b[9];
double t = l / (v1 + v2);
double l1 = t * v1;
for (int i = 0; i < 10; i++) {
l1 -= b[i];
if (l1 <= 0) {
cout << i + 1 << endl;
break;
}
}
}
return 0;
} | replace | 14 | 15 | 14 | 15 | TLE | |
p00034 | C++ | Time Limit Exceeded | #include <cstdio>
#include <iostream>
using namespace std;
int main(void) {
double line[10];
double v1, v2;
while (scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &line[0],
&line[1], &line[2], &line[3], &line[4], &line[5], &line[6],
&line[7], &line[8], &line[9], &v1, &v2)) {
double sum = 0;
for (int i = 0; i < 10; i++) {
sum += line[i];
}
double time = sum / (v1 + v2);
double dist = time * v1;
for (int i = 0; i < 10; i++) {
dist -= line[i];
if (dist <= 0) {
cout << i + 1 << endl;
break;
}
}
}
return 0;
} | #include <cstdio>
#include <iostream>
using namespace std;
int main(void) {
double line[10];
double v1, v2;
while (scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &line[0],
&line[1], &line[2], &line[3], &line[4], &line[5], &line[6],
&line[7], &line[8], &line[9], &v1, &v2) != EOF) {
double sum = 0;
for (int i = 0; i < 10; i++) {
sum += line[i];
}
double time = sum / (v1 + v2);
double dist = time * v1;
for (int i = 0; i < 10; i++) {
dist -= line[i];
if (dist <= 0) {
cout << i + 1 << endl;
break;
}
}
}
return 0;
} | replace | 11 | 12 | 11 | 12 | TLE | |
p00034 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cstdio>
#include <numeric>
using namespace std;
int main() {
int l[10], v1, v2, ret;
while (scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &l[0], &l[1], &l[2],
&l[3], &l[4], &l[5], &l[6], &l[7], &l[8], &l[9], &v1, &v2)) {
int sum = accumulate(l, l + 10, 0), k = 0;
double ret = ((double)v1 / (v1 + v2)) * sum;
for (int i = 0; i < 10; i++) {
if ((k += l[i]) >= ret) {
printf("%d\n", i + 1);
break;
}
}
}
} | #include <algorithm>
#include <cstdio>
#include <numeric>
using namespace std;
int main() {
int l[10], v1, v2, ret;
while (~scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &l[0], &l[1], &l[2],
&l[3], &l[4], &l[5], &l[6], &l[7], &l[8], &l[9], &v1, &v2)) {
int sum = accumulate(l, l + 10, 0), k = 0;
double ret = ((double)v1 / (v1 + v2)) * sum;
for (int i = 0; i < 10; i++) {
if ((k += l[i]) >= ret) {
printf("%d\n", i + 1);
break;
}
}
}
} | replace | 6 | 8 | 6 | 8 | TLE | |
p00034 | C++ | Time Limit Exceeded | #include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
int dis[10], v_0 = 0, v_1 = 0;
while (scanf("%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d", &dis[0],
&dis[1], &dis[2], &dis[3], &dis[4], &dis[5], &dis[6], &dis[7],
&dis[8], &dis[9], &v_0, &v_1)) {
int dsum = 0;
double acum[10];
for (int x = 0; x < 10; ++x) {
dsum += dis[x];
acum[x] = 1.0 * dsum;
}
double dd = v_0 * (dsum * 1.0 / (v_0 + v_1));
// cout<<dd<<endl;
int index = 0;
while (index < 10 && acum[index] < dd) {
++index;
}
--index;
if (acum[index] == dd)
cout << index + 1 << endl;
else
cout << index + 2 << endl;
}
return 0;
} | #include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
int dis[10], v_0 = 0, v_1 = 0;
while (scanf("%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d", &dis[0],
&dis[1], &dis[2], &dis[3], &dis[4], &dis[5], &dis[6], &dis[7],
&dis[8], &dis[9], &v_0, &v_1) == 12) {
int dsum = 0;
double acum[10];
for (int x = 0; x < 10; ++x) {
dsum += dis[x];
acum[x] = 1.0 * dsum;
}
double dd = v_0 * (dsum * 1.0 / (v_0 + v_1));
// cout<<dd<<endl;
int index = 0;
while (index < 10 && acum[index] < dd) {
++index;
}
--index;
if (acum[index] == dd)
cout << index + 1 << endl;
else
cout << index + 2 << endl;
}
return 0;
} | replace | 9 | 10 | 9 | 10 | TLE | |
p00034 | C++ | Time Limit Exceeded | #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define PI acos(-1.0)
#define ALL(A) ((A).begin(), (A).end())
#define vsort(v) sort(v.begin(), v.end())
#define FOR(I, A, B) for (int I = (A); I < (B); ++I)
int main() {
double v1, v2, l[10];
while (scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &l[0], &l[1],
&l[2], &l[3], &l[4], &l[5], &l[6], &l[7], &l[8], &l[9], &v1,
&v2)) {
double p[11];
p[0] = 0;
FOR(i, 1, 11) { p[i] = p[i - 1] + l[i - 1]; }
FOR(i, 0, 10) {
double vt = (p[10] * v1) / (v1 + v2);
if (p[i] < vt && p[i + 1] >= vt) {
cout << i + 1 << endl;
break;
}
}
}
} | #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define PI acos(-1.0)
#define ALL(A) ((A).begin(), (A).end())
#define vsort(v) sort(v.begin(), v.end())
#define FOR(I, A, B) for (int I = (A); I < (B); ++I)
int main() {
double v1, v2, l[10];
while (scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &l[0], &l[1],
&l[2], &l[3], &l[4], &l[5], &l[6], &l[7], &l[8], &l[9], &v1,
&v2) != EOF) {
double p[11];
p[0] = 0;
FOR(i, 1, 11) { p[i] = p[i - 1] + l[i - 1]; }
FOR(i, 0, 10) {
double vt = (p[10] * v1) / (v1 + v2);
if (p[i] < vt && p[i + 1] >= vt) {
cout << i + 1 << endl;
break;
}
}
}
} | replace | 28 | 29 | 28 | 29 | TLE | |
p00035 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vii;
#define rrep(i, m, n) for (int(i) = (m); (i) < (n); (i)++)
#define erep(i, m, n) for (int(i) = (m); (i) <= (n); (i)++)
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define rrev(i, m, n) for (int(i) = (n)-1; (i) >= (m); (i)--)
#define erev(i, m, n) for (int(i) = (n); (i) >= (m); (i)--)
#define rev(i, n) for (int(i) = (n)-1; (i) >= 0; (i)--)
#define vrep(i, c) \
for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ALL(v) (v).begin(), (v).end()
#define mp make_pair
#define pb push_back
template <class T, class S> inline bool minup(T &m, S x) {
return m > (T)x ? (m = (T)x, true) : false;
}
template <class T, class S> inline bool maxup(T &m, S x) {
return m < (T)x ? (m = (T)x, true) : false;
}
const int INF = 1000000000;
const ll MOD = 1000000007LL;
const double EPS = 1E-12;
struct Point : public complex<double> {
public:
Point() {
this->real(0);
this->imag(0);
}
Point(const double &x, const double &y) {
this->real(x);
this->imag(y);
}
Point(const complex<double> w) {
this->real(w.real());
this->imag(w.imag());
}
inline double dot(Point p) { return (conj(*this) * p).real(); } // ??????
inline double det(Point p) { return (conj(*this) * p).imag(); } // ??????
};
namespace std {
bool operator<(const Point &a, const Point &b) {
return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
}
} // namespace std
int ccw(Point a, Point b, Point c) {
b -= a;
c -= a;
if (b.det(c) > 0.0)
return 1;
if (b.det(c) < 0.0)
return -1;
if (b.dot(c) < 0.0)
return 2;
if (norm(b) < norm(c))
return -2;
return 0;
}
typedef vector<Point> Polygon;
#define curr(P, i) P[(i) % P.size()]
#define next(P, i) P[(i + 1) % P.size()]
#define prev(P, i) P[(i + P.size() - 1) % P.size()]
bool isConvex(const Polygon &P) {
for (int i = 0; i < P.size(); ++i)
if (ccw(prev(P, i), curr(P, i), next(P, i)) > 0)
return false;
return true;
}
// O(nlogn)
vector<Point> AndrewMonotoneChain(vector<Point> ps) {
int n = ps.size(), k = 0;
sort(ps.begin(), ps.end());
vector<Point> ch(2 * n);
for (int i = 0; i < n; ch[k++] = ps[i++]) // lower-hull
while (k >= 2 && ccw(ch[k - 2], ch[k - 1], ps[i]) <= 0)
--k;
for (int i = n - 2, t = k + 1; i >= 0; ch[k++] = ps[i--]) // upper-hull
while (k >= t && ccw(ch[k - 2], ch[k - 1], ps[i]) <= 0)
--k;
ch.resize(k - 1);
return ch;
}
template <typename T> ostream &operator<<(ostream &r, const vector<T> t) {
vrep(v, t) r << *v << (v + 1 == t.end() ? "" : " ");
return r;
}
template <typename T>
ostream &operator<<(ostream &r, const pair<vector<T>, int> p) {
int n = p.second;
minup(n, p.first.size());
rep(i, n - 1) r << p.first[i] << ' ';
r << p.first[n - 1];
return r;
}
template <typename T> ostream &operator<<(ostream &r, const pair<T *, int> p) {
int n = p.second - 1;
rep(i, n) r << p.first[i] << ' ';
return r << p.first[n];
}
template <typename T, size_t S>
ostream &operator<<(ostream &r, const T (&a)[S]) {
rep(i, S - 1) r << a[i] << ' ';
return r << a[S - 1];
}
double x, y;
bool ok = true;
int main() {
while (~scanf("%lf,%lf", &x, &y)) {
Polygon P;
P.pb(Point(x, y));
rep(i, 3) {
scanf(",%lf,%lf", &x, &y);
P.pb(Point(x, y));
}
cerr << P << endl;
// puts(isConvex(P) ? "NO" : "YES");
puts(AndrewMonotoneChain(P) == P ? "YES" : "NO");
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vii;
#define rrep(i, m, n) for (int(i) = (m); (i) < (n); (i)++)
#define erep(i, m, n) for (int(i) = (m); (i) <= (n); (i)++)
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define rrev(i, m, n) for (int(i) = (n)-1; (i) >= (m); (i)--)
#define erev(i, m, n) for (int(i) = (n); (i) >= (m); (i)--)
#define rev(i, n) for (int(i) = (n)-1; (i) >= 0; (i)--)
#define vrep(i, c) \
for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ALL(v) (v).begin(), (v).end()
#define mp make_pair
#define pb push_back
template <class T, class S> inline bool minup(T &m, S x) {
return m > (T)x ? (m = (T)x, true) : false;
}
template <class T, class S> inline bool maxup(T &m, S x) {
return m < (T)x ? (m = (T)x, true) : false;
}
const int INF = 1000000000;
const ll MOD = 1000000007LL;
const double EPS = 1E-12;
struct Point : public complex<double> {
public:
Point() {
this->real(0);
this->imag(0);
}
Point(const double &x, const double &y) {
this->real(x);
this->imag(y);
}
Point(const complex<double> w) {
this->real(w.real());
this->imag(w.imag());
}
inline double dot(Point p) { return (conj(*this) * p).real(); } // ??????
inline double det(Point p) { return (conj(*this) * p).imag(); } // ??????
};
namespace std {
bool operator<(const Point &a, const Point &b) {
return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
}
} // namespace std
int ccw(Point a, Point b, Point c) {
b -= a;
c -= a;
if (b.det(c) > 0.0)
return 1;
if (b.det(c) < 0.0)
return -1;
if (b.dot(c) < 0.0)
return 2;
if (norm(b) < norm(c))
return -2;
return 0;
}
typedef vector<Point> Polygon;
#define curr(P, i) P[(i) % P.size()]
#define next(P, i) P[(i + 1) % P.size()]
#define prev(P, i) P[(i + P.size() - 1) % P.size()]
bool isConvex(const Polygon &P) {
for (int i = 0; i < P.size(); ++i)
if (ccw(prev(P, i), curr(P, i), next(P, i)) > 0)
return false;
return true;
}
// O(nlogn)
vector<Point> AndrewMonotoneChain(vector<Point> ps) {
int n = ps.size(), k = 0;
sort(ps.begin(), ps.end());
vector<Point> ch(2 * n);
for (int i = 0; i < n; ch[k++] = ps[i++]) // lower-hull
while (k >= 2 && ccw(ch[k - 2], ch[k - 1], ps[i]) <= 0)
--k;
for (int i = n - 2, t = k + 1; i >= 0; ch[k++] = ps[i--]) // upper-hull
while (k >= t && ccw(ch[k - 2], ch[k - 1], ps[i]) <= 0)
--k;
ch.resize(k - 1);
return ch;
}
template <typename T> ostream &operator<<(ostream &r, const vector<T> t) {
vrep(v, t) r << *v << (v + 1 == t.end() ? "" : " ");
return r;
}
template <typename T>
ostream &operator<<(ostream &r, const pair<vector<T>, int> p) {
int n = p.second;
minup(n, p.first.size());
rep(i, n - 1) r << p.first[i] << ' ';
r << p.first[n - 1];
return r;
}
template <typename T> ostream &operator<<(ostream &r, const pair<T *, int> p) {
int n = p.second - 1;
rep(i, n) r << p.first[i] << ' ';
return r << p.first[n];
}
template <typename T, size_t S>
ostream &operator<<(ostream &r, const T (&a)[S]) {
rep(i, S - 1) r << a[i] << ' ';
return r << a[S - 1];
}
double x, y;
bool ok = true;
int main() {
while (~scanf("%lf,%lf", &x, &y)) {
Polygon P;
P.pb(Point(x, y));
rep(i, 3) {
scanf(",%lf,%lf", &x, &y);
P.pb(Point(x, y));
}
// cerr << P << endl;
// puts(isConvex(P) ? "NO" : "YES");
// puts(AndrewMonotoneChain(P) == P ? "YES" : "NO");
vector<Point> res = AndrewMonotoneChain(P);
sort(ALL(res));
sort(ALL(P));
puts(res == P ? "YES" : "NO");
}
return 0;
} | replace | 129 | 132 | 129 | 136 | 0 | (0,0) (1,0) (1,1) (0,1)
(0,0) (3,0) (1,1) (1,3)
|
p00035 | C++ | Runtime Error | #include <algorithm>
#include <cmath>
#include <iostream>
using namespace std;
// ------ Classes ------ //
class Point {
public:
long double px, py;
Point() : px(0), py(0){};
Point(long double px_, long double py_) : px(px_), py(py_){};
friend bool operator==(const Point &p1, const Point &p2) {
return p1.px == p2.px && p1.py == p2.py;
}
friend bool operator!=(const Point &p1, const Point &p2) {
return p1.px != p2.px || p1.py != p2.py;
}
friend Point operator+(const Point &p1, const Point &p2) {
return Point(p1.px + p2.px, p1.py + p2.py);
}
friend Point operator-(const Point &p1, const Point &p2) {
return Point(p1.px - p2.px, p1.py - p2.py);
}
friend Point operator*(const Point &p1, long double d) {
return Point(p1.px * d, p1.py + d);
}
friend Point operator*(long double d, const Point &p1) { return p1 * d; }
friend Point operator/(const Point &p1, long double d) {
return Point(p1.px / d, p1.py / d);
}
Point &operator+=(const Point &p1) {
px += p1.px;
py += p1.py;
return *this;
}
Point &operator-=(const Point &p1) {
px -= p1.px;
py -= p1.py;
return *this;
}
Point &operator*=(long double d) {
px *= d;
py *= d;
return *this;
}
Point &operator/=(long double d) {
px /= d;
py /= d;
return *this;
}
};
class Segment {
public:
Point p1, p2;
Segment(Point p1_, Point p2_) : p1(p1_), p2(p2_){};
Segment(long double p1x, long double p1y, long double p2x, long double p2y)
: p1(Point(p1x, p1y)), p2(Point(p2x, p2y)){};
friend bool operator==(const Segment &s1, const Segment &s2) {
return (s1.p1 == s2.p1 && s1.p2 == s2.p2) ||
(s1.p1 == s2.p2 && s1.p2 == s2.p1);
}
friend bool operator!=(const Segment &s1, const Segment &s2) {
return !(s1 == s2);
}
};
class Line {
public:
Point p1, p2;
Line(Point p1_, Point p2_) : p1(p1_), p2(p2_){};
Line(long double p1x, long double p1y, long double p2x, long double p2y)
: p1(Point(p1x, p1y)), p2(Point(p2x, p2y)){};
friend bool operator==(const Line &s1, const Line &s2) {
return (s1.p1 == s2.p1 && s1.p2 == s2.p2) ||
(s1.p1 == s2.p2 && s1.p2 == s2.p1);
}
friend bool operator!=(const Line &s1, const Line &s2) { return !(s1 == s2); }
};
// ------ Functions ------ //
long double norm(const Point &a) { return a.px * a.px + a.py * a.py; }
long double abs(const Point &a) { return sqrtl(norm(a)); }
long double dot(const Point &a, const Point &b) {
return a.px * b.px + a.py * b.py;
}
long double crs(const Point &a, const Point &b) {
return a.px * b.py - a.py * b.px;
}
int ccw(Point p0, Point p1, Point p2) {
Point a = p1 - p0, b = p2 - p0;
if (crs(a, b) > 1e-10)
return 1;
if (crs(a, b) < -1e-10)
return -1;
if (dot(a, b) < -1e-10)
return 2;
if (norm(a) < norm(b))
return -2;
return 0;
}
// ------ Main ------ //
Point p1, p2, p3, p4;
int r1, r2, r3, r4;
int main() {
while (~scanf("%Lf,%Lf,%Lf,%Lf,%Lf,%Lf,%Lf,%Lf", p1.px, p1.py, p2.px, p2.py,
p3.px, p3.py, p4.px, p4.py)) {
r1 = ccw(p1, p2, p3);
r2 = ccw(p2, p3, p4);
r3 = ccw(p3, p4, p1);
r4 = ccw(p4, p1, p2);
printf("%s\n",
(r1 == r2 && r2 == r3 && r3 == r4 && abs(r1) == 1) ? "YES" : "NO");
}
return 0;
} | #include <algorithm>
#include <cmath>
#include <iostream>
using namespace std;
// ------ Classes ------ //
class Point {
public:
long double px, py;
Point() : px(0), py(0){};
Point(long double px_, long double py_) : px(px_), py(py_){};
friend bool operator==(const Point &p1, const Point &p2) {
return p1.px == p2.px && p1.py == p2.py;
}
friend bool operator!=(const Point &p1, const Point &p2) {
return p1.px != p2.px || p1.py != p2.py;
}
friend Point operator+(const Point &p1, const Point &p2) {
return Point(p1.px + p2.px, p1.py + p2.py);
}
friend Point operator-(const Point &p1, const Point &p2) {
return Point(p1.px - p2.px, p1.py - p2.py);
}
friend Point operator*(const Point &p1, long double d) {
return Point(p1.px * d, p1.py + d);
}
friend Point operator*(long double d, const Point &p1) { return p1 * d; }
friend Point operator/(const Point &p1, long double d) {
return Point(p1.px / d, p1.py / d);
}
Point &operator+=(const Point &p1) {
px += p1.px;
py += p1.py;
return *this;
}
Point &operator-=(const Point &p1) {
px -= p1.px;
py -= p1.py;
return *this;
}
Point &operator*=(long double d) {
px *= d;
py *= d;
return *this;
}
Point &operator/=(long double d) {
px /= d;
py /= d;
return *this;
}
};
class Segment {
public:
Point p1, p2;
Segment(Point p1_, Point p2_) : p1(p1_), p2(p2_){};
Segment(long double p1x, long double p1y, long double p2x, long double p2y)
: p1(Point(p1x, p1y)), p2(Point(p2x, p2y)){};
friend bool operator==(const Segment &s1, const Segment &s2) {
return (s1.p1 == s2.p1 && s1.p2 == s2.p2) ||
(s1.p1 == s2.p2 && s1.p2 == s2.p1);
}
friend bool operator!=(const Segment &s1, const Segment &s2) {
return !(s1 == s2);
}
};
class Line {
public:
Point p1, p2;
Line(Point p1_, Point p2_) : p1(p1_), p2(p2_){};
Line(long double p1x, long double p1y, long double p2x, long double p2y)
: p1(Point(p1x, p1y)), p2(Point(p2x, p2y)){};
friend bool operator==(const Line &s1, const Line &s2) {
return (s1.p1 == s2.p1 && s1.p2 == s2.p2) ||
(s1.p1 == s2.p2 && s1.p2 == s2.p1);
}
friend bool operator!=(const Line &s1, const Line &s2) { return !(s1 == s2); }
};
// ------ Functions ------ //
long double norm(const Point &a) { return a.px * a.px + a.py * a.py; }
long double abs(const Point &a) { return sqrtl(norm(a)); }
long double dot(const Point &a, const Point &b) {
return a.px * b.px + a.py * b.py;
}
long double crs(const Point &a, const Point &b) {
return a.px * b.py - a.py * b.px;
}
int ccw(Point p0, Point p1, Point p2) {
Point a = p1 - p0, b = p2 - p0;
if (crs(a, b) > 1e-10)
return 1;
if (crs(a, b) < -1e-10)
return -1;
if (dot(a, b) < -1e-10)
return 2;
if (norm(a) < norm(b))
return -2;
return 0;
}
// ------ Main ------ //
Point p1, p2, p3, p4;
int r1, r2, r3, r4;
int main() {
while (~scanf("%Lf,%Lf,%Lf,%Lf,%Lf,%Lf,%Lf,%Lf", &p1.px, &p1.py, &p2.px,
&p2.py, &p3.px, &p3.py, &p4.px, &p4.py)) {
r1 = ccw(p1, p2, p3);
r2 = ccw(p2, p3, p4);
r3 = ccw(p3, p4, p1);
r4 = ccw(p4, p1, p2);
printf("%s\n",
(r1 == r2 && r2 == r3 && r3 == r4 && abs(r1) == 1) ? "YES" : "NO");
}
return 0;
} | replace | 101 | 103 | 101 | 103 | -11 | |
p00035 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
typedef pair<double, double> P;
double Helon(P pa, P pb, P pc) {
double a, b, c;
a = sqrt((pb.first - pa.first) * (pb.first - pa.first) +
(pb.second - pa.second) * (pb.second - pa.second));
b = sqrt((pc.first - pb.first) * (pc.first - pb.first) +
(pc.second - pb.second) * (pc.second - pb.second));
c = sqrt((pa.first - pc.first) * (pa.first - pc.first) +
(pa.second - pc.second) * (pa.second - pc.second));
double s = (a + b + c) / 2;
return (sqrt(s * (s - a) * (s - b) * (s - c)));
}
void solve() {
vector<P> p(4);
while (scanf("%lf,%lf", &p[0].first, &p[0].second)) {
for (int i = 1; i < 4; ++i) {
scanf(",%lf,%lf", &p[i].first, &p[i].second);
}
double S1, S2;
S1 = Helon(p[0], p[1], p[2]);
S1 += Helon(p[0], p[2], p[3]);
S2 = Helon(p[0], p[1], p[3]);
S2 += Helon(p[1], p[2], p[3]);
if (fabs(S1 - S2) < 1e-10) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
}
int main() {
solve();
return (0);
} | #include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
typedef pair<double, double> P;
double Helon(P pa, P pb, P pc) {
double a, b, c;
a = sqrt((pb.first - pa.first) * (pb.first - pa.first) +
(pb.second - pa.second) * (pb.second - pa.second));
b = sqrt((pc.first - pb.first) * (pc.first - pb.first) +
(pc.second - pb.second) * (pc.second - pb.second));
c = sqrt((pa.first - pc.first) * (pa.first - pc.first) +
(pa.second - pc.second) * (pa.second - pc.second));
double s = (a + b + c) / 2;
return (sqrt(s * (s - a) * (s - b) * (s - c)));
}
void solve() {
vector<P> p(4);
while (~scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &p[0].first, &p[0].second,
&p[1].first, &p[1].second, &p[2].first, &p[2].second,
&p[3].first, &p[3].second)) {
double S1, S2;
S1 = Helon(p[0], p[1], p[2]);
S1 += Helon(p[0], p[2], p[3]);
S2 = Helon(p[0], p[1], p[3]);
S2 += Helon(p[1], p[2], p[3]);
if (fabs(S1 - S2) < 1e-10) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
}
int main() {
solve();
return (0);
} | replace | 22 | 26 | 22 | 25 | TLE | |
p00035 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
int main() {
double xa, ya, xb, yb, xc, yc, xd, yd, s1, s2, s3, s4;
while (scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &xa, &ya, &xb, &yb, &xc, &yc,
&xd, &yd)) {
s1 = abs((xc - xa) * (yb - ya) - (xb - xa) * (yc - ya));
s2 = abs((xc - xa) * (yd - ya) - (xd - xa) * (yc - ya));
s3 = abs((xb - xa) * (yd - ya) - (xd - xa) * (yb - ya));
s4 = abs((xb - xc) * (yd - yc) - (xd - xc) * (yb - yc));
if (s1 + s2 == s3 + s4) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
return 0;
} | #include <algorithm>
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
int main() {
double xa, ya, xb, yb, xc, yc, xd, yd, s1, s2, s3, s4;
while (scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &xa, &ya, &xb, &yb, &xc, &yc,
&xd, &yd) != EOF) {
s1 = abs((xc - xa) * (yb - ya) - (xb - xa) * (yc - ya));
s2 = abs((xc - xa) * (yd - ya) - (xd - xa) * (yc - ya));
s3 = abs((xb - xa) * (yd - ya) - (xd - xa) * (yb - ya));
s4 = abs((xb - xc) * (yd - yc) - (xd - xc) * (yb - yc));
if (s1 + s2 == s3 + s4) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
return 0;
} | replace | 10 | 11 | 10 | 11 | TLE | |
p00035 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL << 30)
#define LLINF (1LL << 60)
#define PI 3.14159265359
#define EPS 1e-12
#define int ll
struct vector2D {
double x;
double y;
};
vector2D subVector(const vector2D &t1, const vector2D &t2) {
vector2D ret;
ret.x = t1.x - t2.x;
ret.y = t1.y - t2.y;
return ret;
}
bool hittest(vector2D a, vector2D b, vector2D c, vector2D p) {
vector2D AB = subVector(b, a);
vector2D BP = subVector(p, b);
vector2D BC = subVector(c, b);
vector2D CP = subVector(p, c);
vector2D CA = subVector(a, c);
vector2D AP = subVector(p, a);
double c1 = AB.x * BP.y - AB.y * BP.x;
double c2 = BC.x * CP.y - BC.y * CP.x;
double c3 = CA.x * AP.y - CA.y * AP.x;
if ((c1 > 0 && c2 > 0 && c3 > 0) || (c1 < 0 && c2 < 0 && c3 < 0)) {
return true;
}
return false;
}
signed main(void) {
vector2D p1, p2, p3, p4;
while (scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &p1.x, &p1.y, &p2.x, &p2.y,
&p3.x, &p3.y, &p4.x, &p4.y)) {
if (hittest(p1, p2, p3, p4) || hittest(p1, p2, p4, p3) ||
hittest(p1, p3, p4, p2) || hittest(p2, p3, p4, p1))
cout << "NO" << endl;
else
cout << "YES" << endl;
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL << 30)
#define LLINF (1LL << 60)
#define PI 3.14159265359
#define EPS 1e-12
#define int ll
struct vector2D {
double x;
double y;
};
vector2D subVector(const vector2D &t1, const vector2D &t2) {
vector2D ret;
ret.x = t1.x - t2.x;
ret.y = t1.y - t2.y;
return ret;
}
bool hittest(vector2D a, vector2D b, vector2D c, vector2D p) {
vector2D AB = subVector(b, a);
vector2D BP = subVector(p, b);
vector2D BC = subVector(c, b);
vector2D CP = subVector(p, c);
vector2D CA = subVector(a, c);
vector2D AP = subVector(p, a);
double c1 = AB.x * BP.y - AB.y * BP.x;
double c2 = BC.x * CP.y - BC.y * CP.x;
double c3 = CA.x * AP.y - CA.y * AP.x;
if ((c1 > 0 && c2 > 0 && c3 > 0) || (c1 < 0 && c2 < 0 && c3 < 0)) {
return true;
}
return false;
}
signed main(void) {
vector2D p1, p2, p3, p4;
while (~scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &p1.x, &p1.y, &p2.x, &p2.y,
&p3.x, &p3.y, &p4.x, &p4.y)) {
if (hittest(p1, p2, p3, p4) || hittest(p1, p2, p4, p3) ||
hittest(p1, p3, p4, p2) || hittest(p2, p3, p4, p1))
cout << "NO" << endl;
else
cout << "YES" << endl;
}
return 0;
} | replace | 57 | 59 | 57 | 59 | TLE | |
p00035 | C++ | Time Limit Exceeded | #include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
//??´???AB????§?????????´???BC????§??????????RotType????¨????(A???B???C????????§??????)
// RotType = ????????¢1, ????????¢-1, ??´???0
int getRotType(double angle_a, double angle_b) {
const int eps = 1e-8;
const double PAI = 3.14159265358979;
if (fabs(angle_a - angle_b) <= eps)
return 0;
if (angle_a > angle_b + PAI)
angle_b += 2 * PAI;
else if (angle_b > angle_a + PAI)
angle_a += 2 * PAI;
if (angle_b > angle_a) //?§????????¢????????????????
return 1;
return -1; //?§???????????°?????????????
}
int main() {
double x[4], y[4];
while (scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &x[0], &y[0], &x[1], &y[1],
&x[2], &y[2], &x[3], &y[3])) {
// A???B???C, B???C???D,
// C???D???A?????????????????¨???????????????????????????
double ang[4];
for (int i = 0; i < 4; i++)
ang[i] = atan2(y[(i + 1) % 4] - y[i % 4], x[(i + 1) % 4] - x[i % 4]);
double angType[4];
for (int i = 0; i < 4; i++)
angType[i] = getRotType(ang[i], ang[(i + 1) % 4]);
int i;
for (i = 0; i < 3; i++) {
if (angType[i] != angType[i + 1])
break;
}
if (i == 3)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
} | #include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
//??´???AB????§?????????´???BC????§??????????RotType????¨????(A???B???C????????§??????)
// RotType = ????????¢1, ????????¢-1, ??´???0
int getRotType(double angle_a, double angle_b) {
const int eps = 1e-8;
const double PAI = 3.14159265358979;
if (fabs(angle_a - angle_b) <= eps)
return 0;
if (angle_a > angle_b + PAI)
angle_b += 2 * PAI;
else if (angle_b > angle_a + PAI)
angle_a += 2 * PAI;
if (angle_b > angle_a) //?§????????¢????????????????
return 1;
return -1; //?§???????????°?????????????
}
int main() {
double x[4], y[4];
while (scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &x[0], &y[0], &x[1], &y[1],
&x[2], &y[2], &x[3], &y[3]) != -1) {
// A???B???C, B???C???D,
// C???D???A?????????????????¨???????????????????????????
double ang[4];
for (int i = 0; i < 4; i++)
ang[i] = atan2(y[(i + 1) % 4] - y[i % 4], x[(i + 1) % 4] - x[i % 4]);
double angType[4];
for (int i = 0; i < 4; i++)
angType[i] = getRotType(ang[i], ang[(i + 1) % 4]);
int i;
for (i = 0; i < 3; i++) {
if (angType[i] != angType[i + 1])
break;
}
if (i == 3)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
} | replace | 26 | 27 | 26 | 27 | TLE | |
p00035 | C++ | Time Limit Exceeded | #include <iostream>
#include <stdio.h>
using namespace std;
bool check(double X1, double Y1, double X2, double Y2, double X3, double Y3,
double X4, double Y4) {
return ((X1 - X2) * (Y3 - Y1) - (Y1 - Y2) * (X3 - X1)) *
((X1 - X2) * (Y4 - Y1) - (Y1 - Y2) * (X4 - X1)) >
0.0;
}
void solve() {
double xa, ya, xb, yb, xc, yc, xd, yd;
while (scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &xa, &ya, &xb, &yb, &xc, &yc,
&xd, &yd))
if (check(xa, ya, xc, yc, xb, yb, xd, yd) ||
check(xb, yb, xd, yd, xa, ya, xc, yc)) {
cout << "NO" << endl;
} else {
cout << "YES" << endl;
}
}
int main() {
solve();
return (0);
} | #include <iostream>
#include <stdio.h>
using namespace std;
bool check(double X1, double Y1, double X2, double Y2, double X3, double Y3,
double X4, double Y4) {
return ((X1 - X2) * (Y3 - Y1) - (Y1 - Y2) * (X3 - X1)) *
((X1 - X2) * (Y4 - Y1) - (Y1 - Y2) * (X4 - X1)) >
0.0;
}
void solve() {
double xa, ya, xb, yb, xc, yc, xd, yd;
while (~scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &xa, &ya, &xb, &yb, &xc, &yc,
&xd, &yd))
if (check(xa, ya, xc, yc, xb, yb, xd, yd) ||
check(xb, yb, xd, yd, xa, ya, xc, yc)) {
cout << "NO" << endl;
} else {
cout << "YES" << endl;
}
}
int main() {
solve();
return (0);
} | replace | 14 | 16 | 14 | 16 | TLE | |
p00036 | C++ | Time Limit Exceeded | #include <array>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#define _X_ 0
#define _Y_ 1
int main() {
while (true) {
std::vector<std::array<int, 2>> p;
p.reserve(4);
for (int i = 0; i < 8; i++) {
std::string temp;
std::cin >> temp;
std::stringstream st(temp);
for (int j = 0; j < 8; j++) {
char foo;
st >> foo;
if (foo == '1') {
p.push_back({j, i});
}
}
}
if (p[0][_Y_] == p[1][_Y_]) {
if (p[0][_X_] == p[2][_X_]) {
std::cout << 'A' << std::endl;
} else if (p[0][_Y_] == p[2][_Y_]) {
std::cout << 'C' << std::endl;
} else if (p[1][_X_] == p[2][_X_]) {
std::cout << 'E' << std::endl;
} else if (p[0][_X_] == p[3][_X_]) {
std::cout << 'G' << std::endl;
}
} else {
if (p[0][_X_] == p[3][_X_]) {
std::cout << 'B' << std::endl;
} else if (p[0][_X_] > p[3][_X_]) {
std::cout << 'D' << std::endl;
} else {
std::cout << 'F' << std::endl;
}
}
}
return 0;
}
| #include <array>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#define _X_ 0
#define _Y_ 1
int main() {
while (true) {
std::vector<std::array<int, 2>> p;
p.reserve(4);
for (int i = 0; i < 8; i++) {
std::string temp;
std::cin >> temp;
std::stringstream st(temp);
for (int j = 0; j < 8; j++) {
char foo;
st >> foo;
if (foo == '1') {
p.push_back({j, i});
}
}
}
if (std::cin.eof()) {
break;
}
if (p[0][_Y_] == p[1][_Y_]) {
if (p[0][_X_] == p[2][_X_]) {
std::cout << 'A' << std::endl;
} else if (p[0][_Y_] == p[2][_Y_]) {
std::cout << 'C' << std::endl;
} else if (p[1][_X_] == p[2][_X_]) {
std::cout << 'E' << std::endl;
} else if (p[0][_X_] == p[3][_X_]) {
std::cout << 'G' << std::endl;
}
} else {
if (p[0][_X_] == p[3][_X_]) {
std::cout << 'B' << std::endl;
} else if (p[0][_X_] > p[3][_X_]) {
std::cout << 'D' << std::endl;
} else {
std::cout << 'F' << std::endl;
}
}
}
return 0;
}
| insert | 23 | 23 | 23 | 26 | TLE | |
p00036 | C++ | Time Limit Exceeded | #include <cstdio>
#include <cstring>
int main() {
char p[7][19] = {
"1100000011", "10000000100000001", "1111", "1000000110000001",
"11000000011", "100000001100000001", "110000011"};
char f[65];
char t;
while (1 + scanf("%c", &t)) {
while (t == 10) {
scanf("%c", &t);
}
f[0] = t;
for (int i = 1; i < 64; i++) {
scanf("%c", &t);
while (t == 10) {
scanf("%c", &t);
}
f[i] = t;
}
f[64] = '\0';
for (int i = 0; i < 7; i++) {
if (strstr(f, p[i])) {
printf("%c\n", i + 'A');
}
}
}
return 0;
} | #include <cstdio>
#include <cstring>
int main() {
char p[7][19] = {
"1100000011", "10000000100000001", "1111", "1000000110000001",
"11000000011", "100000001100000001", "110000011"};
char f[65];
char t;
while (1 + scanf("%c", &t)) {
while (t == 10) {
scanf("%c", &t);
}
f[0] = t;
for (int i = 1; i < 64; i++) {
scanf("%c", &t);
while (t == 10) {
scanf("%c", &t);
}
f[i] = t;
}
f[64] = '\0';
for (int i = 0; i < 7; i++) {
if (strstr(f, p[i])) {
printf("%c\n", i + 'A');
}
}
scanf("%c", &t);
}
return 0;
} | insert | 27 | 27 | 27 | 28 | TLE | |
p00036 | C++ | Runtime Error | #include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
vector<string> f;
const string P[7][4] = {
{// A
"1100", "1100", "0000", "0000"},
{// B
"1000", "1000", "1000", "1000"},
{// C
"1111", "0000", "0000", "0000"},
{// D
"0100", "1100", "1000", "0000"},
{// E
"1100", "0110", "0000", "0000"},
{// F
"1000", "1100", "0100", "0000"},
{// G
"0110", "1100", "0000", "0000"},
};
bool check(int x, int y, int k) {
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
int nx = x + j;
int ny = y + i;
if (P[k][i][j] == '1') {
if (nx < 0 || nx > 8 || ny < 0 || ny > 8) {
return false;
}
if (P[k][i][j] != f[ny][nx])
return false;
}
}
}
return true;
}
int main(void) {
while (cin.eof() == false) {
f = vector<string>(8);
string line;
for (int i = 0; i < 8; i++) {
getline(cin, line);
f[i] = line;
if (cin.eof())
break;
}
if (cin.eof())
break;
getline(cin, line);
char answer = 'A';
bool not_found = true;
for (int i = 0; not_found && i < 8; i++) {
for (int j = 0; not_found && j < 8; j++) {
for (int k = 0; not_found && k < 7; k++) {
if (check(j, i, k)) {
answer += k;
not_found = false;
}
}
}
}
cout << answer << endl;
}
return 0;
} | #include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
vector<string> f;
const string P[7][4] = {
{// A
"1100", "1100", "0000", "0000"},
{// B
"1000", "1000", "1000", "1000"},
{// C
"1111", "0000", "0000", "0000"},
{// D
"0100", "1100", "1000", "0000"},
{// E
"1100", "0110", "0000", "0000"},
{// F
"1000", "1100", "0100", "0000"},
{// G
"0110", "1100", "0000", "0000"},
};
bool check(int x, int y, int k) {
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
int nx = x + j;
int ny = y + i;
if (P[k][i][j] == '1') {
if (nx < 0 || nx >= 8 || ny < 0 || ny >= 8) {
return false;
}
if (P[k][i][j] != f[ny][nx])
return false;
}
}
}
return true;
}
int main(void) {
while (cin.eof() == false) {
f = vector<string>(8);
string line;
for (int i = 0; i < 8; i++) {
getline(cin, line);
f[i] = line;
if (cin.eof())
break;
}
if (cin.eof())
break;
getline(cin, line);
char answer = 'A';
bool not_found = true;
for (int i = 0; not_found && i < 8; i++) {
for (int j = 0; not_found && j < 8; j++) {
for (int k = 0; not_found && k < 7; k++) {
if (check(j, i, k)) {
answer += k;
not_found = false;
}
}
}
}
cout << answer << endl;
}
return 0;
} | replace | 30 | 31 | 30 | 31 | 0 | |
p00036 | C++ | Time Limit Exceeded | #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#define X first
#define Y second
#define WIDTH 8
#define HEIGHT 8
using namespace std;
vector<string> init() {
vector<string> map;
for (int i = 0; i < HEIGHT; i++) {
string tmp;
getline(cin, tmp);
map.push_back(tmp);
}
return map;
}
void countNum(vector<string> map, int *count) {
int counter = -1;
for (int i = 0; i < HEIGHT; i++) {
for (int j = 0; j < WIDTH; j++) {
if (map[i][j] == '1') {
counter++;
if (counter == 3)
return;
} else {
if (counter >= 0)
count[counter]++;
}
}
}
return;
}
char checkChar(int *count) {
if (count[0] == 0 && count[1] == 6 && count[2] == 0) {
return 'A';
} else if (count[0] == 7 && count[1] == 7 && count[2] == 7) {
return 'B';
} else if (count[0] == 0 && count[1] == 0 && count[2] == 0) {
return 'C';
} else if (count[0] == 6 && count[1] == 0 && count[2] == 6) {
return 'D';
} else if (count[0] == 0 && count[1] == 7 && count[2] == 0) {
return 'E';
} else if (count[0] == 7 && count[1] == 0 && count[2] == 7) {
return 'F';
} else if (count[0] == 0 && count[1] == 5 && count[2] == 0) {
return 'G';
}
}
int main() {
while (1) {
vector<string> map = init();
int count[] = {0, 0, 0};
countNum(map, count);
cout << checkChar(count) << endl;
// 入力で一行改行が入ってしまうのでそれ対策
string tmp;
getline(cin, tmp);
}
return 0;
} | #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#define X first
#define Y second
#define WIDTH 8
#define HEIGHT 8
using namespace std;
vector<string> init() {
vector<string> map;
for (int i = 0; i < HEIGHT; i++) {
string tmp;
getline(cin, tmp);
map.push_back(tmp);
}
return map;
}
void countNum(vector<string> map, int *count) {
int counter = -1;
for (int i = 0; i < HEIGHT; i++) {
for (int j = 0; j < WIDTH; j++) {
if (map[i][j] == '1') {
counter++;
if (counter == 3)
return;
} else {
if (counter >= 0)
count[counter]++;
}
}
}
return;
}
char checkChar(int *count) {
if (count[0] == 0 && count[1] == 6 && count[2] == 0) {
return 'A';
} else if (count[0] == 7 && count[1] == 7 && count[2] == 7) {
return 'B';
} else if (count[0] == 0 && count[1] == 0 && count[2] == 0) {
return 'C';
} else if (count[0] == 6 && count[1] == 0 && count[2] == 6) {
return 'D';
} else if (count[0] == 0 && count[1] == 7 && count[2] == 0) {
return 'E';
} else if (count[0] == 7 && count[1] == 0 && count[2] == 7) {
return 'F';
} else if (count[0] == 0 && count[1] == 5 && count[2] == 0) {
return 'G';
}
}
int main() {
while (1) {
if (cin.eof())
break;
vector<string> map = init();
int count[] = {0, 0, 0};
countNum(map, count);
cout << checkChar(count) << endl;
// 入力で一行改行が入ってしまうのでそれ対策
string tmp;
getline(cin, tmp);
}
return 0;
} | insert | 68 | 68 | 68 | 70 | TLE | |
p00036 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
typedef long long int lli;
using namespace std;
int dx[7][4] = {{0, 0, 1, 1}, {0, 0, 0, 0}, {0, 1, 2, 3}, {0, 0, -1, -1},
{0, 1, 1, 2}, {0, 0, 1, 1}, {0, -1, 0, 1}};
int dy[7][4] = {{0, 1, 1, 0}, {0, 1, 2, 3}, {0, 0, 0, 0}, {0, 1, 1, 2},
{0, 0, 1, 1}, {0, 1, 1, 2}, {0, 1, 1, 0}};
string MAP[8];
string ans = "ABCDEFG";
int main() {
while (1) {
for (int i = 0; i < 8; ++i) {
for (int j = 0; j < 8; ++j) {
cin >> MAP[i][j];
}
}
for (int i = 0; i < 8; ++i) {
for (int j = 0; j < 8; ++j) {
if (MAP[i][j] == '1') {
for (int k = 0; k < 7; ++k) {
bool ok = true;
for (int l = 0; l < 4; ++l) {
int nx = j + dx[k][l];
int ny = i + dy[k][l];
if ((0 <= nx && nx < 8 && 0 <= ny && ny < 8 &&
MAP[ny][nx] != '1') ||
(nx < 0 || 8 <= nx || ny < 0 || 8 <= ny)) {
ok = false;
break;
}
}
if (ok) {
cout << ans[k] << "\n";
break;
}
}
}
}
}
}
return 0;
} | #include <algorithm>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
typedef long long int lli;
using namespace std;
int dx[7][4] = {{0, 0, 1, 1}, {0, 0, 0, 0}, {0, 1, 2, 3}, {0, 0, -1, -1},
{0, 1, 1, 2}, {0, 0, 1, 1}, {0, -1, 0, 1}};
int dy[7][4] = {{0, 1, 1, 0}, {0, 1, 2, 3}, {0, 0, 0, 0}, {0, 1, 1, 2},
{0, 0, 1, 1}, {0, 1, 1, 2}, {0, 1, 1, 0}};
string MAP[8];
string ans = "ABCDEFG";
int main() {
while (1) {
for (int i = 0; i < 8; ++i) {
if (!(cin >> MAP[i])) {
return 0;
}
}
for (int i = 0; i < 8; ++i) {
for (int j = 0; j < 8; ++j) {
if (MAP[i][j] == '1') {
for (int k = 0; k < 7; ++k) {
bool ok = true;
for (int l = 0; l < 4; ++l) {
int nx = j + dx[k][l];
int ny = i + dy[k][l];
if ((0 <= nx && nx < 8 && 0 <= ny && ny < 8 &&
MAP[ny][nx] != '1') ||
(nx < 0 || 8 <= nx || ny < 0 || 8 <= ny)) {
ok = false;
break;
}
}
if (ok) {
cout << ans[k] << "\n";
break;
}
}
}
}
}
}
return 0;
} | replace | 23 | 25 | 23 | 25 | TLE | |
p00036 | C++ | Runtime Error | // A Figure on Surface
#include <iostream>
#include <string>
using namespace std;
int main(void) {
const int N = 8;
while (1) {
string a[N];
int i, j;
for (i = 0; i < N; i++) {
cin >> a[i];
}
if (!cin)
break;
// ¶ã©çÌÀWð²×é
for (i = 0; i < N; i++) {
for (j = 0; j < N; j++) {
if (a[i][j] == '1')
goto DISCOVER;
}
}
DISCOVER:
// ÔÈñÄǤÅàÇ¢©çÀSÉs«Üµå¤
if ((a[i][j] == a[i + 1][j]) && (a[i][j] == a[i][j + 1]) &&
(a[i][j] == a[i + 1][j + 1]))
cout << 'A' << endl;
else if ((i < N - 3) && (a[i][j] == a[i + 3][j]))
cout << 'B' << endl;
else if ((j < N - 3) && (a[i][j] == a[i][j + 3]))
cout << 'C' << endl;
else if ((i < N - 2) && (j > 0) && (a[i][j] == a[i + 2][j - 1]))
cout << 'D' << endl;
else if ((j < N - 2) && (a[i][j] == a[i + 1][j + 2]))
cout << 'E' << endl;
else if ((i < N - 2) && (a[i][j] == a[i + 2][j + 1]))
cout << 'F' << endl;
else
cout << 'G' << endl;
}
return 0;
} | // A Figure on Surface
#include <iostream>
#include <string>
using namespace std;
int main(void) {
const int N = 8;
while (1) {
string a[N];
int i, j;
for (i = 0; i < N; i++) {
cin >> a[i];
}
if (!cin)
break;
// ¶ã©çÌÀWð²×é
for (i = 0; i < N; i++) {
for (j = 0; j < N; j++) {
if (a[i][j] == '1')
goto DISCOVER;
}
}
DISCOVER:
// ÔÈñÄǤÅàÇ¢©çÀSÉs«Üµå¤
if ((i < N - 1) && (j < N - 1) && (a[i][j] == a[i + 1][j]) &&
(a[i][j] == a[i][j + 1]) && (a[i][j] == a[i + 1][j + 1]))
cout << 'A' << endl;
else if ((i < N - 3) && (a[i][j] == a[i + 3][j]))
cout << 'B' << endl;
else if ((j < N - 3) && (a[i][j] == a[i][j + 3]))
cout << 'C' << endl;
else if ((i < N - 2) && (j > 0) && (a[i][j] == a[i + 2][j - 1]))
cout << 'D' << endl;
else if ((j < N - 2) && (a[i][j] == a[i + 1][j + 2]))
cout << 'E' << endl;
else if ((i < N - 2) && (a[i][j] == a[i + 2][j + 1]))
cout << 'F' << endl;
else
cout << 'G' << endl;
}
return 0;
} | replace | 26 | 28 | 26 | 28 | 0 | |
p00036 | C++ | Runtime Error | #include <iostream>
#include <string>
using namespace std;
int main() {
while (true) {
int i = 0;
string map[8];
while (cin >> map[i], !cin.eof()) {
i++;
if (i == 8) {
break;
}
}
if (cin.eof()) {
break;
}
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
if (map[i][j] == '1' && map[i][j + 1] == '1' && map[i + 1][j] == '1' &&
map[i + 1][j + 1] == '1') {
cout << 'A' << endl;
} else if (map[i][j] == '1' && map[i + 1][j] == '1' &&
map[i + 2][j] == '1' && map[i + 3][j] == '1') {
cout << 'B' << endl;
} else if (map[i][j] == '1' && map[i][j + 1] == '1' &&
map[i][j + 2] == '1' && map[i][j + 3] == '1') {
cout << 'C' << endl;
} else if (map[i][j] == '1' && map[i + 1][j] == '1' &&
map[i + 1][j - 1] == '1' && map[i + 2][j - 1] == '1') {
cout << 'D' << endl;
} else if (map[i][j] == '1' && map[i][j + 1] == '1' &&
map[i + 1][j + 1] == '1' && map[i + 1][j + 2] == '1') {
cout << 'E' << endl;
} else if (map[i][j] == '1' && map[i + 1][j] == '1' &&
map[i + 1][j + 1] == '1' && map[i + 2][i + 1] == '1') {
cout << 'F' << endl;
} else if (map[i][j] == '1' && map[i][j - 1] == '1' &&
map[i + 1][j - 1] == '1' && map[i + 1][j - 2] == '1') {
cout << 'G' << endl;
}
}
}
}
return 0;
} | #include <iostream>
#include <string>
using namespace std;
int main() {
while (true) {
int i = 0;
string map[8];
while (cin >> map[i], !cin.eof()) {
i++;
if (i == 8) {
break;
}
}
if (cin.eof()) {
break;
}
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
if (i < 7 && j < 7) {
if (map[i][j] == '1' && map[i][j + 1] == '1' &&
map[i + 1][j] == '1' && map[i + 1][j + 1] == '1') {
cout << 'A' << endl;
}
}
if (i < 5) {
if (map[i][j] == '1' && map[i + 1][j] == '1' &&
map[i + 2][j] == '1' && map[i + 3][j] == '1') {
cout << 'B' << endl;
}
}
if (j < 5) {
if (map[i][j] == '1' && map[i][j + 1] == '1' &&
map[i][j + 2] == '1' && map[i][j + 3] == '1') {
cout << 'C' << endl;
}
}
if (j > 0 && i < 6) {
if (map[i][j] == '1' && map[i + 1][j] == '1' &&
map[i + 1][j - 1] == '1' && map[i + 2][j - 1] == '1') {
cout << 'D' << endl;
}
}
if (i < 7 && j < 6) {
if (map[i][j] == '1' && map[i][j + 1] == '1' &&
map[i + 1][j + 1] == '1' && map[i + 1][j + 2] == '1') {
cout << 'E' << endl;
}
}
if (i < 6 && j < 7) {
if (map[i][j] == '1' && map[i + 1][j] == '1' &&
map[i + 1][j + 1] == '1' && map[i + 2][j + 1] == '1') {
cout << 'F' << endl;
}
}
if (i < 7 && j > 1) {
if (map[i][j] == '1' && map[i][j - 1] == '1' &&
map[i + 1][j - 1] == '1' && map[i + 1][j - 2] == '1') {
cout << 'G' << endl;
}
}
}
}
}
return 0;
} | replace | 19 | 40 | 19 | 60 | 0 | |
p00036 | C++ | Time Limit Exceeded | #include <iostream>
using namespace std;
char m[8][8];
void figure(int, int);
int main() {
while (1) {
bool f = true;
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
cin >> m[i][j];
}
}
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
if (m[i][j] == '1') {
figure(i, j);
f = false;
break;
}
}
if (!f) {
break;
}
}
}
}
void figure(int i, int j) {
char s;
if (m[i][j + 1] == '1' && m[i + 1][j + 1] == '1' && m[i + 1][j] == '1') {
s = 'A';
} else if (m[i + 1][j] == '1' && m[i + 2][j] == '1') {
s = 'B';
} else if (m[i][j + 1] == '1' && m[i][j + 2] == '1') {
s = 'C';
} else if (m[i][j + 1] == '1' && m[i + 1][j + 1] == '1') {
s = 'E';
} else if (m[i][j + 1] == '1') {
s = 'G';
} else if (m[i + 1][j + 1] == '1') {
s = 'F';
} else {
s = 'D';
}
cout << s << endl;
} | #include <iostream>
using namespace std;
char m[8][8];
void figure(int, int);
int main() {
while (1) {
bool f = true;
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
cin >> m[i][j];
if (cin.eof()) {
return 0;
}
}
}
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
if (m[i][j] == '1') {
figure(i, j);
f = false;
break;
}
}
if (!f) {
break;
}
}
}
}
void figure(int i, int j) {
char s;
if (m[i][j + 1] == '1' && m[i + 1][j + 1] == '1' && m[i + 1][j] == '1') {
s = 'A';
} else if (m[i + 1][j] == '1' && m[i + 2][j] == '1') {
s = 'B';
} else if (m[i][j + 1] == '1' && m[i][j + 2] == '1') {
s = 'C';
} else if (m[i][j + 1] == '1' && m[i + 1][j + 1] == '1') {
s = 'E';
} else if (m[i][j + 1] == '1') {
s = 'G';
} else if (m[i + 1][j + 1] == '1') {
s = 'F';
} else {
s = 'D';
}
cout << s << endl;
} | insert | 13 | 13 | 13 | 16 | TLE | |
p00037 | C++ | Time Limit Exceeded | #include <iostream>
#include <string>
using namespace std;
class Dot {
public:
bool d[4];
Dot() { d[0] = d[1] = d[2] = d[3] = false; }
};
int main() {
Dot data[5][5];
for (int i = 0; i < 9; i++) {
string str;
getline(cin, str);
int y = i / 2;
if (i % 2 == 0) {
for (int j = 0; j < 4; j++) {
if (str[j] == '1') {
data[y][j].d[0] = data[y][j + 1].d[2] = true;
}
}
} else {
for (int j = 0; j < 5; j++) {
if (str[j] == '1') {
data[y][j].d[1] = data[y + 1][j].d[3] = true;
}
}
}
}
int d[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
int x = 0;
int y = 0;
int dir = 0;
while (1) {
for (int i = 0; i < 3; i++) {
int t = (dir + i + 3) % 4;
if (data[y][x].d[t]) {
dir = t;
x += d[t][0];
y += d[t][1];
switch (t) {
case 0:
cout << 'R';
break;
case 1:
cout << 'D';
break;
case 2:
cout << 'L';
break;
case 3:
cout << 'U';
break;
}
break;
}
}
if (x == 0 && y == 0) {
cout << endl;
break;
}
}
return 0;
} | #include <iostream>
#include <string>
using namespace std;
class Dot {
public:
bool d[4];
Dot() { d[0] = d[1] = d[2] = d[3] = false; }
};
int main() {
Dot data[5][5];
for (int i = 0; i < 9; i++) {
string str;
getline(cin, str);
int y = i / 2;
if (i % 2 == 0) {
for (int j = 0; j < 4; j++) {
if (str[j] == '1') {
data[y][j].d[0] = data[y][j + 1].d[2] = true;
}
}
} else {
for (int j = 0; j < 5; j++) {
if (str[j] == '1') {
data[y][j].d[1] = data[y + 1][j].d[3] = true;
}
}
}
}
int d[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
int x = 0;
int y = 0;
int dir = 0;
while (1) {
for (int i = 0; i < 4; i++) {
int t = (dir + i + 3) % 4;
if (data[y][x].d[t]) {
dir = t;
x += d[t][0];
y += d[t][1];
switch (t) {
case 0:
cout << 'R';
break;
case 1:
cout << 'D';
break;
case 2:
cout << 'L';
break;
case 3:
cout << 'U';
break;
}
break;
}
}
if (x == 0 && y == 0) {
cout << endl;
break;
}
}
return 0;
} | replace | 36 | 37 | 36 | 37 | TLE | |
p00037 | C++ | Time Limit Exceeded | #include <cstdio>
#include <iostream>
#include <string>
using namespace std;
string str[100];
int len;
int fie[101][101];
int m;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
char s[4] = {'R', 'D', 'L', 'U'};
int main(void) {
int n = 9;
for (int i = 0; i < 10; i++)
cin >> str[i];
m = str[0].size();
for (int i = 0; i < n; i++) {
for (int j = 0; j < str[i].size(); j++) {
if (str[i][j] == '1') {
if (i % 2 == 0)
fie[j * 2 + 2][i + 1] = 1;
if (i % 2 == 1)
fie[j * 2 + 1][i + 1] = 1;
}
}
}
int x = 2, y = 0, dir = 0;
while (1) {
int nx = x + dx[(dir + 1) % 4], ny = y + dy[(dir + 1) % 4];
if (nx >= 0 && nx <= m * 2 + 2 && ny >= 0 && ny <= n + 1) {
if (fie[nx][ny] == 1)
printf("%c", s[dir]);
}
nx = x + dx[dir], ny = y + dy[dir];
if (nx >= 0 && nx <= m * 2 + 2 && ny >= 0 && ny <= n + 1) {
if (fie[nx][ny] == 0) {
x += dx[dir] * 2;
y += dy[dir] * 2;
if (fie[x + dx[(dir + 1) % 4]][y + dy[(dir + 1) % 4]] == 0) {
dir = (dir + 1) % 4;
}
} else {
if (fie[x + dx[(dir + 3) % 4]][y + dy[(dir + 3) % 4]] == 0) {
dir = (dir + 3) % 4;
x += dx[dir] * 2;
y += dy[dir] * 2;
printf("%c", s[dir]);
} else {
dir = (dir + 2) % 4;
x += dx[dir] * 2;
y += dy[dir] * 2;
printf("%c", s[(dir + 1) % 4]);
printf("%c", s[dir]);
}
}
} else
dir = (dir + 1) % 4;
// printf("%d %d %d %d %d\n",x,y,dir,dx[dir],dy[dir]);
if (x == 0 && y == 0)
break;
}
printf("\n");
return 0;
} | #include <cstdio>
#include <iostream>
#include <string>
using namespace std;
string str[100];
int len;
int fie[101][101];
int m;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
char s[4] = {'R', 'D', 'L', 'U'};
int main(void) {
int n = 9;
for (int i = 0; i < 10; i++)
cin >> str[i];
m = str[0].size();
for (int i = 0; i < n; i++) {
for (int j = 0; j < str[i].size(); j++) {
if (str[i][j] == '1') {
if (i % 2 == 0)
fie[j * 2 + 2][i + 1] = 1;
if (i % 2 == 1)
fie[j * 2 + 1][i + 1] = 1;
}
}
}
int x = 2, y = 0, dir = 0;
while (1) {
int nx = x + dx[(dir + 1) % 4], ny = y + dy[(dir + 1) % 4];
if (nx >= 0 && nx <= m * 2 + 2 && ny >= 0 && ny <= n + 1) {
if (fie[nx][ny] == 1)
printf("%c", s[dir]);
}
nx = x + dx[dir], ny = y + dy[dir];
if (nx >= 0 && nx <= m * 2 + 2 && ny >= 0 && ny <= n + 1) {
if (fie[nx][ny] == 0) {
x += dx[dir] * 2;
y += dy[dir] * 2;
if (fie[x + dx[(dir + 1) % 4]][y + dy[(dir + 1) % 4]] == 0) {
dir = (dir + 1) % 4;
}
} else {
if (fie[x + dx[(dir + 1) % 4]][y + dy[(dir + 1) % 4]] == 0) {
dir = (dir + 1) % 4;
x += dx[dir] * 2;
y += dy[dir] * 2;
} else if (fie[x + dx[(dir + 3) % 4]][y + dy[(dir + 3) % 4]] == 0) {
dir = (dir + 3) % 4;
x += dx[dir] * 2;
y += dy[dir] * 2;
printf("%c", s[dir]);
} else {
dir = (dir + 2) % 4;
x += dx[dir] * 2;
y += dy[dir] * 2;
printf("%c", s[(dir + 1) % 4]);
printf("%c", s[dir]);
}
}
} else
dir = (dir + 1) % 4;
// printf("%d %d %d %d %d\n",x,y,dir,dx[dir],dy[dir]);
if (x == 0 && y == 0)
break;
}
printf("\n");
return 0;
} | replace | 43 | 44 | 43 | 48 | TLE | |
p00037 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
vector<string> strs;
int H, W;
bool isroad(int fx, int fy, int tx, int ty) {
int fromx, fromy, tox, toy;
fromx = min(fx, tx);
fromy = min(fy, ty);
tox = max(fx, tx);
toy = max(fy, ty);
if (fromx < 1 || tox < 1 || tox > W || fromx > W || fromy < 1 || toy < 1 ||
fromy > H || toy > H)
return false;
if (fromx == tox) {
if (strs[(fromy - 1) * 2 + 1][fromx - 1] == '1')
return true;
else {
return false;
}
} else {
if (strs[(fromy - 1) * 2][fromx - 1] == '1')
return true;
else {
return false;
}
}
}
int vx[] = {1, 0, -1, 0}, vy[] = {0, -1, 0, 1};
int main() {
string ins;
while (cin >> ins) {
strs.push_back(ins);
}
W = strs[0].size() + 1;
H = strs.size() / 2 + 1;
int nx = 2, ny = 1, v = 0;
string outs = "R";
while (nx != 1 || ny != 1) {
for (int i = 5; i >= 3; i--) {
bool r = isroad(nx, ny, nx + vx[(v + i) % 4], ny + vy[(v + i) % 4]);
if (r) {
v = (v + i) % 4;
nx += vx[v];
ny += vy[v];
if (v == 0)
outs += 'R';
else if (v == 1)
outs += 'U';
else if (v == 2)
outs += 'L';
else
outs += 'D';
break;
}
}
}
cout << outs << endl;
} | #include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
vector<string> strs;
int H, W;
bool isroad(int fx, int fy, int tx, int ty) {
int fromx, fromy, tox, toy;
fromx = min(fx, tx);
fromy = min(fy, ty);
tox = max(fx, tx);
toy = max(fy, ty);
if (fromx < 1 || tox < 1 || tox > W || fromx > W || fromy < 1 || toy < 1 ||
fromy > H || toy > H)
return false;
if (fromx == tox) {
if (strs[(fromy - 1) * 2 + 1][fromx - 1] == '1')
return true;
else {
return false;
}
} else {
if (strs[(fromy - 1) * 2][fromx - 1] == '1')
return true;
else {
return false;
}
}
}
int vx[] = {1, 0, -1, 0}, vy[] = {0, -1, 0, 1};
int main() {
string ins;
while (cin >> ins) {
strs.push_back(ins);
}
W = strs[0].size() + 1;
H = strs.size() / 2 + 1;
int nx = 2, ny = 1, v = 0;
string outs = "R";
while (nx != 1 || ny != 1) {
for (int i = 5; i >= 2; i--) {
bool r = isroad(nx, ny, nx + vx[(v + i) % 4], ny + vy[(v + i) % 4]);
if (r) {
v = (v + i) % 4;
nx += vx[v];
ny += vy[v];
if (v == 0)
outs += 'R';
else if (v == 1)
outs += 'U';
else if (v == 2)
outs += 'L';
else
outs += 'D';
break;
}
}
}
cout << outs << endl;
} | replace | 41 | 42 | 41 | 42 | TLE | |
p00037 | C++ | Runtime Error | #include <stdio.h>
int f[5][5], i, j, a, y, x, p;
int main() {
for (; i < 9; ++i) {
char s[6];
scanf("%s", s);
for (j = 0; j < 4 + i % 2; ++j) {
a = s[j] - 48;
f[i / 2][j] |= a << (1 + i % 2);
f[i / 2 + i % 2][j + !(i % 2)] |= a << 3 - i % 2 * 3;
}
}
do {
do
p = (p + 1) % 4;
while (!((f[y][x] >> p) & 1));
putchar("URDL"[p]);
x += p ? 2 - p : 0;
y += p == 3 ? 0 : p - 1;
p = (p + 2) % 4;
} while (y != 0 || x != 0 || f[0][0] == 6 && p == 3);
return puts("");
} | #include <stdio.h>
int f[5][5], i, j, a, y, x, p;
int main() {
for (; i < 9; ++i) {
char s[6];
scanf("%s", s);
for (j = 0; j < 4 + i % 2; ++j) {
a = s[j] - 48;
f[i / 2][j] |= a << (1 + i % 2);
f[i / 2 + i % 2][j + !(i % 2)] |= a << 3 - i % 2 * 3;
}
}
do {
do
p = (p + 1) % 4;
while (!((f[y][x] >> p) & 1));
putchar("URDL"[p]);
x += p ? 2 - p : 0;
y += p == 3 ? 0 : p - 1;
p = (p + 2) % 4;
} while (y != 0 || x != 0 || f[0][0] == 6 && p == 3);
return !puts("");
} | replace | 21 | 22 | 21 | 22 | 1 | |
p00037 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
const char ch[] = {"ULDR"};
bool g[10][10][10][10];
int main() {
char c;
for (int i = 1; i <= 5; i++) {
for (int j = 1; j <= 4; j++) {
scanf(" %c", &c);
if (c == '0')
continue;
g[i][j][i][j + 1] = true;
g[i][j + 1][i][j] = true;
}
if (i == 5)
continue;
for (int j = 1; j <= 5; j++) {
scanf(" %c", &c);
if (c == '0')
continue;
g[i][j][i + 1][j] = true;
g[i + 1][j][i][j] = true;
}
}
int dir = 3;
int x = 1, y = 2;
while (true) {
printf("%c", ch[dir]);
if (x == 1 && y == 1)
break;
for (int t = 1; t >= -1; t--) {
int nd = (dir + t + 4) % 4;
int nx = x + dx[nd];
int ny = y + dy[nd];
if (g[x][y][nx][ny]) {
x = nx;
y = ny;
dir = nd;
break;
}
}
}
puts("");
return 0;
} | #include <bits/stdc++.h>
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
const char ch[] = {"ULDR"};
bool g[10][10][10][10];
int main() {
char c;
for (int i = 1; i <= 5; i++) {
for (int j = 1; j <= 4; j++) {
scanf(" %c", &c);
if (c == '0')
continue;
g[i][j][i][j + 1] = true;
g[i][j + 1][i][j] = true;
}
if (i == 5)
continue;
for (int j = 1; j <= 5; j++) {
scanf(" %c", &c);
if (c == '0')
continue;
g[i][j][i + 1][j] = true;
g[i + 1][j][i][j] = true;
}
}
int dir = 3;
int x = 1, y = 2;
while (true) {
printf("%c", ch[dir]);
if (x == 1 && y == 1)
break;
for (int t = 1; t >= -2; t--) {
int nd = (dir + t + 4) % 4;
int nx = x + dx[nd];
int ny = y + dy[nd];
if (g[x][y][nx][ny]) {
x = nx;
y = ny;
dir = nd;
break;
}
}
}
puts("");
return 0;
} | replace | 37 | 38 | 37 | 38 | TLE | |
p00037 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define DEBUG(x) cerr << #x << " = " << x << endl
int main() {
static bool wall[6][6][4];
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
REP(i, 6) REP(j, 6) REP(k, 4) {
int ni = i + dy[k];
int nj = j + dx[k];
if (0 <= ni && ni < 6 && 0 <= nj && nj < 6) {
wall[i][j][k] = 0;
} else {
wall[i][j][k] = 1;
}
}
string s;
for (int i = 0; i < 4; i++) {
getline(cin, s);
for (int j = 0; j < 4; j++) {
wall[i][j + 1][1] = (s[j] == '1');
wall[i + 1][j + 1][3] = (s[j] == '1');
}
getline(cin, s);
for (int j = 0; j < 5; j++) {
wall[i + 1][j][0] = (s[j] == '1');
wall[i + 1][j + 1][2] = (s[j] == '1');
}
}
getline(cin, s);
for (int j = 0; j < 4; j++) {
wall[4][j + 1][1] = (s[j] == '1');
wall[5][j + 1][3] = (s[j] == '1');
}
string icon = "RDLU";
#if 0
REP(i,6) REP(j,6) {
cerr << "(" << i << "," << j << ")";
REP(k,4) {
if(wall[i][j][k]) cerr << icon[k];
}
cerr << endl;
}
#endif
int X = 1, Y = 0, dir = 0;
string ans = "R";
do {
#if 1
cerr << "X = " << X << ", Y = " << Y << ", dir = " << dir << endl;
#endif
if (wall[Y][X][dir] == 0) {
Y += dy[dir];
X += dx[dir];
if (wall[Y][X][(dir + 1) % 4] == 0) {
dir = (dir + 1) % 4;
X += dx[dir];
Y += dy[dir];
if (wall[Y][X][(dir + 1) % 4] == 0) {
dir = (dir + 1) % 4;
X += dx[dir];
Y += dy[dir];
ans.push_back(icon[dir]);
} else {
ans.push_back(icon[dir]);
}
} else {
ans.push_back(icon[dir]);
}
} else {
dir = (dir - 1 + 4) % 4;
ans.push_back(icon[dir]);
}
} while (!((X == 1 && Y == 0)));
ans = ans.substr(0, (int)ans.size() - 1);
cout << ans << endl;
} | #include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define DEBUG(x) cerr << #x << " = " << x << endl
int main() {
static bool wall[6][6][4];
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
REP(i, 6) REP(j, 6) REP(k, 4) {
int ni = i + dy[k];
int nj = j + dx[k];
if (0 <= ni && ni < 6 && 0 <= nj && nj < 6) {
wall[i][j][k] = 0;
} else {
wall[i][j][k] = 1;
}
}
string s;
for (int i = 0; i < 4; i++) {
getline(cin, s);
for (int j = 0; j < 4; j++) {
wall[i][j + 1][1] = (s[j] == '1');
wall[i + 1][j + 1][3] = (s[j] == '1');
}
getline(cin, s);
for (int j = 0; j < 5; j++) {
wall[i + 1][j][0] = (s[j] == '1');
wall[i + 1][j + 1][2] = (s[j] == '1');
}
}
getline(cin, s);
for (int j = 0; j < 4; j++) {
wall[4][j + 1][1] = (s[j] == '1');
wall[5][j + 1][3] = (s[j] == '1');
}
string icon = "RDLU";
#if 0
REP(i,6) REP(j,6) {
cerr << "(" << i << "," << j << ")";
REP(k,4) {
if(wall[i][j][k]) cerr << icon[k];
}
cerr << endl;
}
#endif
int X = 1, Y = 0, dir = 0;
string ans = "R";
do {
#if 0
cerr << "X = " << X << ", Y = " << Y << ", dir = " << dir << endl;
#endif
if (wall[Y][X][dir] == 0) {
Y += dy[dir];
X += dx[dir];
if (wall[Y][X][(dir + 1) % 4] == 0) {
dir = (dir + 1) % 4;
X += dx[dir];
Y += dy[dir];
if (wall[Y][X][(dir + 1) % 4] == 0) {
dir = (dir + 1) % 4;
X += dx[dir];
Y += dy[dir];
ans.push_back(icon[dir]);
} else {
ans.push_back(icon[dir]);
}
} else {
ans.push_back(icon[dir]);
}
} else {
dir = (dir - 1 + 4) % 4;
ans.push_back(icon[dir]);
}
} while (!((X == 1 && Y == 0)));
ans = ans.substr(0, (int)ans.size() - 1);
cout << ans << endl;
} | replace | 56 | 57 | 56 | 57 | 0 | X = 1, Y = 0, dir = 0
X = 2, Y = 0, dir = 0
X = 3, Y = 0, dir = 0
X = 4, Y = 0, dir = 0
X = 5, Y = 1, dir = 1
X = 5, Y = 2, dir = 1
X = 5, Y = 3, dir = 1
X = 5, Y = 4, dir = 1
X = 4, Y = 5, dir = 2
X = 3, Y = 5, dir = 2
X = 2, Y = 5, dir = 2
X = 1, Y = 4, dir = 3
X = 1, Y = 3, dir = 3
X = 1, Y = 2, dir = 3
X = 2, Y = 1, dir = 0
X = 3, Y = 1, dir = 0
X = 4, Y = 2, dir = 1
X = 4, Y = 3, dir = 1
X = 3, Y = 4, dir = 2
X = 2, Y = 3, dir = 3
X = 3, Y = 2, dir = 0
X = 3, Y = 2, dir = 3
X = 3, Y = 2, dir = 2
X = 2, Y = 2, dir = 2
X = 2, Y = 2, dir = 1
X = 2, Y = 3, dir = 1
X = 2, Y = 4, dir = 1
X = 2, Y = 4, dir = 0
X = 3, Y = 4, dir = 0
X = 4, Y = 4, dir = 0
X = 4, Y = 4, dir = 3
X = 4, Y = 3, dir = 3
X = 4, Y = 2, dir = 3
X = 4, Y = 1, dir = 3
X = 4, Y = 1, dir = 2
X = 3, Y = 1, dir = 2
X = 2, Y = 1, dir = 2
X = 1, Y = 1, dir = 2
|
p00037 | C++ | Runtime Error | #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 maze[20][20];
char s[6];
char ans[100];
int sz = 0;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
char sym[] = "RDLU";
int main() {
REP(i, 9) {
scanf("%s", s);
REP(j, strlen(s)) {
if (i % 2 == 0) {
maze[i + 1][2 * j + 2] = s[j] - '0';
} else {
maze[i + 1][2 * j + 1] = s[j] - '0';
}
}
}
REP(i, 11) {
REP(j, 11) { fprintf(stderr, "%d", maze[i][j]); }
fprintf(stderr, "\n");
}
ans[0] = 'R';
sz++;
int x = 3, y = 1;
int dir = 0;
while (x != 1 || y != 1) {
REP(i, 4) {
int d = (dir + 3 + i) % 4;
if (maze[y + dy[d]][x + dx[d]]) {
dir = d;
break;
}
}
x += dx[dir] * 2;
y += dy[dir] * 2;
ans[sz++] = sym[dir];
}
printf("%s\n", ans);
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 maze[20][20];
char s[6];
char ans[100];
int sz = 0;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
char sym[] = "RDLU";
int main() {
REP(i, 9) {
scanf("%s", s);
REP(j, strlen(s)) {
if (i % 2 == 0) {
maze[i + 1][2 * j + 2] = s[j] - '0';
} else {
maze[i + 1][2 * j + 1] = s[j] - '0';
}
}
}
ans[0] = 'R';
sz++;
int x = 3, y = 1;
int dir = 0;
while (x != 1 || y != 1) {
REP(i, 4) {
int d = (dir + 3 + i) % 4;
if (maze[y + dy[d]][x + dx[d]]) {
dir = d;
break;
}
}
x += dx[dir] * 2;
y += dy[dir] * 2;
ans[sz++] = sym[dir];
}
printf("%s\n", ans);
return 0;
} | delete | 28 | 32 | 28 | 28 | 0 | 00000000000
00101010100
00000000010
00001010000
00010001010
00000010000
00010101010
00000010000
00010000010
00001010100
00000000000
|
p00038 | C++ | Runtime Error | #include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
int main(void) {
int a[5] = {0};
string str = "null";
while (scanf("%d,%d,%d,%d,%d", a[0], a[1], a[2], a[3], a[4]) != EOF) {
sort(a, a + 5);
if (((a[0] == a[1]) && (a[2] == a[3]) && (a[2] == a[1])) ||
((a[1] == a[2]) && (a[2] == a[3]) && (a[3] == a[4])))
str = "four card";
else if (((a[0] == a[1]) && (a[1] == a[2]) && (a[3] == a[4])) ||
((a[0] == a[1]) && (a[2] == a[3]) && (a[3] == a[4])))
str = "full house";
else if (((a[0] == 1) && (a[1] == 10) && (a[2] == 11) && (a[3] == 12) &&
(a[4] == 13)) ||
((a[0] + 1 == a[1]) && (a[1] + 1 == a[2]) && (a[2] + 1 == a[3]) &&
(a[3] + 1 == a[4])))
str = "straight";
else if (((a[0] == a[1]) && (a[1] == a[2])) ||
((a[1] == a[2]) && (a[2] == a[3])) ||
((a[2] == a[3]) && (a[3] == a[4])))
str = "three card";
else if (((a[0] == a[1]) && ((a[2] == a[3]) || (a[3] == a[4]))) ||
((a[1] == a[2]) && (a[3] == a[4])))
str = "two pair";
else if ((a[0] == a[1]) || (a[1] == a[2]) || (a[2] == a[3]) ||
(a[3] == a[4]))
str = "one pair";
cout << str << endl;
}
return 0;
} | #include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
int main(void) {
int a[5] = {0};
string str = "null";
while (scanf("%d,%d,%d,%d,%d", &a[0], &a[1], &a[2], &a[3], &a[4]) != EOF) {
sort(a, a + 5);
if (((a[0] == a[1]) && (a[2] == a[3]) && (a[2] == a[1])) ||
((a[1] == a[2]) && (a[2] == a[3]) && (a[3] == a[4])))
str = "four card";
else if (((a[0] == a[1]) && (a[1] == a[2]) && (a[3] == a[4])) ||
((a[0] == a[1]) && (a[2] == a[3]) && (a[3] == a[4])))
str = "full house";
else if (((a[0] == 1) && (a[1] == 10) && (a[2] == 11) && (a[3] == 12) &&
(a[4] == 13)) ||
((a[0] + 1 == a[1]) && (a[1] + 1 == a[2]) && (a[2] + 1 == a[3]) &&
(a[3] + 1 == a[4])))
str = "straight";
else if (((a[0] == a[1]) && (a[1] == a[2])) ||
((a[1] == a[2]) && (a[2] == a[3])) ||
((a[2] == a[3]) && (a[3] == a[4])))
str = "three card";
else if (((a[0] == a[1]) && ((a[2] == a[3]) || (a[3] == a[4]))) ||
((a[1] == a[2]) && (a[3] == a[4])))
str = "two pair";
else if ((a[0] == a[1]) || (a[1] == a[2]) || (a[2] == a[3]) ||
(a[3] == a[4]))
str = "one pair";
cout << str << endl;
}
return 0;
} | replace | 8 | 9 | 8 | 9 | -11 | |
p00038 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
int c[5]; // card
bool straight() {
if (c[4] == 13 && c[3] == 12 && c[2] == 11 && c[1] == 10 && c[0] == 1)
return true;
for (int i = 0; i < 4; i++) {
if (c[i + 1] - c[i] != 1)
return false;
}
return true;
}
int main(void) {
while (~scanf("%d %d %d %d %d", c, c + 1, c + 2, c + 3, c + 4)) {
sort(c, c + 5);
if (c[0] == c[3] || c[1] == c[4]) {
puts("four card");
} else if ((c[0] == c[2] && c[3] == c[4]) ||
(c[0] == c[1] && c[2] == c[4])) {
puts("full house");
} else if (straight()) {
puts("straight");
} else if (c[0] == c[2] || c[1] == c[3] || c[2] == c[4]) {
puts("three card");
} else if ((c[0] == c[1] && (c[2] == c[3] || c[3] == c[4])) ||
(c[1] == c[2] && c[3] == c[4])) {
puts("two pair");
} else if (c[0] == c[1] || c[1] == c[2] || c[2] == c[3] || c[3] == c[4]) {
puts("one pair");
} else {
puts("null");
}
}
return 0;
} | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
int c[5]; // card
bool straight() {
if (c[4] == 13 && c[3] == 12 && c[2] == 11 && c[1] == 10 && c[0] == 1)
return true;
for (int i = 0; i < 4; i++) {
if (c[i + 1] - c[i] != 1)
return false;
}
return true;
}
int main(void) {
while (~scanf("%d,%d,%d,%d,%d", c, c + 1, c + 2, c + 3, c + 4)) {
sort(c, c + 5);
if (c[0] == c[3] || c[1] == c[4]) {
puts("four card");
} else if ((c[0] == c[2] && c[3] == c[4]) ||
(c[0] == c[1] && c[2] == c[4])) {
puts("full house");
} else if (straight()) {
puts("straight");
} else if (c[0] == c[2] || c[1] == c[3] || c[2] == c[4]) {
puts("three card");
} else if ((c[0] == c[1] && (c[2] == c[3] || c[3] == c[4])) ||
(c[1] == c[2] && c[3] == c[4])) {
puts("two pair");
} else if (c[0] == c[1] || c[1] == c[2] || c[2] == c[3] || c[3] == c[4]) {
puts("one pair");
} else {
puts("null");
}
}
return 0;
} | replace | 22 | 23 | 22 | 23 | TLE | |
p00038 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
string s[] = {"one pair", "two pair", "three card", "straight", "null"};
int str(int n) {
cout << s[n] << endl;
return 0;
}
int main() {
int a[5], t[14], ans, m;
while (scanf("%d,%d,%d,%d,%d", &a[0], &a[1], &a[2], &a[3], &a[4])) {
ans = -1, m = 0;
sort(a, a + 5);
fill(t, t + 14, 0);
for (int i = 0; i < 5; i++) {
t[a[i]]++;
if (m < t[a[i]])
m = t[a[i]];
}
int flag = 0;
if (a[0] == 1 && a[1] == 10 && a[2] == 11 && a[3] == 12 && a[4] == 13) {
str(3);
continue;
}
for (int i = 1; i < 5 && a[i - 1] + 1 == a[i]; i++)
flag = i;
if (flag == 4) {
str(3);
continue;
}
if (m == 4) {
cout << "four card" << endl;
continue;
}
if (m == 3) {
int f = 1;
for (int i = 1; i <= 13; i++) {
if (t[i] == 2)
f = 0;
}
if (!f) {
cout << "full house" << endl;
continue;
}
ans = 2;
}
for (int i = 1; i <= 13; i++) {
if (!ans && t[i] == 2)
ans = 1;
if (ans != 1 && t[i] == 2)
ans = 0;
}
if (ans == -1)
ans = 4;
str(ans);
}
return 0;
} | #include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
string s[] = {"one pair", "two pair", "three card", "straight", "null"};
int str(int n) {
cout << s[n] << endl;
return 0;
}
int main() {
int a[5], t[14], ans, m;
while (scanf("%d,%d,%d,%d,%d", &a[0], &a[1], &a[2], &a[3], &a[4]) != EOF) {
ans = -1, m = 0;
sort(a, a + 5);
fill(t, t + 14, 0);
for (int i = 0; i < 5; i++) {
t[a[i]]++;
if (m < t[a[i]])
m = t[a[i]];
}
int flag = 0;
if (a[0] == 1 && a[1] == 10 && a[2] == 11 && a[3] == 12 && a[4] == 13) {
str(3);
continue;
}
for (int i = 1; i < 5 && a[i - 1] + 1 == a[i]; i++)
flag = i;
if (flag == 4) {
str(3);
continue;
}
if (m == 4) {
cout << "four card" << endl;
continue;
}
if (m == 3) {
int f = 1;
for (int i = 1; i <= 13; i++) {
if (t[i] == 2)
f = 0;
}
if (!f) {
cout << "full house" << endl;
continue;
}
ans = 2;
}
for (int i = 1; i <= 13; i++) {
if (!ans && t[i] == 2)
ans = 1;
if (ans != 1 && t[i] == 2)
ans = 0;
}
if (ans == -1)
ans = 4;
str(ans);
}
return 0;
} | replace | 14 | 15 | 14 | 15 | TLE | |
p00038 | C++ | Time Limit Exceeded | #include <algorithm>
#include <iostream>
using namespace std;
bool isstraight(int c[]);
int main() {
int card[5];
while (scanf("%d,%d,%d,%d,%d", &card[0], &card[1], &card[2], &card[3],
&card[4])) {
sort(card, card + 5);
int n = 0;
for (int i = 0; i < 4; i++) {
for (int j = i + 1; j < 5; j++) {
if (card[i] == card[j]) {
n++;
}
}
}
switch (n) {
case 1:
cout << "one pair" << endl;
break;
case 2:
cout << "two pair" << endl;
break;
case 3:
cout << "three card" << endl;
break;
case 4:
cout << "full house" << endl;
break;
case 6:
cout << "four card" << endl;
break;
case 10:
cout << "four card" << endl;
break;
default:
if (isstraight(card)) {
cout << "straight" << endl;
} else {
cout << "null" << endl;
}
break;
}
}
return 0;
}
bool isstraight(int c[]) {
for (int i = 1; i < 9; i++) {
if (c[0] == i && c[1] == i + 1 && c[2] == i + 2 && c[3] == i + 3 &&
c[4] == i + 4) {
return true;
}
if (c[0] == 1 && c[1] == 10 && c[2] == 11 && c[3] == 12 && c[4] == 13) {
return true;
}
}
return false;
} | #include <algorithm>
#include <iostream>
using namespace std;
bool isstraight(int c[]);
int main() {
int card[5];
while (~scanf("%d,%d,%d,%d,%d", &card[0], &card[1], &card[2], &card[3],
&card[4])) {
sort(card, card + 5);
int n = 0;
for (int i = 0; i < 4; i++) {
for (int j = i + 1; j < 5; j++) {
if (card[i] == card[j]) {
n++;
}
}
}
switch (n) {
case 1:
cout << "one pair" << endl;
break;
case 2:
cout << "two pair" << endl;
break;
case 3:
cout << "three card" << endl;
break;
case 4:
cout << "full house" << endl;
break;
case 6:
cout << "four card" << endl;
break;
case 10:
cout << "four card" << endl;
break;
default:
if (isstraight(card)) {
cout << "straight" << endl;
} else {
cout << "null" << endl;
}
break;
}
}
return 0;
}
bool isstraight(int c[]) {
for (int i = 1; i < 9; i++) {
if (c[0] == i && c[1] == i + 1 && c[2] == i + 2 && c[3] == i + 3 &&
c[4] == i + 4) {
return true;
}
if (c[0] == 1 && c[1] == 10 && c[2] == 11 && c[3] == 12 && c[4] == 13) {
return true;
}
}
return false;
} | replace | 9 | 11 | 9 | 11 | TLE | |
p00038 | 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 card[5];
int c[13];
void solve() {
memset(c, 0, sizeof(c));
REP(i, 5) { c[card[i] - 1]++; }
bool f1 = false, f2 = false;
REP(i, 13) {
if (c[i] >= 4) {
f1 = true;
}
}
if (f1) {
cout << "four card" << endl;
return;
}
REP(i, 13) {
if (c[i] == 3) {
f1 = true;
} else if (c[i] == 2) {
f2 = true;
}
}
if (f1 && f2) {
cout << "full house" << endl;
return;
}
f1 = f2 = false;
REP(i, 10) {
bool f = true;
REP(j, 5) {
if (c[(i + j) % 13] != 1) {
f = false;
}
}
if (f) {
f1 = true;
}
}
if (f1) {
cout << "straight" << endl;
return;
}
REP(i, 13) {
if (c[i] == 3) {
f1 = true;
}
}
if (f1) {
cout << "three card" << endl;
return;
}
int k = 0;
REP(i, 13) {
if (c[i] == 2) {
k++;
}
}
if (k == 2) {
cout << "two pair" << endl;
} else if (k == 1) {
cout << "one pair" << endl;
} else {
cout << "null" << endl;
}
}
int main() {
while (
scanf("%d,%d,%d,%d,%d", card, card + 1, card + 2, card + 3, card + 4)) {
solve();
}
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 card[5];
int c[13];
void solve() {
memset(c, 0, sizeof(c));
REP(i, 5) { c[card[i] - 1]++; }
bool f1 = false, f2 = false;
REP(i, 13) {
if (c[i] >= 4) {
f1 = true;
}
}
if (f1) {
cout << "four card" << endl;
return;
}
REP(i, 13) {
if (c[i] == 3) {
f1 = true;
} else if (c[i] == 2) {
f2 = true;
}
}
if (f1 && f2) {
cout << "full house" << endl;
return;
}
f1 = f2 = false;
REP(i, 10) {
bool f = true;
REP(j, 5) {
if (c[(i + j) % 13] != 1) {
f = false;
}
}
if (f) {
f1 = true;
}
}
if (f1) {
cout << "straight" << endl;
return;
}
REP(i, 13) {
if (c[i] == 3) {
f1 = true;
}
}
if (f1) {
cout << "three card" << endl;
return;
}
int k = 0;
REP(i, 13) {
if (c[i] == 2) {
k++;
}
}
if (k == 2) {
cout << "two pair" << endl;
} else if (k == 1) {
cout << "one pair" << endl;
} else {
cout << "null" << endl;
}
}
int main() {
while (scanf("%d,%d,%d,%d,%d", card, card + 1, card + 2, card + 3,
card + 4) != EOF) {
solve();
}
return 0;
} | replace | 76 | 78 | 76 | 78 | TLE | |
p00038 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(), (c).end())
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;
int main(void) {
for (;;) {
int n[5];
char c;
REP(i, 5) {
if (i)
cin >> c;
if ((scanf("%d", &n[i])) == 0)
return 0;
}
int num[16];
REP(i, 16) num[i] = 0;
REP(i, 5)++ num[n[i]];
num[14] = num[1];
string s = "null";
REP(i, 11) {
int st = 0;
REP(j, 5) if (num[i + j])++ st;
if (st == 5)
s = "straight";
}
int pa = 0;
REP(i, 5) REP(j, i) if (n[i] == n[j])++ pa;
if (pa == 1)
s = "one pair";
if (pa == 2)
s = "two pair";
if (pa == 3)
s = "three card";
if (pa == 4)
s = "full house";
if (pa == 6)
s = "four card";
cout << s << endl;
}
} | #include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(), (c).end())
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;
int main(void) {
for (;;) {
int n[5];
char c;
REP(i, 5) {
if (i)
cin >> c;
n[i] = 0;
cin >> n[i];
if (n[i] == 0)
return 0;
}
int num[16];
REP(i, 16) num[i] = 0;
REP(i, 5)++ num[n[i]];
num[14] = num[1];
string s = "null";
REP(i, 11) {
int st = 0;
REP(j, 5) if (num[i + j])++ st;
if (st == 5)
s = "straight";
}
int pa = 0;
REP(i, 5) REP(j, i) if (n[i] == n[j])++ pa;
if (pa == 1)
s = "one pair";
if (pa == 2)
s = "two pair";
if (pa == 3)
s = "three card";
if (pa == 4)
s = "full house";
if (pa == 6)
s = "four card";
cout << s << endl;
}
} | replace | 15 | 16 | 15 | 18 | TLE | |
p00038 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int main() {
int c;
int cards[14], pairs[5];
while (scanf("%d", &c), c) {
memset(cards, 0, sizeof(cards));
memset(pairs, 0, sizeof(pairs));
cards[c]++;
for (int i = 0; i < 4; i++) {
scanf(",%d", &c);
cards[c]++;
}
for (int i = 1; i <= 13; i++) {
pairs[cards[i]]++;
}
if (pairs[4]) {
cout << "four card" << endl;
} else if (pairs[3] && pairs[2]) {
cout << "full house" << endl;
} else if (pairs[1] == 5) {
int i = 1;
for (; i <= 10; i++) {
if (cards[i] && cards[i + 1] && cards[i + 2] && cards[i + 3] &&
cards[((i + 3) % 13) + 1]) {
cout << "straight" << endl;
break;
}
}
if (i > 10)
cout << "null" << endl;
} else if (pairs[3]) {
cout << "three card" << endl;
} else if (pairs[2] == 2) {
cout << "two pair" << endl;
} else if (pairs[2]) {
cout << "one pair" << endl;
} else {
cout << "null" << endl;
}
}
return 0;
} | #include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int main() {
int c;
int cards[14], pairs[5];
while (scanf("%d", &c) != -1) {
memset(cards, 0, sizeof(cards));
memset(pairs, 0, sizeof(pairs));
cards[c]++;
for (int i = 0; i < 4; i++) {
scanf(",%d", &c);
cards[c]++;
}
for (int i = 1; i <= 13; i++) {
pairs[cards[i]]++;
}
if (pairs[4]) {
cout << "four card" << endl;
} else if (pairs[3] && pairs[2]) {
cout << "full house" << endl;
} else if (pairs[1] == 5) {
int i = 1;
for (; i <= 10; i++) {
if (cards[i] && cards[i + 1] && cards[i + 2] && cards[i + 3] &&
cards[((i + 3) % 13) + 1]) {
cout << "straight" << endl;
break;
}
}
if (i > 10)
cout << "null" << endl;
} else if (pairs[3]) {
cout << "three card" << endl;
} else if (pairs[2] == 2) {
cout << "two pair" << endl;
} else if (pairs[2]) {
cout << "one pair" << endl;
} else {
cout << "null" << endl;
}
}
return 0;
} | replace | 9 | 10 | 9 | 10 | TLE | |
p00039 | C++ | Time Limit Exceeded | #include <iostream>
#include <vector>
using namespace std;
int changeTheChar(char c) {
if (c == 'I') {
return 1;
} else if (c == 'V') {
return 5;
} else if (c == 'X') {
return 10;
} else if (c == 'L') {
return 50;
} else if (c == 'C') {
return 100;
} else if (c == 'D') {
return 500;
} else if (c == 'M') {
return 1000;
}
return 0;
}
int main() {
while (true) {
string str;
cin >> str;
vector<int> roman(str.size(), 0);
// ????????????
for (int i = 0; i < str.size(); i++) {
roman[i] = changeTheChar(str[i]);
}
for (int i = 0; i < roman.size(); i++) {
// cout << roman[i] << " ";
}
int res = 0;
while (roman.size() > 0) {
int maxI = 0;
int maxIndex;
// ?????§???????´¢
for (int i = roman.size() - 1; i >= 0; i--) {
if (maxI <= roman[i]) {
maxI = roman[i];
maxIndex = i;
}
}
// cout << maxIndex << endl;
// cout << maxI << endl;
if (maxIndex != 0) {
res += roman[maxIndex] - roman[maxIndex - 1];
roman.erase(roman.begin());
roman.erase(roman.begin());
} else {
res += roman[maxIndex];
roman.erase(roman.begin());
}
// cout << res << endl;
}
cout << res << endl;
}
return 0;
} | #include <iostream>
#include <vector>
using namespace std;
int changeTheChar(char c) {
if (c == 'I') {
return 1;
} else if (c == 'V') {
return 5;
} else if (c == 'X') {
return 10;
} else if (c == 'L') {
return 50;
} else if (c == 'C') {
return 100;
} else if (c == 'D') {
return 500;
} else if (c == 'M') {
return 1000;
}
return 0;
}
int main() {
string str;
while (cin >> str) {
vector<int> roman(str.size(), 0);
// ????????????
for (int i = 0; i < str.size(); i++) {
roman[i] = changeTheChar(str[i]);
}
for (int i = 0; i < roman.size(); i++) {
// cout << roman[i] << " ";
}
int res = 0;
while (roman.size() > 0) {
int maxI = 0;
int maxIndex;
// ?????§???????´¢
for (int i = roman.size() - 1; i >= 0; i--) {
if (maxI <= roman[i]) {
maxI = roman[i];
maxIndex = i;
}
}
// cout << maxIndex << endl;
// cout << maxI << endl;
if (maxIndex != 0) {
res += roman[maxIndex] - roman[maxIndex - 1];
roman.erase(roman.begin());
roman.erase(roman.begin());
} else {
res += roman[maxIndex];
roman.erase(roman.begin());
}
// cout << res << endl;
}
cout << res << endl;
}
return 0;
} | replace | 26 | 31 | 26 | 28 | TLE | |
p00040 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
using namespace std;
string change(int a, int b, string str) {
for (int i = 0; i < str.size(); i++)
str[i] = ((str[i] - 'a') * a + b) % 26 + 'a';
return str;
}
string out(int a, int b, string str) {
for (int i = 0; i < str.size(); i++) {
if ('a' <= str[i] && str[i] <= 'z') {
for (int j = 0; j < 26; j++) {
if ((j * a + b) % 26 + 'a' == str[i]) {
str[i] = j + 'a';
break;
}
}
}
}
return str;
}
int main() {
int N;
cin >> N;
for (int i = 0; i < N; i++) {
string str;
getchar();
getline(cin, str);
for (int j = 1;; j++) {
for (int k = 0; k < 26; k++) {
for (int l = 0; l < str.size() - 3; l++) {
if (change(j, k, "that") == str.substr(l, 4)) {
cout << out(j, k, str) << endl;
goto exit;
}
if (change(j, k, "this") == str.substr(l, 4)) {
cout << out(j, k, str) << endl;
goto exit;
}
}
}
}
exit:;
}
return 0;
} | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
using namespace std;
string change(int a, int b, string str) {
for (int i = 0; i < str.size(); i++)
str[i] = ((str[i] - 'a') * a + b) % 26 + 'a';
return str;
}
string out(int a, int b, string str) {
for (int i = 0; i < str.size(); i++) {
if ('a' <= str[i] && str[i] <= 'z') {
for (int j = 0; j < 26; j++) {
if ((j * a + b) % 26 + 'a' == str[i]) {
str[i] = j + 'a';
break;
}
}
}
}
return str;
}
int main() {
int N;
cin >> N;
for (int i = 0; i < N; i++) {
string str;
if (!i)
getchar();
getline(cin, str);
for (int j = 1;; j++) {
for (int k = 0; k < 26; k++) {
for (int l = 0; l < str.size() - 3; l++) {
if (change(j, k, "that") == str.substr(l, 4)) {
cout << out(j, k, str) << endl;
goto exit;
}
if (change(j, k, "this") == str.substr(l, 4)) {
cout << out(j, k, str) << endl;
goto exit;
}
}
}
}
exit:;
}
return 0;
} | replace | 30 | 31 | 30 | 32 | TLE | |
p00041 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
using namespace std;
const int N = 4;
const int MAX_E = 100;
const char ope[] = {'+', '-', '*'};
bool is_end(vector<int> a) {
REP(i, a.size()) if (a[i] != 0) return false;
return true;
}
int calc(int type, int val, int x) {
if (type == 0)
return val - x;
if (type == 1)
return x - val;
if (type == 2)
return val / x;
}
bool used[5][5][300];
string memo[5][5][300];
string rec(const vector<int> &nums, int l, int r, int val) {
if (used[l][r][val + MAX_E])
return memo[l][r][val + MAX_E];
used[l][r][val + MAX_E] = true;
string &res = memo[l][r][val + MAX_E];
if (r - l == 1) {
if (nums[l] == val) {
return res = to_string(val);
} else {
return res = "";
}
}
for (int k = 1; l + k < r; k++) {
for (int x = -MAX_E; x <= MAX_E; x++) {
for (int type = 0; type < 3; type++) {
if (type == 2 && (x == 0 || val % x != 0))
continue;
int y = calc(type, val, x);
string ls = rec(nums, l, l + k, x);
string rs = rec(nums, l + k, r, y);
if (ls == "")
continue;
if (rs == "")
continue;
if (nums.size() == 4)
return res = "(" + ls + ope[type] + rs + ")";
}
}
}
return res = "";
}
int main() {
while (true) {
vector<int> nums(N);
REP(i, N) cin >> nums[i];
if (is_end(nums))
break;
bool exist = false;
sort(nums.begin(), nums.end());
do {
memset(used, 0, sizeof(used));
string s = rec(nums, 0, nums.size(), 10);
if (s != "") {
cout << s << endl;
exist = true;
break;
}
} while (next_permutation(nums.begin(), nums.end()));
if (!exist) {
cout << "0" << endl;
}
}
return 0;
} | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
using namespace std;
const int N = 4;
const int MAX_E = 72;
const char ope[] = {'+', '-', '*'};
bool is_end(vector<int> a) {
REP(i, a.size()) if (a[i] != 0) return false;
return true;
}
int calc(int type, int val, int x) {
if (type == 0)
return val - x;
if (type == 1)
return x - val;
if (type == 2)
return val / x;
}
bool used[5][5][300];
string memo[5][5][300];
string rec(const vector<int> &nums, int l, int r, int val) {
if (used[l][r][val + MAX_E])
return memo[l][r][val + MAX_E];
used[l][r][val + MAX_E] = true;
string &res = memo[l][r][val + MAX_E];
if (r - l == 1) {
if (nums[l] == val) {
return res = to_string(val);
} else {
return res = "";
}
}
for (int k = 1; l + k < r; k++) {
for (int x = -MAX_E; x <= MAX_E; x++) {
for (int type = 0; type < 3; type++) {
if (type == 2 && (x == 0 || val % x != 0))
continue;
int y = calc(type, val, x);
string ls = rec(nums, l, l + k, x);
string rs = rec(nums, l + k, r, y);
if (ls == "")
continue;
if (rs == "")
continue;
if (nums.size() == 4)
return res = "(" + ls + ope[type] + rs + ")";
}
}
}
return res = "";
}
int main() {
while (true) {
vector<int> nums(N);
REP(i, N) cin >> nums[i];
if (is_end(nums))
break;
bool exist = false;
sort(nums.begin(), nums.end());
do {
memset(used, 0, sizeof(used));
string s = rec(nums, 0, nums.size(), 10);
if (s != "") {
cout << s << endl;
exist = true;
break;
}
} while (next_permutation(nums.begin(), nums.end()));
if (!exist) {
cout << "0" << endl;
}
}
return 0;
} | replace | 6 | 7 | 6 | 7 | TLE | |
p00041 | C++ | Time Limit Exceeded | #include <cstdio>
using namespace std;
int a[4];
int c[8];
int k;
int calc() {
int op = c[k++];
int ret = 0;
if (op >= 0) {
ret = op;
} else if (op >= -3) {
int x = calc();
int y = calc();
if (op == -1) {
ret = x + y;
} else if (op == -2) {
ret = x - y;
} else {
ret = x * y;
}
} else {
throw 0;
}
return ret;
}
void print() {
int op = c[k++];
if (op >= 0) {
printf("%d", op);
} else {
char ch;
if (op == -1) {
ch = '+';
} else if (op == -2) {
ch = '-';
} else {
ch = '*';
}
putchar('(');
print();
printf(" %c ", ch);
print();
putchar(')');
}
}
const int brnum = 3000000;
void solve(int i, int S, int oprem, int numrem) {
if (i == 6) {
for (int j = 0; j < 4; ++j) {
if (S >> j & 1) {
c[6] = a[j];
}
}
try {
k = 0;
if (calc() == 10 && k == 7) {
k = 0;
for (int j = 0; j < brnum; ++j)
putchar('(');
print();
for (int j = 0; j < brnum; ++j)
putchar(')');
puts("");
throw "";
}
} catch (int) {
}
return;
}
if (oprem > 0) {
for (int op = -1; op >= -3; --op) {
c[i] = op;
solve(i + 1, S, oprem - 1, numrem + 1);
}
}
if (numrem > 0) {
for (int j = 0; j < 4; ++j) {
if (S >> j & 1) {
c[i] = a[j];
solve(i + 1, S ^ 1 << j, oprem, numrem - 1);
}
}
}
}
int main() {
while (1) {
for (int i = 0; i < 8; ++i) {
c[i] = -9;
}
for (int i = 0; i < 4; ++i) {
scanf("%d", &a[i]);
}
if (a[0] == 0) {
break;
}
try {
solve(0, 15, 3, 0);
puts("0");
} catch (...) {
}
}
} | #include <cstdio>
using namespace std;
int a[4];
int c[8];
int k;
int calc() {
int op = c[k++];
int ret = 0;
if (op >= 0) {
ret = op;
} else if (op >= -3) {
int x = calc();
int y = calc();
if (op == -1) {
ret = x + y;
} else if (op == -2) {
ret = x - y;
} else {
ret = x * y;
}
} else {
throw 0;
}
return ret;
}
void print() {
int op = c[k++];
if (op >= 0) {
printf("%d", op);
} else {
char ch;
if (op == -1) {
ch = '+';
} else if (op == -2) {
ch = '-';
} else {
ch = '*';
}
putchar('(');
print();
printf(" %c ", ch);
print();
putchar(')');
}
}
const int brnum = 100000;
void solve(int i, int S, int oprem, int numrem) {
if (i == 6) {
for (int j = 0; j < 4; ++j) {
if (S >> j & 1) {
c[6] = a[j];
}
}
try {
k = 0;
if (calc() == 10 && k == 7) {
k = 0;
for (int j = 0; j < brnum; ++j)
putchar('(');
print();
for (int j = 0; j < brnum; ++j)
putchar(')');
puts("");
throw "";
}
} catch (int) {
}
return;
}
if (oprem > 0) {
for (int op = -1; op >= -3; --op) {
c[i] = op;
solve(i + 1, S, oprem - 1, numrem + 1);
}
}
if (numrem > 0) {
for (int j = 0; j < 4; ++j) {
if (S >> j & 1) {
c[i] = a[j];
solve(i + 1, S ^ 1 << j, oprem, numrem - 1);
}
}
}
}
int main() {
while (1) {
for (int i = 0; i < 8; ++i) {
c[i] = -9;
}
for (int i = 0; i < 4; ++i) {
scanf("%d", &a[i]);
}
if (a[0] == 0) {
break;
}
try {
solve(0, 15, 3, 0);
puts("0");
} catch (...) {
}
}
} | replace | 50 | 51 | 50 | 51 | TLE | |
p00041 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
int d[4];
bool flg = false;
string s = "+-*";
int calc(int a, int op, int b) {
if (op == 0)
return a + b;
if (op == 1)
return a - b;
return a * b;
}
bool solve(int a, int b, int c) {
flg++;
if (calc(calc(calc(d[0], a, d[1]), b, d[2]), c, d[3]) == 10) {
return printf("(((%d %c %d) %c %d) %c %d)\n", d[0], s[a], d[1], s[b], d[2],
s[c], d[3]);
}
if (calc(calc(d[0], a, d[1]), b, calc(d[2], c, d[3])) == 10) {
return printf("((%d %c %d) %c (%d %c %d))\n", d[0], s[a], d[1], s[b], d[2],
s[c], d[3]);
}
if (calc(calc(d[0], a, calc(d[1], b, d[2])), c, d[3]) == 10) {
return printf("((%d %c (%d %c %d)) %c %d)\n", d[0], s[a], d[1], s[b], d[2],
s[c], d[3]);
}
return flg = false;
}
bool judge() { rep(i, 3) rep(j, 3) rep(k, 3) if (solve(i, j, k)) return true; }
int main() {
while (flg = true) {
rep(i, 4) cin >> d[i];
if (!d[0] & d[1] & d[2] & d[3])
break;
sort(d, d + 4);
do
if (judge())
break;
while (next_permutation(d, d + 4));
if (!flg)
puts("0");
}
} | #include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
int d[4];
bool flg = false;
string s = "+-*";
int calc(int a, int op, int b) {
if (op == 0)
return a + b;
if (op == 1)
return a - b;
return a * b;
}
bool solve(int a, int b, int c) {
flg++;
if (calc(calc(calc(d[0], a, d[1]), b, d[2]), c, d[3]) == 10) {
return printf("(((%d %c %d) %c %d) %c %d)\n", d[0], s[a], d[1], s[b], d[2],
s[c], d[3]);
}
if (calc(calc(d[0], a, d[1]), b, calc(d[2], c, d[3])) == 10) {
return printf("((%d %c %d) %c (%d %c %d))\n", d[0], s[a], d[1], s[b], d[2],
s[c], d[3]);
}
if (calc(calc(d[0], a, calc(d[1], b, d[2])), c, d[3]) == 10) {
return printf("((%d %c (%d %c %d)) %c %d)\n", d[0], s[a], d[1], s[b], d[2],
s[c], d[3]);
}
return flg = false;
}
bool judge() { rep(i, 3) rep(j, 3) rep(k, 3) if (solve(i, j, k)) return true; }
int main() {
while (flg = true) {
rep(i, 4) cin >> d[i];
if (!d[0] && !d[1] && !d[2] && !d[3])
break;
sort(d, d + 4);
do
if (judge())
break;
while (next_permutation(d, d + 4));
if (!flg)
puts("0");
}
} | replace | 39 | 40 | 39 | 40 | TLE | |
p00042 | C++ | Runtime Error | #include <algorithm>
#include <cstdio>
#include <iostream>
#include <list>
#define MAX(x, y) ((x > y) ? x : y)
using namespace std;
FILE *wfp = fopen("output.txt", "w");
FILE *rfp = fopen("input.txt", "r");
int W;
int N;
int kati[10000];
int omosa[10000];
int DP[1005][10005]; //[i][j]i番目までにjより小さくなるような価値
int DP_W[10005]; // そのときの重さ
int CASE = 0;
int main() {
/// wfp=stdout;
/// rfp=stdin;
while (true) {
CASE++;
fill(DP_W, DP_W + 10005, 0);
for (int i = 0; i < 10000; i++)
DP[0][i] = 0;
for (int i = 0; i < 1000; i++)
DP[i][0] = 0;
fscanf(rfp, "%d", &W);
if (W == 0)
break;
fscanf(rfp, "%d", &N);
for (int i = 0; i < N; i++) {
fscanf(rfp, "%d,%d", &kati[i], &omosa[i]);
}
for (int i = 0; i < N; i++) {
for (int j = 0; j < W; j++) {
if (j + 1 - omosa[i] >= 0)
DP[i + 1][j + 1] =
MAX(DP[i][j + 1], DP[i][j + 1 - omosa[i]] + kati[i]);
else
DP[i + 1][j + 1] = DP[i][j + 1];
}
}
DP_W[0] = 0;
for (int i = 1; i <= W; i++) {
if (DP[N][i] == DP[N][i - 1])
DP_W[i] = DP_W[i - 1];
else
DP_W[i] = i;
}
fprintf(wfp, "Case %d:\n", CASE);
fprintf(wfp, "%d\n", DP[N][W]);
fprintf(wfp, "%d\n", DP_W[W]);
}
fclose(rfp);
fclose(wfp);
return 0;
} | #include <algorithm>
#include <cstdio>
#include <iostream>
#include <list>
#define MAX(x, y) ((x > y) ? x : y)
using namespace std;
FILE *wfp = fopen("output.txt", "w");
FILE *rfp = fopen("input.txt", "r");
int W;
int N;
int kati[10000];
int omosa[10000];
int DP[1005][10005]; //[i][j]i番目までにjより小さくなるような価値
int DP_W[10005]; // そのときの重さ
int CASE = 0;
int main() {
wfp = stdout;
rfp = stdin;
while (true) {
CASE++;
fill(DP_W, DP_W + 10005, 0);
for (int i = 0; i < 10000; i++)
DP[0][i] = 0;
for (int i = 0; i < 1000; i++)
DP[i][0] = 0;
fscanf(rfp, "%d", &W);
if (W == 0)
break;
fscanf(rfp, "%d", &N);
for (int i = 0; i < N; i++) {
fscanf(rfp, "%d,%d", &kati[i], &omosa[i]);
}
for (int i = 0; i < N; i++) {
for (int j = 0; j < W; j++) {
if (j + 1 - omosa[i] >= 0)
DP[i + 1][j + 1] =
MAX(DP[i][j + 1], DP[i][j + 1 - omosa[i]] + kati[i]);
else
DP[i + 1][j + 1] = DP[i][j + 1];
}
}
DP_W[0] = 0;
for (int i = 1; i <= W; i++) {
if (DP[N][i] == DP[N][i - 1])
DP_W[i] = DP_W[i - 1];
else
DP_W[i] = i;
}
fprintf(wfp, "Case %d:\n", CASE);
fprintf(wfp, "%d\n", DP[N][W]);
fprintf(wfp, "%d\n", DP_W[W]);
}
fclose(rfp);
fclose(wfp);
return 0;
} | replace | 22 | 24 | 22 | 24 | -11 |