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
p03262
C++
Runtime Error
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define loop(i, x, n) for (int i = (x); i < (n); i++) #define all(v) (v).begin(), (v).end() #define int long long using namespace std; const int MOD = 1e9 + 7; const int INF = 1e10; template <typename T> void cmax(T &a, T b) { a = max(a, b); } template <typename T> void cmin(T &a, T b) { a = min(a, b); } inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } signed main() { int n, x; cin >> n >> x; vector<int> a(n); vector<int> dif(n - 1); rep(i, n) cin >> a[i]; if (n == 1) { cout << abs(x - a[0]) << endl; return 0; } rep(i, n) dif[i] = abs(a[i] - x); int ans = dif[0]; rep(i, n) ans = gcd(ans, dif[i]); cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define loop(i, x, n) for (int i = (x); i < (n); i++) #define all(v) (v).begin(), (v).end() #define int long long using namespace std; const int MOD = 1e9 + 7; const int INF = 1e10; template <typename T> void cmax(T &a, T b) { a = max(a, b); } template <typename T> void cmin(T &a, T b) { a = min(a, b); } inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } signed main() { int n, x; cin >> n >> x; vector<int> a(n); vector<int> dif(n); rep(i, n) cin >> a[i]; if (n == 1) { cout << abs(x - a[0]) << endl; return 0; } rep(i, n) dif[i] = abs(a[i] - x); int ans = dif[0]; rep(i, n) ans = gcd(ans, dif[i]); cout << ans << endl; return 0; }
replace
17
18
17
18
0
p03262
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int gcd(int x, int y) { if (y == 0) return x; return gcd(y, x % y); } int main() { int n, x; cin >> n >> x; vector<int> y(n); y[0] = x; for (int i = 1; i <= n; i++) { cin >> y[i]; } sort(y.begin(), y.end()); vector<int> dif(n); for (int i = 0; i < n; i++) { dif[i] = y[i + 1] - y[i]; } int ans = dif[0]; for (int i = 1; i < n; i++) { ans = gcd(ans, dif[i]); } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int gcd(int x, int y) { if (y == 0) return x; return gcd(y, x % y); } int main() { int n, x; cin >> n >> x; vector<int> y(n + 1); y[0] = x; for (int i = 1; i <= n; i++) { cin >> y[i]; } sort(y.begin(), y.end()); vector<int> dif(n); for (int i = 0; i < n; i++) { dif[i] = y[i + 1] - y[i]; } int ans = dif[0]; for (int i = 1; i < n; i++) { ans = gcd(ans, dif[i]); } cout << ans << endl; }
replace
12
13
12
13
0
p03262
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define rep(i, m, n) for (int i = m; i < (n); i++) #define print(x) cout << (x) << endl; #define printv(x) \ for (int i = 0; i < x.size(); i++) { \ cout << (x[i]) << " "; \ } \ cout << endl; #define printa(x, n) \ for (int i = 0; i < n; i++) { \ cout << (x[i]) << " "; \ } \ cout << endl; #define printa2(x, m, n) \ for (int i = 0; i < m; i++) { \ for (int j = 0; j < n; j++) { \ cout << x[i][j] << " "; \ } \ cout << endl; \ } #define INF (1e9) typedef long long ll; typedef struct { int x; int y; } P; ll my_gcd(ll m, ll n) { // 引数に0がある場合は0を返す if ((0 == m) || (0 == n)) return 0; // ユークリッドの方法 while (m != n) { if (m > n) m = m - n; else n = n - m; } return m; } // gcd using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int N, X; ll x[100010]; cin >> N >> X; rep(i, 0, N) { cin >> x[i]; } ll d[100010] = {}; rep(i, 0, N) { d[i] = abs(X - x[i]); } ll ans = d[0]; rep(i, 1, N) { ans = my_gcd(ans, d[i]); } print(ans); }
#include <bits/stdc++.h> #define rep(i, m, n) for (int i = m; i < (n); i++) #define print(x) cout << (x) << endl; #define printv(x) \ for (int i = 0; i < x.size(); i++) { \ cout << (x[i]) << " "; \ } \ cout << endl; #define printa(x, n) \ for (int i = 0; i < n; i++) { \ cout << (x[i]) << " "; \ } \ cout << endl; #define printa2(x, m, n) \ for (int i = 0; i < m; i++) { \ for (int j = 0; j < n; j++) { \ cout << x[i][j] << " "; \ } \ cout << endl; \ } #define INF (1e9) typedef long long ll; typedef struct { int x; int y; } P; ll my_gcd(ll m, ll n) { // 引数に0がある場合は0を返す if ((0 == m) || (0 == n)) return 0; // ユークリッドの方法 while (m != n) { if (m > n) m = m - n; else n = n - m; } return m; } // gcd using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int N, X; ll x[100010]; cin >> N >> X; rep(i, 0, N) { cin >> x[i]; } ll d[100010] = {}; rep(i, 0, N) { d[i] = abs(X - x[i]); } ll ans = d[0]; ll d_tmp[100010] = {}; if (N % 2 == 0) { rep(j, 0, N / 2) { d_tmp[j] = my_gcd(d[2 * j], d[2 * j + 1]); } rep(j, 0, N / 2) { ans = my_gcd(ans, d_tmp[j]); } } else { rep(j, 0, (N - 1) / 2) { d_tmp[j] = my_gcd(d[2 * j], d[2 * j + 1]); } rep(j, 0, (N - 1) / 2) { ans = my_gcd(ans, d_tmp[j]); } ans = my_gcd(ans, d[N - 1]); } print(ans); }
replace
53
54
53
62
TLE
p03262
C++
Time Limit Exceeded
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <list> #include <map> #include <set> #include <tuple> #include <vector> using namespace std; int main() { vector<int> vi; int N, X, dummy, ans; dummy = scanf("%d %d", &N, &X); vi.push_back(X); int tmp; for (int i = 0; i < N; i++) { dummy = scanf("%d", &tmp); vi.push_back(tmp); } sort(vi.begin(), vi.end()); int size = vi.size(); for (int i = 0; i < size - 1; i++) { vi[i] = vi[i + 1] - vi[i]; } vi.pop_back(); vi.erase(unique(vi.begin(), vi.end()), vi.end()); for (int i = vi[0]; i > 0; i--) { bool NG = false; for (auto itr = vi.begin(); itr != vi.end(); itr++) { if (*itr % i != 0) { NG = true; break; } } if (!NG) { printf("%d\n", i); break; } } return 0; }
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <list> #include <map> #include <set> #include <tuple> #include <vector> using namespace std; int main() { vector<int> vi; int N, X, dummy, ans; dummy = scanf("%d %d", &N, &X); vi.push_back(X); int tmp; for (int i = 0; i < N; i++) { dummy = scanf("%d", &tmp); vi.push_back(tmp); } sort(vi.begin(), vi.end()); int size = vi.size(); for (int i = 0; i < size - 1; i++) { vi[i] = vi[i + 1] - vi[i]; } vi.pop_back(); sort(vi.begin(), vi.end()); vi.erase(unique(vi.begin(), vi.end()), vi.end()); for (int i = vi[0]; i > 0; i--) { bool NG = false; for (auto itr = vi.begin(); itr != vi.end(); itr++) { if (*itr % i != 0) { NG = true; break; } } if (!NG) { printf("%d\n", i); break; } } return 0; }
insert
33
33
33
34
TLE
p03262
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { int r; while (b != 0) { r = a % b; a = b; b = r; } return a; } int main() { long long n, x, i, ans, dif[10009]; vector<long long> a; cin >> n >> x; a.push_back(x); for (i = 0; i < n; i++) { cin >> x; a.push_back(x); } sort(a.begin(), a.end()); for (i = 0; i < n; i++) { dif[i] = a[i + 1] - a[i]; } ans = gcd(dif[0], dif[1]); for (i = 2; i < n; i++) { ans = gcd(ans, dif[i]); } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { int r; while (b != 0) { r = a % b; a = b; b = r; } return a; } int main() { long long n, x, i, ans, dif[100090]; vector<long long> a; cin >> n >> x; a.push_back(x); for (i = 0; i < n; i++) { cin >> x; a.push_back(x); } sort(a.begin(), a.end()); for (i = 0; i < n; i++) { dif[i] = a[i + 1] - a[i]; } ans = gcd(dif[0], dif[1]); for (i = 2; i < n; i++) { ans = gcd(ans, dif[i]); } cout << ans << endl; return 0; }
replace
14
15
14
15
0
p03262
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; using ll = long long; int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int main() { int n, xxxx; cin >> n >> xxxx; vector<int> x(n + 1); x.at(0) = xxxx; for (int i = 1; i < n + 1; i++) cin >> x.at(i); sort(x.begin(), x.end()); int ans = x.at(1) - x.at(0); if (n != 1) { for (int i = 0; i < n; i++) { ans = gcd(ans, x.at(i + 2) - x.at(i + 1)); } } cout << ans; cout << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int main() { int n, xxxx; cin >> n >> xxxx; vector<int> x(n + 1); x.at(0) = xxxx; for (int i = 1; i < n + 1; i++) cin >> x.at(i); sort(x.begin(), x.end()); int ans = x.at(1) - x.at(0); for (int i = 0; i < n - 1; i++) { ans = gcd(ans, x.at(i + 2) - x.at(i + 1)); } cout << ans; cout << endl; }
replace
19
23
19
21
-6
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_range_check: __n (which is 4) >= this->size() (which is 4)
p03262
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { long long int z, n, x, a[10000], b[10000]; scanf("%I64d%I64d", &n, &x); for (int i = 0; i < n; i++) { scanf("%I64d", &a[i]); b[i] = abs(a[i] - x); } sort(b, b + n); z = b[0]; for (int i = 1; i < n; i++) { z = __gcd(z, b[i]); } printf("%I64d", z); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int z, n, x, a[100009], b[100009]; scanf("%I64d%I64d", &n, &x); for (int i = 0; i < n; i++) { scanf("%I64d", &a[i]); b[i] = abs(a[i] - x); } sort(b, b + n); z = b[0]; for (int i = 1; i < n; i++) { z = __gcd(z, b[i]); } printf("%I64d", z); return 0; }
replace
5
6
5
6
0
p03262
C++
Time Limit Exceeded
#include <cmath> #include <iostream> #include <queue> #include <vector> using namespace std; int gcd(int a, int b) { if (a <= 0 || b <= 0) return -1; if (a < b) gcd(b, a); int r = a % b; while (r) { a = b; b = r; } return b; } int main() { int N, X; cin >> N >> X; int D; vector<int> diff; for (int i = 0; i < N; i++) { int temp; cin >> temp; diff.push_back(abs(temp - X)); } D = diff[0]; for (auto it = diff.begin(); it != diff.end(); it++) { D = gcd(D, *it); } cout << D << endl; return 0; }
#include <cmath> #include <iostream> #include <queue> #include <vector> using namespace std; int gcd(int a, int b) { if (a <= 0 || b <= 0) return -1; if (a < b) gcd(b, a); int r = a % b; while (r) { a = b; b = r; r = a % b; } return b; } int main() { int N, X; cin >> N >> X; int D; vector<int> diff; for (int i = 0; i < N; i++) { int temp; cin >> temp; diff.push_back(abs(temp - X)); } D = diff[0]; for (auto it = diff.begin(); it != diff.end(); it++) { D = gcd(D, *it); } cout << D << endl; return 0; }
insert
17
17
17
18
TLE
p03262
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { while (!b) { a %= b; swap(a, b); } return a; } int main() { ios::sync_with_stdio(0); cin.tie(0); int n, x; cin >> n >> x; int g = 0; while (n--) { int y; cin >> y; g = gcd(abs(x - y), g); } cout << g << '\n'; }
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { while (b) { a %= b; swap(a, b); } return a; } int main() { ios::sync_with_stdio(0); cin.tie(0); int n, x; cin >> n >> x; int g = 0; while (n--) { int y; cin >> y; g = gcd(abs(x - y), g); } cout << g << '\n'; }
replace
4
5
4
5
-8
p03262
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define mod 1000000007 #define ALL(a) a.begin(), a.end() ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return a * b / gcd(a, b); } int main() { ll n, x; cin >> n >> x; ll c[x]; for (int i = 0; i < n; i++) cin >> c[i]; ll dis[n]; for (int i = 0; i < n; i++) { dis[i] = abs(c[i] - x); } ll ans = dis[0]; for (int i = 1; i < n; i++) { ans = gcd(ans, dis[i]); } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define mod 1000000007 #define ALL(a) a.begin(), a.end() ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return a * b / gcd(a, b); } int main() { ll n, x; cin >> n >> x; ll c[n]; for (int i = 0; i < n; i++) cin >> c[i]; ll dis[n]; for (int i = 0; i < n; i++) { dis[i] = abs(c[i] - x); } ll ans = dis[0]; for (int i = 1; i < n; i++) { ans = gcd(ans, dis[i]); } cout << ans << endl; return 0; }
replace
13
14
13
14
0
p03262
C++
Runtime Error
#include <cmath> #include <iostream> #include <vector> using namespace std; long long int gcd(long long int a, long long int b) { long long int r; if (a % b == 0) return b; else { r = a % b; return gcd(b, r); } } int main() { int N; long long int X; cin >> N >> X; vector<long long int> c(N); for (int i = 0; i < N; i++) cin >> c[i]; vector<long long int> d(N); for (int i = 0; i < N; i++) d[i] = abs(c[i] - X); long long int ans = 0LL; for (int i = 0; i < N; i++) { if (i == 0) { ans = gcd(d[0], d[1]); continue; } ans = gcd(d[i], ans); } cout << ans; }
#include <cmath> #include <iostream> #include <vector> using namespace std; long long int gcd(long long int a, long long int b) { long long int r; if (a % b == 0) return b; else { r = a % b; return gcd(b, r); } } int main() { int N; long long int X; cin >> N >> X; vector<long long int> c(N); for (int i = 0; i < N; i++) cin >> c[i]; vector<long long int> d(N); for (int i = 0; i < N; i++) d[i] = abs(c[i] - X); long long int ans = 0LL; for (int i = 0; i < N; i++) { if (N == 1) { ans = d[0]; break; } if (i == 0) { ans = gcd(d[0], d[1]); continue; } ans = gcd(d[i], ans); } cout << ans; }
insert
30
30
30
34
0
p03262
C++
Runtime Error
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int euclid_gcd(int a, int b) { int tmp_a, tmp_b; // tmp_a>tmp_b if (a < b) { tmp_a = b; tmp_b = a; } else { tmp_a = a; tmp_b = b; } if (tmp_b == 0) { return tmp_a; } else { return euclid_gcd(tmp_b, tmp_a % tmp_b); } } int gcd_multi(vector<int> x) { vector<int> gcds(x.size() / 2 + (x.size() % 2)); if (x.size() == 2) { return euclid_gcd(x[0], x[1]); } for (int i = 0; i < x.size() / 2; ++i) { gcds[i] = euclid_gcd(x[i * 2], x[i * 2 + 1]); } if (x.size() % 2 == 1) { gcds.back() = x.back(); } return gcd_multi(gcds); } int main(void) { int n, start; cin >> n >> start; vector<int> x(n); for (int i = 0; i < n; i++) { std::cin >> x[i]; } x.push_back(start); sort(x.begin(), x.end()); vector<int> w(n); for (int i = 0; i < n; i++) { w[i] = abs(x[i] - x[i + 1]); } cout << gcd_multi(w); return 0; }
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int euclid_gcd(int a, int b) { int tmp_a, tmp_b; // tmp_a>tmp_b if (a < b) { tmp_a = b; tmp_b = a; } else { tmp_a = a; tmp_b = b; } if (tmp_b == 0) { return tmp_a; } else { return euclid_gcd(tmp_b, tmp_a % tmp_b); } } int gcd_multi(vector<int> x) { vector<int> gcds(x.size() / 2 + (x.size() % 2)); if (x.size() == 1) { return x.front(); } if (x.size() == 2) { return euclid_gcd(x[0], x[1]); } for (int i = 0; i < x.size() / 2; ++i) { gcds[i] = euclid_gcd(x[i * 2], x[i * 2 + 1]); } if (x.size() % 2 == 1) { gcds.back() = x.back(); } return gcd_multi(gcds); } int main(void) { int n, start; cin >> n >> start; vector<int> x(n); for (int i = 0; i < n; i++) { std::cin >> x[i]; } x.push_back(start); sort(x.begin(), x.end()); vector<int> w(n); for (int i = 0; i < n; i++) { w[i] = abs(x[i] - x[i + 1]); } cout << gcd_multi(w); return 0; }
insert
30
30
30
34
0
p03262
C++
Runtime Error
/** * Problem: C. * Author: hkxadpall. * Date: 2018-09-01. * Upload: AtCoder. */ #include <algorithm> #include <iostream> #include <map> #include <queue> #include <set> #include <stdio.h> #include <string.h> #include <vector> using namespace std; namespace AuthorName { template <typename _TpInt> inline _TpInt read(); template <typename _TpRealnumber> inline double readr(); template <typename _TpInt> inline void write(_TpInt x); // template <typename _TpSwap> inline void swap(_TpSwap &x, _TpSwap &y); #define Max_N 10007 int n, k, nk, ns; int a[Max_N]; long long ans; int gcd(int a, int b) { return (b == 0) ? (a) : (gcd(b, a % b)); } int main() { n = read<int>(); a[0] = read<int>(); // int a; for (int i = 1; i <= n; i++) { a[i] = read<int>(); } sort(a, a + n + 1); int max_gcd = (a[1] - a[0]); for (int i = 2; i <= n; i++) { max_gcd = gcd(max_gcd, a[i] - a[0]); } write(max_gcd); return 0; } #define Getchar() getchar() template <typename _TpInt> inline _TpInt read() { register int flag = 1; register char c = Getchar(); while ((c > '9' || c < '0') && c != '-') c = Getchar(); if (c == '-') flag = -1, c = Getchar(); register _TpInt init = (c & 15); while ((c = Getchar()) <= '9' && c >= '0') init = (init << 3) + (init << 1) + (c & 15); return init * flag; } template <typename _TpRealnumber> inline double readr() { register int flag = 1; register char c = Getchar(); while ((c > '9' || c < '0') && c != '-') c = Getchar(); if (c == '-') flag = -1, c = Getchar(); register _TpRealnumber init = (c & 15); while ((c = Getchar()) <= '9' && c >= '0') init = init * 10 + (c & 15); if (c != '.') return init * flag; register _TpRealnumber l = 0.1; while ((c = Getchar()) <= '9' && c >= '0') init = init + (c & 15) * l, l *= 0.1; return init * flag; } template <typename _TpInt> inline void write(_TpInt x) { if (x < 0) { putchar('-'); write<_TpInt>(~x + 1); } else { if (x > 9) write<_TpInt>(x / 10); putchar(x % 10 + '0'); } } // template <typename _TpSwap> // inline void swap(_TpSwap &x, _TpSwap &y) // { // _TpSwap t = x; // x = y; // y = t; // } } // namespace AuthorName int main() { AuthorName::main(); return 0; }
/** * Problem: C. * Author: hkxadpall. * Date: 2018-09-01. * Upload: AtCoder. */ #include <algorithm> #include <iostream> #include <map> #include <queue> #include <set> #include <stdio.h> #include <string.h> #include <vector> using namespace std; namespace AuthorName { template <typename _TpInt> inline _TpInt read(); template <typename _TpRealnumber> inline double readr(); template <typename _TpInt> inline void write(_TpInt x); // template <typename _TpSwap> inline void swap(_TpSwap &x, _TpSwap &y); #define Max_N 100007 int n, k, nk, ns; int a[Max_N]; long long ans; int gcd(int a, int b) { return (b == 0) ? (a) : (gcd(b, a % b)); } int main() { n = read<int>(); a[0] = read<int>(); // int a; for (int i = 1; i <= n; i++) { a[i] = read<int>(); } sort(a, a + n + 1); int max_gcd = (a[1] - a[0]); for (int i = 2; i <= n; i++) { max_gcd = gcd(max_gcd, a[i] - a[0]); } write(max_gcd); return 0; } #define Getchar() getchar() template <typename _TpInt> inline _TpInt read() { register int flag = 1; register char c = Getchar(); while ((c > '9' || c < '0') && c != '-') c = Getchar(); if (c == '-') flag = -1, c = Getchar(); register _TpInt init = (c & 15); while ((c = Getchar()) <= '9' && c >= '0') init = (init << 3) + (init << 1) + (c & 15); return init * flag; } template <typename _TpRealnumber> inline double readr() { register int flag = 1; register char c = Getchar(); while ((c > '9' || c < '0') && c != '-') c = Getchar(); if (c == '-') flag = -1, c = Getchar(); register _TpRealnumber init = (c & 15); while ((c = Getchar()) <= '9' && c >= '0') init = init * 10 + (c & 15); if (c != '.') return init * flag; register _TpRealnumber l = 0.1; while ((c = Getchar()) <= '9' && c >= '0') init = init + (c & 15) * l, l *= 0.1; return init * flag; } template <typename _TpInt> inline void write(_TpInt x) { if (x < 0) { putchar('-'); write<_TpInt>(~x + 1); } else { if (x > 9) write<_TpInt>(x / 10); putchar(x % 10 + '0'); } } // template <typename _TpSwap> // inline void swap(_TpSwap &x, _TpSwap &y) // { // _TpSwap t = x; // x = y; // y = t; // } } // namespace AuthorName int main() { AuthorName::main(); return 0; }
replace
22
23
22
23
0
p03262
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0; i < n; i++) int gcd(int a, int b) { int c = a / b; int d = a % b; if (d > 0) return gcd(b, d); else return b; } int main() { cin.tie(0); ios::sync_with_stdio(false); int n, x; cin >> n >> x; vector<int> A(n + 1); REP(i, n) cin >> A[i]; A[n] = x; sort(A.begin(), A.end()); vector<int> B(n); REP(i, n) { B[i] = A[i + 1] - A[i]; } int g = gcd(B[0], B[1]); for (int i = 1; i < n; i++) { g = gcd(g, B[i]); } cout << g << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0; i < n; i++) int gcd(int a, int b) { int c = a / b; int d = a % b; if (d > 0) return gcd(b, d); else return b; } int main() { cin.tie(0); ios::sync_with_stdio(false); int n, x; cin >> n >> x; vector<int> A(n + 1); REP(i, n) cin >> A[i]; A[n] = x; sort(A.begin(), A.end()); vector<int> B(n); REP(i, n) { B[i] = A[i + 1] - A[i]; } int g; if (n == 1) g = B[0]; else g = gcd(B[0], B[1]); for (int i = 1; i < n; i++) { g = gcd(g, B[i]); } cout << g << endl; return 0; }
replace
29
30
29
34
0
p03262
C++
Runtime Error
#include <bits/stdc++.h> #define ll long long #define rep(X, N) for (int X = 0; X < N; X++) #define repvin(V, N) \ for (int i = 0; i < N; i++) { \ int tmp; \ cin >> tmp; \ V.push_back(tmp); \ } using namespace std; int gcd(int a, int b) { if (a < b) return gcd(b, a); if (a % b == 0) { return b; } else { return gcd(b, a % b); } } int main() { int n, x; cin >> n >> x; vector<int> v; repvin(v, n); v.push_back(x); sort(v.begin(), v.end()); vector<int> diff; rep(i, n) { diff.push_back(v[i + 1] - v[i]); } int ans = gcd(diff[0], diff[1]); rep(i, n - 2) { ans = gcd(ans, diff[i + 2]); } cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define ll long long #define rep(X, N) for (int X = 0; X < N; X++) #define repvin(V, N) \ for (int i = 0; i < N; i++) { \ int tmp; \ cin >> tmp; \ V.push_back(tmp); \ } using namespace std; int gcd(int a, int b) { if (a < b) return gcd(b, a); if (a % b == 0) { return b; } else { return gcd(b, a % b); } } int main() { int n, x; cin >> n >> x; vector<int> v; repvin(v, n); v.push_back(x); sort(v.begin(), v.end()); vector<int> diff; rep(i, n) { diff.push_back(v[i + 1] - v[i]); } int ans; if (diff.size() > 1) { ans = gcd(diff[0], diff[1]); } else { ans = diff[0]; } rep(i, n - 2) { ans = gcd(ans, diff[i + 2]); } cout << ans << endl; return 0; }
replace
40
41
40
47
0
p03262
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define rep1(i, n) for (int i = 1; i < n + 1; i++) #define sort(A) sort(A.begin(), A.end()) #define reverse(A) reverse(A.begin(), A.end()); typedef long long ll; int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int main() { int n, x; cin >> n >> x; vector<int> v(n); rep(i, x) cin >> v[i]; vector<int> d(n); rep(i, n) d[i] = abs(x - v[i]); int g; rep(i, n) { if (i == 0) g = d[0]; else g = gcd(g, d[i]); } cout << g << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define rep1(i, n) for (int i = 1; i < n + 1; i++) #define sort(A) sort(A.begin(), A.end()) #define reverse(A) reverse(A.begin(), A.end()); typedef long long ll; int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int main() { int n, x; cin >> n >> x; vector<int> v(n); rep(i, n) cin >> v[i]; vector<int> d(n); rep(i, n) d[i] = abs(x - v[i]); int g; rep(i, n) { if (i == 0) g = d[0]; else g = gcd(g, d[i]); } cout << g << endl; }
replace
19
20
19
20
TLE
p03262
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int a[10005]; int main() { int n, s, l; scanf("%d", &n); for (register int i = 1; i <= n + 1; i++) scanf("%d", &a[i]); sort(a + 1, a + n + 2); for (register int i = 1; i <= n; i++) a[i] = a[i + 1] - a[i]; a[n + 1] = 0; sort(a + 1, a + n + 1); s = a[1]; l = 0; while (s > 0) { l = 0; for (register int i = 1; i <= n; i++) if (a[i] % s != 0) { l = 1; s--; break; } if (l == 0) { printf("%d\n", s); exit(0); } } return 0; }
#include <bits/stdc++.h> using namespace std; int a[100005]; int main() { int n, s, l; scanf("%d", &n); for (register int i = 1; i <= n + 1; i++) scanf("%d", &a[i]); sort(a + 1, a + n + 2); for (register int i = 1; i <= n; i++) a[i] = a[i + 1] - a[i]; a[n + 1] = 0; sort(a + 1, a + n + 1); s = a[1]; l = 0; while (s > 0) { l = 0; for (register int i = 1; i <= n; i++) if (a[i] % s != 0) { l = 1; s--; break; } if (l == 0) { printf("%d\n", s); exit(0); } } return 0; }
replace
2
3
2
3
0
p03262
C++
Runtime Error
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <stdio.h> #include <vector> using namespace std; #define int long long #define rep(s, i, n) for (int i = s; i < n; i++) #define c(n) cout << n << endl; #define ic(n) \ int n; \ cin >> n; #define sc(s) \ string s; \ cin >> s; #define mod 1000000007 #define inf 1000000000000000007 #define f first #define s second #define mini(c, a, b) *min_element(c + a, c + b) #define maxi(c, a, b) *max_element(c + a, c + b) int keta(int x) { rep(0, i, 30) { if (x < 10) { return i + 1; } x = x / 10; } } int gcd(int x, int y) { int aa = x, bb = y; rep(0, i, 1000) { aa = aa % bb; if (aa == 0) { return bb; } bb = bb % aa; if (bb == 0) { return aa; } } } int lcm(int x, int y) { int aa = x, bb = y; rep(0, i, 1000) { aa = aa % bb; if (aa == 0) { return x / bb * y; } bb = bb % aa; if (bb == 0) { return x / aa * y; } } } char mem[214514]; char t[214514]; char c[214514]; string s[214514]; int a[214514], b[214514]; signed main() { ic(n) ic(x) rep(0, i, n) { cin >> a[i]; a[i] -= x; } if (n == 1) { c(a[0]) return 0; } sort(a, a + n); rep(0, i, n - 1) b[i] = a[i + 1] - a[i]; int ans = gcd(b[0], b[1]); rep(1, i, n) { ans = gcd(b[i], ans); } c(ans) }
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <stdio.h> #include <vector> using namespace std; #define int long long #define rep(s, i, n) for (int i = s; i < n; i++) #define c(n) cout << n << endl; #define ic(n) \ int n; \ cin >> n; #define sc(s) \ string s; \ cin >> s; #define mod 1000000007 #define inf 1000000000000000007 #define f first #define s second #define mini(c, a, b) *min_element(c + a, c + b) #define maxi(c, a, b) *max_element(c + a, c + b) int keta(int x) { rep(0, i, 30) { if (x < 10) { return i + 1; } x = x / 10; } } int gcd(int x, int y) { int aa = x, bb = y; rep(0, i, 1000) { aa = aa % bb; if (aa == 0) { return bb; } bb = bb % aa; if (bb == 0) { return aa; } } } int lcm(int x, int y) { int aa = x, bb = y; rep(0, i, 1000) { aa = aa % bb; if (aa == 0) { return x / bb * y; } bb = bb % aa; if (bb == 0) { return x / aa * y; } } } char mem[214514]; char t[214514]; char c[214514]; string s[214514]; int a[214514], b[214514]; signed main() { ic(n) ic(x) rep(0, i, n) { cin >> a[i]; a[i] -= x; } if (n == 1) { c(abs(a[0])) return 0; } if (n == 2) { c(gcd(a[0], a[1])); return 0; } sort(a, a + n); rep(0, i, n - 1) b[i] = a[i + 1] - a[i]; int ans = gcd(b[0], b[1]); rep(1, i, n) { ans = gcd(b[i], ans); } c(ans) }
replace
67
68
67
72
0
p03262
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #define ll long long int using namespace std; int n, x, f[100005], top, pd, d[100005]; ll ans = 0x3f3f3f3f; ll gcd(int a, int b) { if (b == 0) return a; else return (long long)gcd(b, a % b); } int main() { ans = ans * 100000; scanf("%d%d", &n, &f[1]); for (int i = 2; i <= n + 1; i++) scanf("%d", &f[i]); sort(f + 1, f + n + 2); for (int i = 2; i <= n + 1; i++) { d[i - 1] = f[i] - f[i - 1]; if (n == 1) ans = d[i - 1]; } if (n != 1) for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) ans = min(ans, gcd(d[i], d[j])); } printf("%lld", ans); return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #define ll long long int using namespace std; int n, x, f[100005], top, pd, d[100005]; ll ans = 0x3f3f3f3f; ll gcd(int a, int b) { if (b == 0) return a; else return (long long)gcd(b, a % b); } int main() { ans = ans * 100000; scanf("%d%d", &n, &f[1]); for (int i = 2; i <= n + 1; i++) scanf("%d", &f[i]); sort(f + 1, f + n + 2); for (int i = 2; i <= n + 1; i++) { d[i - 1] = f[i] - f[i - 1]; if (n == 1) ans = d[i - 1]; } if (n != 1) for (int i = 2; i <= n; i++) { ans = min(ans, gcd(d[i], d[i - 1])); } printf("%lld", ans); return 0; }
replace
28
31
28
30
TLE
p03262
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define ll long long int a[10005]; int n, x, ans = 1e9; int main() { cin >> n >> x; for (int i = 1; i <= n; i++) { cin >> a[i]; a[i] = abs(a[i] - x); ans = min(a[i], ans); } for (int i = 1; i <= n; i++) ans = __gcd(ans, a[i]); cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; #define ll long long int a[100005]; int n, x, ans = 1e9; int main() { cin >> n >> x; for (int i = 1; i <= n; i++) { cin >> a[i]; a[i] = abs(a[i] - x); ans = min(a[i], ans); } for (int i = 1; i <= n; i++) ans = __gcd(ans, a[i]); cout << ans; return 0; }
replace
3
4
3
4
0
p03262
C++
Runtime Error
#include <algorithm> #include <assert.h> #include <bitset> #include <cassert> #include <cctype> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdint> #include <cstdio> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <list> #include <map> #include <math.h> #include <memory> #include <queue> #include <random> #include <set> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string> #include <tuple> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> // =============================================================== using namespace std; using ll = long long; using vl = vector<long long>; using vll = vector<vector<long long>>; using vs = vector<string>; using vc = vector<char>; using vcc = vector<vector<char>>; using vm = vector<short>; using vmm = vector<vector<short>>; using pii = pair<int, int>; using psi = pair<string, int>; using ld = long double; using ull = unsigned long long; // =============================================================== ll gcd(ll a, ll b) // 最大公約数 { if (a % b == 0) { return (b); } else { return (gcd(b, a % b)); } } ll lcm(ll a, ll b) // 最小公倍数 { return a * b / gcd(a, b); } ll box(double a) // doubleの切り捨て { ll b = a; return b; } ll fff(double a) // doubleの四捨五入 { ll b = a + 0.5; return b; } ll sum(ll n) { // 整数sまでの合計 if (n == 0) { return 0; } int s = sum(n - 1); return s + n; } bool prime(ll num) // 素数判定、primeならtrue,違うならfalse { if (num < 2) return false; else if (num == 2) return true; else if (num % 2 == 0) return false; double sqrtNum = sqrt(num); for (int i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) { return false; } } // 素数である return true; } // =============================================================== int main() { ll n, x; cin >> n >> x; vl a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } if (n == 1) { cout << abs(a[0] - x) << endl; } else { sort(a.begin(), a.end()); ll count; vl b(n); ll junbi = 0; for (int i = 0; i < n - 1; i++) { if (a[i] < x && a[i + 1] > x) { b[i] = x - a[i]; b[i + 1] = a[i + 1] - x; junbi++; } b[i + junbi] = a[i + 1] - a[i]; } count = b[0]; for (int i = 0; i < n; i++) { count = gcd(count, b[i]); } cout << count << endl; } }
#include <algorithm> #include <assert.h> #include <bitset> #include <cassert> #include <cctype> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdint> #include <cstdio> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <list> #include <map> #include <math.h> #include <memory> #include <queue> #include <random> #include <set> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string> #include <tuple> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> // =============================================================== using namespace std; using ll = long long; using vl = vector<long long>; using vll = vector<vector<long long>>; using vs = vector<string>; using vc = vector<char>; using vcc = vector<vector<char>>; using vm = vector<short>; using vmm = vector<vector<short>>; using pii = pair<int, int>; using psi = pair<string, int>; using ld = long double; using ull = unsigned long long; // =============================================================== ll gcd(ll a, ll b) // 最大公約数 { if (a % b == 0) { return (b); } else { return (gcd(b, a % b)); } } ll lcm(ll a, ll b) // 最小公倍数 { return a * b / gcd(a, b); } ll box(double a) // doubleの切り捨て { ll b = a; return b; } ll fff(double a) // doubleの四捨五入 { ll b = a + 0.5; return b; } ll sum(ll n) { // 整数sまでの合計 if (n == 0) { return 0; } int s = sum(n - 1); return s + n; } bool prime(ll num) // 素数判定、primeならtrue,違うならfalse { if (num < 2) return false; else if (num == 2) return true; else if (num % 2 == 0) return false; double sqrtNum = sqrt(num); for (int i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) { return false; } } // 素数である return true; } // =============================================================== int main() { ll n, x; cin >> n >> x; vl a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } if (n == 1) { cout << abs(a[0] - x) << endl; } else { sort(a.begin(), a.end()); ll count; vl b(n); ll junbi = 0; for (int i = 0; i < n - 1; i++) { if (x < a[n - 1] && x > a[0]) { if (a[i] < x && a[i + 1] > x) { b[i] = x - a[i]; b[i + 1] = a[i + 1] - x; junbi++; } } else { if (x < a[n - 1]) { b[0] = a[0] - x; junbi++; } else { b[n - 1] = x - a[n - 1]; } } b[i + junbi] = a[i + 1] - a[i]; } count = b[0]; for (int i = 0; i < n; i++) { count = gcd(count, b[i]); } cout << count << endl; } }
replace
125
129
125
138
0
p03263
Python
Runtime Error
h, w = map(int, input().split()) a = [list(map(int, input().split())) for i in range(h)] r, c, d = 0, 0, 3 ret = [] for y in range(h * w - 1): if y % w == 0 or y % w == w - 1: d = (d + 1) % 4 dy, dx = [(0, 1), (1, 0), (0, -1), (1, 0)][d] if a[r][c] % 2 != 0: ret.append((r, c, r + dy, c + dx)) a[r + dy][c + dx] += 1 r, c = r + dy, c + dx print(len(ret)) for r1, c1, r2, c2 in ret: print(r1 + 1, c1 + 1, r2 + 1, c2 + 1)
h, w = map(int, input().split()) a = [list(map(int, input().split())) for i in range(h)] r, c, d = 0, 0, 3 ret = [] for y in range(h * w - 1): if y % w == 0: d = (d + 1) % 4 if y % w == w - 1: d = (d + 1) % 4 dy, dx = [(0, 1), (1, 0), (0, -1), (1, 0)][d] if a[r][c] % 2 != 0: ret.append((r, c, r + dy, c + dx)) a[r + dy][c + dx] += 1 r, c = r + dy, c + dx print(len(ret)) for r1, c1, r2, c2 in ret: print(r1 + 1, c1 + 1, r2 + 1, c2 + 1)
replace
5
6
5
8
0
p03263
Python
Runtime Error
# -*- coding: utf-8 -*- def main(): h, w = map(int, input().split()) a = [list(map(int, input().split())) for _ in range(h)] operations = list() # See: # https://atcoder.jp/contests/abc109/submissions/3154532 for row in range(h): for col in range(w - 1): if a[row][col] % 2 == 1: operations.append((row + 1, col + 1, row + 1, col + 2)) a[row][col] -= 1 a[row][col + 1] += 1 for row in range(h - 1): if a[row][w - 1] % 2 == 1: operations.append((row + 1, col + 1, row + 2, col + 1)) a[row][w - 1] -= 1 a[row + 1][w - 1] += 1 n = len(operations) print(n) for i in range(n): y, x, y_dash, x_dash = operations[i] print(y, x, y_dash, x_dash) if __name__ == "__main__": main()
# -*- coding: utf-8 -*- def main(): h, w = map(int, input().split()) a = [list(map(int, input().split())) for _ in range(h)] operations = list() # See: # https://atcoder.jp/contests/abc109/submissions/3154532 for row in range(h): for col in range(w - 1): if a[row][col] % 2 == 1: operations.append((row + 1, col + 1, row + 1, col + 2)) a[row][col] -= 1 a[row][col + 1] += 1 for row in range(h - 1): if a[row][w - 1] % 2 == 1: operations.append((row + 1, w, row + 2, w)) a[row][w - 1] -= 1 a[row + 1][w - 1] += 1 n = len(operations) print(n) for i in range(n): y, x, y_dash, x_dash = operations[i] print(y, x, y_dash, x_dash) if __name__ == "__main__": main()
replace
19
20
19
20
0
p03263
C++
Runtime Error
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> using namespace std; struct node { int a, b, c, d; } re[10000]; int a[550][550]; int main() { int h, w; scanf("%d%d", &h, &w); for (int i = 1; i <= h; i++) for (int j = 1; j <= w; j++) scanf("%d", &a[i][j]); int cnt = 0; for (int i = 1; i < h; i++) for (int j = 1; j <= w; j++) if (a[i][j] % 2 == 1) a[i][j]--, a[i + 1][j]++, re[cnt].a = i, re[cnt].b = j, re[cnt].c = i + 1, re[cnt].d = j, cnt++; for (int j = 1; j < w; j++) if (a[h][j] % 2 == 1) a[h][j]--, a[h][j + 1]++, re[cnt].a = h, re[cnt].b = j, re[cnt].c = h, re[cnt].d = j + 1, cnt++; printf("%d\n", cnt); for (int i = 0; i < cnt; i++) printf("%d %d %d %d\n", re[i].a, re[i].b, re[i].c, re[i].d); }
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> using namespace std; struct node { int a, b, c, d; } re[250050]; int a[550][550]; int main() { int h, w; scanf("%d%d", &h, &w); for (int i = 1; i <= h; i++) for (int j = 1; j <= w; j++) scanf("%d", &a[i][j]); int cnt = 0; for (int i = 1; i < h; i++) for (int j = 1; j <= w; j++) if (a[i][j] % 2 == 1) a[i][j]--, a[i + 1][j]++, re[cnt].a = i, re[cnt].b = j, re[cnt].c = i + 1, re[cnt].d = j, cnt++; for (int j = 1; j < w; j++) if (a[h][j] % 2 == 1) a[h][j]--, a[h][j + 1]++, re[cnt].a = h, re[cnt].b = j, re[cnt].c = h, re[cnt].d = j + 1, cnt++; printf("%d\n", cnt); for (int i = 0; i < cnt; i++) printf("%d %d %d %d\n", re[i].a, re[i].b, re[i].c, re[i].d); }
replace
7
8
7
8
0
p03263
Python
Runtime Error
H, W = map(int, input().split()) G = [list(map(int, input().split())) for i in range(H)] N = 0 ans = [] for h in range(H): for w in range(W - 1): if G[h][w] % 2 == 1: N += 1 ans.append((h, w, h, w + 1)) G[h][w + 1] += 1 G[h][w] -= 1 for h in range(H - 1): if G[h][W - 1] % 2 == 1: N += 1 ans.append((h, w, h + 1, w)) G[h + 1][W - 1] += 1 G[h][W - 1] -= 1 print(N) for y1, x1, y2, x2 in ans: print(y1 + 1, x1 + 1, y2 + 1, x2 + 1)
H, W = map(int, input().split()) G = [list(map(int, input().split())) for i in range(H)] N = 0 ans = [] for h in range(H): for w in range(W - 1): if G[h][w] % 2 == 1: N += 1 ans.append((h, w, h, w + 1)) G[h][w + 1] += 1 G[h][w] -= 1 for h in range(H - 1): if G[h][W - 1] % 2 == 1: N += 1 ans.append((h, W - 1, h + 1, W - 1)) G[h + 1][W - 1] += 1 G[h][W - 1] -= 1 print(N) for y1, x1, y2, x2 in ans: print(y1 + 1, x1 + 1, y2 + 1, x2 + 1)
replace
16
17
16
17
0
p03263
C++
Runtime Error
#include <algorithm> #include <climits> #include <cmath> #include <cstdint> #include <cstdlib> #include <ctime> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <math.h> #include <queue> #include <random> #include <stdio.h> #include <string> #include <tuple> #include <vector> using namespace std; template <class T> using V = vector<T>; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } const long long INF = 1LL << 60; const double pi = acos(-1); using ll = long long; using db = long double; using st = string; using ch = char; using vll = V<ll>; using vpll = V<pair<ll, ll>>; using vst = V<st>; using vdb = V<db>; using vch = V<ch>; using graph = V<V<int>>; using pq = priority_queue<ll>; #define FOR(i, a, b) for (ll i = (a); i < (b); i++) #define bgn begin() #define en end() #define SORT(a) sort((a).bgn, (a).en) #define REV(a) reverse((a).bgn, (a).en) #define fi first #define se second #define sz size() #define gcd(a, b) __gcd(a, b) #define pb(a) push_back(a); #define ALL(a) (a).begin(), (a).end() ll Sum(ll n) { ll m = 0; while (n) { m += n % 10; n /= 10; } return m; } const int MAX = 510000; // change const int MOD = 1000000007; long long fac[MAX], finv[MAX], inv[MAX]; void Comuse() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } #define comuse Comuse() ll combi(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } ll perm(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] % MOD) % MOD; } ll modpow(ll a, ll n, ll mod) { ll ans = 1; while (n > 0) { if (n & 1) { ans = ans * a % mod; } a = a * a % mod; n >>= 1; } return ans; } ll modinv(ll a, ll mod) { return modpow(a, mod - 2, mod); } ll modcombi(int n, int k, int mod) { ll ans = 1; for (ll i = n; i > n - k; i--) { ans *= i; ans %= mod; } for (ll i = 1; i <= k; i++) { ans *= modinv(i, mod); ans %= mod; } return ans; } ll lcm(ll a, ll b) { ll n; n = a / gcd(a, b) * b; return n; } vll div(ll n) { vll ret; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) { ret.push_back(n / i); } } } SORT(ret); return (ret); } vector<bool> isprime(MAX + 100, true); void primeuse() { isprime[0] = false; isprime[1] = false; for (int i = 2; i < MAX + 50; i++) { int up = sqrt(i) + 1; for (int j = 2; j < up; j++) { if (i % j == 0) { isprime[i] = false; } } } } void bf(ll n, string s) { for (ll i = 0; i < n; i++) { cout << s; } cout << "\n"; } void Solve(); const int MAX_N = 131072; // segment tree int NN; int seg[MAX_N * 2 - 1]; void seguse() { for (int i = 0; i < 2 * NN - 1; i++) { seg[i] = INT_MAX; } } signed main() { cin.tie(0); ios::sync_with_stdio(false); cout << setprecision(20) << fixed; Solve(); } /****************************************\ | Thank you for viewing my code:) | | Written by RedSpica a.k.a. RanseMirage | | Twitter:@asakaakasaka | \****************************************/ // segtreeの葉の先頭の添え字はN-1 void Solve() { ll h, w; cin >> h >> w; vector<vector<ll>> A(h, vector<ll>(w)); FOR(i, 0, h) { FOR(j, 0, w) { cin >> A[i][j]; } } vector<vector<ll>> ans(0, vector<ll>(0)); for (int i = 0; i < h; i++) { if (i % 2 == 0) { for (int j = 0; j < w; j++) { if (A[i][j] % 2 == 0) { continue; } if (j == w - 1 and i == h - 1) { break; } if (j == w - 1 and i != h - 1) { A[i][j]--; A[i + 1][j]++; ans.push_back({i, j, i + 1, j}); } else { A[i][j]--; A[i][j + 1]++; ans.push_back({i, j, i, j + 1}); } } } else { for (int j = w - 1; j >= 0; j--) { if (A[i][j] % 2 == 0) { continue; } if (i == h - 1 and w == 0) { break; } if (j == 0 and i != h - 1) { A[i][j]--; A[i + 1][j]++; ans.push_back({i, j, i + 1, j}); } else { A[i][j]--; A[i][j - 1]++; ans.push_back({i, j, i, j - 1}); } } } } ll m = ans.size(); cout << m << "\n"; FOR(i, 0, m) { FOR(j, 0, 4) { cout << ans[i][j] + 1; if (j != 3) { cout << " "; } } cout << "\n"; } }
#include <algorithm> #include <climits> #include <cmath> #include <cstdint> #include <cstdlib> #include <ctime> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <math.h> #include <queue> #include <random> #include <stdio.h> #include <string> #include <tuple> #include <vector> using namespace std; template <class T> using V = vector<T>; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } const long long INF = 1LL << 60; const double pi = acos(-1); using ll = long long; using db = long double; using st = string; using ch = char; using vll = V<ll>; using vpll = V<pair<ll, ll>>; using vst = V<st>; using vdb = V<db>; using vch = V<ch>; using graph = V<V<int>>; using pq = priority_queue<ll>; #define FOR(i, a, b) for (ll i = (a); i < (b); i++) #define bgn begin() #define en end() #define SORT(a) sort((a).bgn, (a).en) #define REV(a) reverse((a).bgn, (a).en) #define fi first #define se second #define sz size() #define gcd(a, b) __gcd(a, b) #define pb(a) push_back(a); #define ALL(a) (a).begin(), (a).end() ll Sum(ll n) { ll m = 0; while (n) { m += n % 10; n /= 10; } return m; } const int MAX = 510000; // change const int MOD = 1000000007; long long fac[MAX], finv[MAX], inv[MAX]; void Comuse() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } #define comuse Comuse() ll combi(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } ll perm(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] % MOD) % MOD; } ll modpow(ll a, ll n, ll mod) { ll ans = 1; while (n > 0) { if (n & 1) { ans = ans * a % mod; } a = a * a % mod; n >>= 1; } return ans; } ll modinv(ll a, ll mod) { return modpow(a, mod - 2, mod); } ll modcombi(int n, int k, int mod) { ll ans = 1; for (ll i = n; i > n - k; i--) { ans *= i; ans %= mod; } for (ll i = 1; i <= k; i++) { ans *= modinv(i, mod); ans %= mod; } return ans; } ll lcm(ll a, ll b) { ll n; n = a / gcd(a, b) * b; return n; } vll div(ll n) { vll ret; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) { ret.push_back(n / i); } } } SORT(ret); return (ret); } vector<bool> isprime(MAX + 100, true); void primeuse() { isprime[0] = false; isprime[1] = false; for (int i = 2; i < MAX + 50; i++) { int up = sqrt(i) + 1; for (int j = 2; j < up; j++) { if (i % j == 0) { isprime[i] = false; } } } } void bf(ll n, string s) { for (ll i = 0; i < n; i++) { cout << s; } cout << "\n"; } void Solve(); const int MAX_N = 131072; // segment tree int NN; int seg[MAX_N * 2 - 1]; void seguse() { for (int i = 0; i < 2 * NN - 1; i++) { seg[i] = INT_MAX; } } signed main() { cin.tie(0); ios::sync_with_stdio(false); cout << setprecision(20) << fixed; Solve(); } /****************************************\ | Thank you for viewing my code:) | | Written by RedSpica a.k.a. RanseMirage | | Twitter:@asakaakasaka | \****************************************/ // segtreeの葉の先頭の添え字はN-1 void Solve() { ll h, w; cin >> h >> w; vector<vector<ll>> A(h, vector<ll>(w)); FOR(i, 0, h) { FOR(j, 0, w) { cin >> A[i][j]; } } vector<vector<ll>> ans(0, vector<ll>(0)); for (int i = 0; i < h; i++) { if (i % 2 == 0) { for (int j = 0; j < w; j++) { if (A[i][j] % 2 == 0) { continue; } if (j == w - 1 and i == h - 1) { break; } if (j == w - 1 and i != h - 1) { A[i][j]--; A[i + 1][j]++; ans.push_back({i, j, i + 1, j}); } else { A[i][j]--; A[i][j + 1]++; ans.push_back({i, j, i, j + 1}); } } } else { for (int j = w - 1; j >= 0; j--) { if (A[i][j] % 2 == 0) { continue; } if (i == h - 1 and j == 0) { break; } if (j == 0 and i != h - 1) { A[i][j]--; A[i + 1][j]++; ans.push_back({i, j, i + 1, j}); } else { A[i][j]--; A[i][j - 1]++; ans.push_back({i, j, i, j - 1}); } } } } ll m = ans.size(); cout << m << "\n"; FOR(i, 0, m) { FOR(j, 0, 4) { cout << ans[i][j] + 1; if (j != 3) { cout << " "; } } cout << "\n"; } }
replace
240
241
240
241
0
p03263
C++
Runtime Error
#include <algorithm> #include <cctype> #include <cmath> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <stack> #include <string> #include <utility> #include <vector> #define rep(i, p, q) for (int i = p; i < q; i++) #define ll long long ll CONS = 1e9 + 7; using namespace std; // ABC 109 D int main(void) { ll h, w; cin >> h >> w; vector<vector<ll>> a = vector<vector<ll>>(h + 1, vector<ll>(w + 1)); rep(i, 1, h + 1) { rep(j, 1, w + 1) cin >> a[i][j]; } vector<string> ans = vector<string>(); ll row = 1, col = 1; ll count = 0; bool goRight = true; while (count < h * w) { ll rowNext, colNext; count++; if (goRight) { if (col == w && row % 2 == 1) { colNext = col; rowNext = row + 1; goRight = false; } else { colNext = col + 1; rowNext = row; } } else { if (col == 1 && row % 2 == 0) { colNext = col; rowNext = row + 1; goRight = true; } else { colNext = col - 1; rowNext = row; } } if (a[row][col] % 2 == 1 && row > 0 && col > 0 && row < h + 1 && col < w + 1) { string s = to_string(row) + " " + to_string(col) + " " + to_string(rowNext) + " " + to_string(colNext); ans.push_back(s); a[rowNext][colNext]++; } row = rowNext; col = colNext; } cout << ans.size() << endl; rep(i, 0, ans.size()) { cout << ans[i] << endl; } }
#include <algorithm> #include <cctype> #include <cmath> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <stack> #include <string> #include <utility> #include <vector> #define rep(i, p, q) for (int i = p; i < q; i++) #define ll long long ll CONS = 1e9 + 7; using namespace std; // ABC 109 D int main(void) { ll h, w; cin >> h >> w; vector<vector<ll>> a = vector<vector<ll>>(h + 1, vector<ll>(w + 1)); rep(i, 1, h + 1) { rep(j, 1, w + 1) cin >> a[i][j]; } vector<string> ans = vector<string>(); ll row = 1, col = 1; ll count = 0; bool goRight = true; while (count < h * w) { ll rowNext, colNext; count++; if (goRight) { if (col == w && row % 2 == 1) { colNext = col; rowNext = row + 1; goRight = false; } else { colNext = col + 1; rowNext = row; } } else { if (col == 1 && row % 2 == 0) { colNext = col; rowNext = row + 1; goRight = true; } else { colNext = col - 1; rowNext = row; } } if (a[row][col] % 2 == 1 && rowNext > 0 && colNext > 0 && rowNext < h + 1 && colNext < w + 1) { string s = to_string(row) + " " + to_string(col) + " " + to_string(rowNext) + " " + to_string(colNext); ans.push_back(s); a[rowNext][colNext]++; } row = rowNext; col = colNext; } cout << ans.size() << endl; rep(i, 0, ans.size()) { cout << ans[i] << endl; } }
replace
57
59
57
59
0
p03263
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; const int N = 500 + 10; int a[N][N], h, w, cnt; int ans[N][N]; int main() { cin >> h >> w; cnt = 0; for (int i = 1; i <= h; i++) { for (int j = 1; j <= w; j++) { cin >> a[i][j]; } } for (int i = 1; i <= h - 1; i++) { for (int j = 1; j <= w; j++) { if (a[i][j] % 2 != 0) { a[i][j]--; a[i + 1][j]++; cnt++; ans[cnt][0] = i; ans[cnt][1] = j; ans[cnt][2] = i + 1; ans[cnt][3] = j; } } } for (int j = 1; j <= w - 1; j++) { if (a[h][j] % 2 != 0) { a[h][j]--; a[h][j + 1]++; cnt++; ans[cnt][0] = h; ans[cnt][1] = j; ans[cnt][2] = h; ans[cnt][3] = j + 1; } } cout << cnt << endl; for (int i = 1; i <= cnt; i++) { cout << ans[i][0] << ' ' << ans[i][1] << ' ' << ans[i][2] << ' ' << ans[i][3] << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 500 + 10; int a[N][N], h, w, cnt; int ans[N * N][4]; int main() { cin >> h >> w; cnt = 0; for (int i = 1; i <= h; i++) { for (int j = 1; j <= w; j++) { cin >> a[i][j]; } } for (int i = 1; i <= h - 1; i++) { for (int j = 1; j <= w; j++) { if (a[i][j] % 2 != 0) { a[i][j]--; a[i + 1][j]++; cnt++; ans[cnt][0] = i; ans[cnt][1] = j; ans[cnt][2] = i + 1; ans[cnt][3] = j; } } } for (int j = 1; j <= w - 1; j++) { if (a[h][j] % 2 != 0) { a[h][j]--; a[h][j + 1]++; cnt++; ans[cnt][0] = h; ans[cnt][1] = j; ans[cnt][2] = h; ans[cnt][3] = j + 1; } } cout << cnt << endl; for (int i = 1; i <= cnt; i++) { cout << ans[i][0] << ' ' << ans[i][1] << ' ' << ans[i][2] << ' ' << ans[i][3] << endl; } return 0; }
replace
5
6
5
6
0
p03263
C++
Runtime Error
#include <iostream> #include <tuple> #include <vector> using map_t = std::vector<std::vector<size_t>>; using ans_t = std::vector<std::tuple<size_t, size_t, size_t, size_t>>; void move(size_t y1, size_t x1, size_t y2, size_t x2, map_t &A, ans_t &ans) { A[y1 - 1][x1 - 1]--; A[y2 - 1][x2 - 1]++; ans.push_back(std::make_tuple(y1, x1, y2, x2)); } int main() { size_t H, W; std::cin >> H >> W; map_t A(H, std::vector<size_t>(W)); for (size_t y = 0; y < H; y++) { for (size_t x = 0; x < W; x++) { std::cin >> A[y][x]; } } ans_t ans; for (size_t y = 1; y < H + 1; y++) { if (y % 2 == 1) { for (size_t x = 1; x < W + 1; x++) { if (A[y - 1][x - 1] % 2 == 1) { if (x < W) move(y, x, y, x + 1, A, ans); else if (y < H) move(y, x, y + 1, x, A, ans); } } } else { for (size_t x = W; x > 0; x--) { if (A[y - 1][x - 1] % 2 == 1) { if (x > 0) move(y, x, y, x - 1, A, ans); else if (y < H) move(y, x, y + 1, x, A, ans); } } } } std::cout << ans.size() << std::endl; for (auto const &a : ans) { std::cout << std::get<0>(a) << ' ' << std::get<1>(a) << ' ' << std::get<2>(a) << ' ' << std::get<3>(a) << std::endl; } return 0; }
#include <iostream> #include <tuple> #include <vector> using map_t = std::vector<std::vector<size_t>>; using ans_t = std::vector<std::tuple<size_t, size_t, size_t, size_t>>; void move(size_t y1, size_t x1, size_t y2, size_t x2, map_t &A, ans_t &ans) { A[y1 - 1][x1 - 1]--; A[y2 - 1][x2 - 1]++; ans.push_back(std::make_tuple(y1, x1, y2, x2)); } int main() { size_t H, W; std::cin >> H >> W; map_t A(H, std::vector<size_t>(W)); for (size_t y = 0; y < H; y++) { for (size_t x = 0; x < W; x++) { std::cin >> A[y][x]; } } ans_t ans; for (size_t y = 1; y < H + 1; y++) { if (y % 2 == 1) { for (size_t x = 1; x < W + 1; x++) { if (A[y - 1][x - 1] % 2 == 1) { if (x < W) move(y, x, y, x + 1, A, ans); else if (y < H) move(y, x, y + 1, x, A, ans); } } } else { for (size_t x = W; x > 0; x--) { if (A[y - 1][x - 1] % 2 == 1) { if (x > 1) move(y, x, y, x - 1, A, ans); else if (y < H) move(y, x, y + 1, x, A, ans); } } } } std::cout << ans.size() << std::endl; for (auto const &a : ans) { std::cout << std::get<0>(a) << ' ' << std::get<1>(a) << ' ' << std::get<2>(a) << ' ' << std::get<3>(a) << std::endl; } return 0; }
replace
40
41
40
41
0
p03263
Python
Runtime Error
h, w = map(int, input().split()) a = [] for _ in range(h): a.append = list(map(int, input().split())) ans = [] for i in range(h): for j in range(w - 1): if a[i][j] % 2 == 1: ans.append([i + 1, j + 1, i + 1, j + 2]) a[i][j + 1] += 1 for i in range(h - 1): if a[i][w - 1] % 2 == 1: ans.append([i + 1, w, i + 2, w]) a[i + 1][w - 1] += 1 print(len(ans)) for ans in ans: print(*ans)
h, w = map(int, input().split()) a = [] for _ in range(h): a.append(list(map(int, input().split()))) ans = [] for i in range(h): for j in range(w - 1): if a[i][j] % 2 == 1: ans.append([i + 1, j + 1, i + 1, j + 2]) a[i][j + 1] += 1 for i in range(h - 1): if a[i][w - 1] % 2 == 1: ans.append([i + 1, w, i + 2, w]) a[i + 1][w - 1] += 1 print(len(ans)) for ans in ans: print(*ans)
replace
4
5
4
5
AttributeError: 'list' object attribute 'append' is read-only
Traceback (most recent call last): File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03263/Python/s852811802.py", line 5, in <module> a.append = list(map(int, input().split())) AttributeError: 'list' object attribute 'append' is read-only
p03263
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll mod = 1e18 + 7; int H, W; int a[505][505]; int go[2505][5]; int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> H >> W; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { cin >> a[i][j]; } } int N = 0; for (int i = 0; i < H; i++) { if (i % 2) { for (int j = W - 1; j >= 0; j--) { if (j == W - 1) { if (a[i - 1][j] % 2) { a[i - 1][j]--; a[i][j]++; go[N][0] = i - 1; go[N][1] = j; go[N][2] = i; go[N][3] = j; N++; } } else { if (a[i][j + 1] % 2) { a[i][j + 1]--; a[i][j]++; go[N][0] = i; go[N][1] = j + 1; go[N][2] = i; go[N][3] = j; N++; } } } } else { for (int j = 0; j < W; j++) { if (i == 0 && j == 0) continue; if (j == 0) { if (a[i - 1][j] % 2) { a[i - 1][j]--; a[i][j]++; go[N][0] = i - 1; go[N][1] = j; go[N][2] = i; go[N][3] = j; N++; } } else { if (a[i][j - 1] % 2) { a[i][j - 1]--; a[i][j]++; go[N][0] = i; go[N][1] = j - 1; go[N][2] = i; go[N][3] = j; N++; } } } } } cout << N << endl; for (int i = 0; i < N; i++) { cout << go[i][0] + 1 << " " << go[i][1] + 1 << " " << go[i][2] + 1 << " " << go[i][3] + 1 << endl; } }
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll mod = 1e18 + 7; int H, W; int a[505][505]; int go[300000][5]; int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> H >> W; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { cin >> a[i][j]; } } int N = 0; for (int i = 0; i < H; i++) { if (i % 2) { for (int j = W - 1; j >= 0; j--) { if (j == W - 1) { if (a[i - 1][j] % 2) { a[i - 1][j]--; a[i][j]++; go[N][0] = i - 1; go[N][1] = j; go[N][2] = i; go[N][3] = j; N++; } } else { if (a[i][j + 1] % 2) { a[i][j + 1]--; a[i][j]++; go[N][0] = i; go[N][1] = j + 1; go[N][2] = i; go[N][3] = j; N++; } } } } else { for (int j = 0; j < W; j++) { if (i == 0 && j == 0) continue; if (j == 0) { if (a[i - 1][j] % 2) { a[i - 1][j]--; a[i][j]++; go[N][0] = i - 1; go[N][1] = j; go[N][2] = i; go[N][3] = j; N++; } } else { if (a[i][j - 1] % 2) { a[i][j - 1]--; a[i][j]++; go[N][0] = i; go[N][1] = j - 1; go[N][2] = i; go[N][3] = j; N++; } } } } } cout << N << endl; for (int i = 0; i < N; i++) { cout << go[i][0] + 1 << " " << go[i][1] + 1 << " " << go[i][2] + 1 << " " << go[i][3] + 1 << endl; } }
replace
7
8
7
8
0
p03263
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> i_i; typedef pair<ll, ll> l_l; #define EPS (1e-7) #define INF (1e9) #define PI (acos(-1)) #define int ll int h, w; int a[250][251]; int cnt; vector<int> ans[4]; signed main() { cin >> h >> w; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { cin >> a[i][j]; a[i][j] = a[i][j] % 2; } } for (int i = 0; i < h; i++) { for (int j = 0; j < w - 1; j++) { if (a[i][j]) { a[i][j]--; a[i][j + 1] ^= 1; ans[0].push_back(i + 1); ans[1].push_back(j + 1); ans[2].push_back(i + 1); ans[3].push_back(j + 2); cnt++; } } } for (int i = 0; i < h - 1; i++) { if (a[i][w - 1]) { a[i][w - 1]--; a[i + 1][w - 1] ^= 1; ans[0].push_back(i + 1); ans[1].push_back(w); ans[2].push_back(i + 2); ans[3].push_back(w); cnt++; } } cout << cnt << endl; for (int i = 0; i < ans[0].size(); i++) { for (int j = 0; j < 4; j++) { cout << ans[j][i]; if (j != 3) cout << " "; } cout << endl; } }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> i_i; typedef pair<ll, ll> l_l; #define EPS (1e-7) #define INF (1e9) #define PI (acos(-1)) #define int ll int h, w; int a[500][501]; int cnt; vector<int> ans[4]; signed main() { cin >> h >> w; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { cin >> a[i][j]; a[i][j] = a[i][j] % 2; } } for (int i = 0; i < h; i++) { for (int j = 0; j < w - 1; j++) { if (a[i][j]) { a[i][j]--; a[i][j + 1] ^= 1; ans[0].push_back(i + 1); ans[1].push_back(j + 1); ans[2].push_back(i + 1); ans[3].push_back(j + 2); cnt++; } } } for (int i = 0; i < h - 1; i++) { if (a[i][w - 1]) { a[i][w - 1]--; a[i + 1][w - 1] ^= 1; ans[0].push_back(i + 1); ans[1].push_back(w); ans[2].push_back(i + 2); ans[3].push_back(w); cnt++; } } cout << cnt << endl; for (int i = 0; i < ans[0].size(); i++) { for (int j = 0; j < 4; j++) { cout << ans[j][i]; if (j != 3) cout << " "; } cout << endl; } }
replace
11
12
11
12
0
p03263
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int H, W; vector<vector<int>> a(510, vector<int>(510)); int sum = 0; cin >> H >> W; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { cin >> a[i][j]; sum += a[i][j]; } } vector<vector<int>> ans; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { if (i == H - 1 && j == W - 1) break; if (i % 2 == 0) { // 左から右に if (a[i][j] % 2 == 1) { a[i][j] -= 1; if (j == W - 1) { a[i + 1][j] += 1; ans.push_back({i + 1, j + 1, i + 2, j + 1}); } else { a[i][j + 1] += 1; ans.push_back({i + 1, j + 1, i + 1, j + 2}); } } } if (i % 2 == 1) { // 右から左に if (a[i][W - j - 1] % 2 == 1) { a[i][W - j - 1] -= 1; if (j == 0) { a[i + 1][W - j - 1] += 1; ans.push_back({i + 1, W - j, i + 2, W - j}); } else { a[i][W - j - 2] += 1; ans.push_back({i + 1, W - j, i + 1, W - j - 1}); } } } } } cout << ans.size() << endl; for (int i = 0; i < ans.size(); i++) { printf("%d %d %d %d\n", ans[i][0], ans[i][1], ans[i][2], ans[i][3]); } }
#include <bits/stdc++.h> using namespace std; int main() { int H, W; vector<vector<int>> a(510, vector<int>(510)); int sum = 0; cin >> H >> W; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { cin >> a[i][j]; sum += a[i][j]; } } vector<vector<int>> ans; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { if (i == H - 1 && j == W - 1) break; if (i % 2 == 0) { // 左から右に if (a[i][j] % 2 == 1) { a[i][j] -= 1; if (j == W - 1) { a[i + 1][j] += 1; ans.push_back({i + 1, j + 1, i + 2, j + 1}); } else { a[i][j + 1] += 1; ans.push_back({i + 1, j + 1, i + 1, j + 2}); } } } if (i % 2 == 1) { // 右から左に if (a[i][W - j - 1] % 2 == 1) { a[i][W - j - 1] -= 1; if (j == W - 1) { a[i + 1][W - j - 1] += 1; ans.push_back({i + 1, W - j, i + 2, W - j}); } else { a[i][W - j - 2] += 1; ans.push_back({i + 1, W - j, i + 1, W - j - 1}); } } } } } cout << ans.size() << endl; for (int i = 0; i < ans.size(); i++) { printf("%d %d %d %d\n", ans[i][0], ans[i][1], ans[i][2], ans[i][3]); } }
replace
39
40
39
40
0
p03263
C++
Runtime Error
#include <algorithm> #include <chrono> #include <deque> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <vector> using namespace std; using lli = long long int; using Vint = std::vector<int>; using Vlli = std::vector<lli>; using Wint = std::vector<Vint>; using Wlli = std::vector<Vlli>; using Vbool = std::vector<bool>; using Wbool = std::vector<Vbool>; using pii = std::pair<int, int>; using pll = std::pair<lli, lli>; template <class T> using Vec = std::vector<T>; constexpr int MOD = 1e9 + 7; constexpr int INFi = 2e9 + 1; constexpr lli INFl = (lli)(9e18) + 1; const vector<pii> DXDY = {std::make_pair(1, 0), std::make_pair(-1, 0), std::make_pair(0, 1), std::make_pair(0, -1)}; constexpr char BR = '\n'; #define DEBUG(x) std::cerr << #x << " = " << x << '\n'; #define FOR(i, a, b) for (int(i) = (a); (i) < (b); ++(i)) #define FOReq(i, a, b) for (int(i) = (a); (i) <= (b); ++(i)) #define rFOR(i, a, b) for (int(i) = (b); (i) >= (a); --(i)) #define FORstep(i, a, b, step) for (int(i) = (a); i < (b); i += (step)) #define REP(i, n) FOR(i, 0, n) #define rREP(i, n) rFOR(i, 0, (n - 1)) #define vREP(ele, vec) for (auto &(ele) : (vec)) #define vREPcopy(ele, vec) for (auto(ele) : (vec)) #define SORT(A) std::sort((A).begin(), (A).end()) #define RSORT(A) std::sort((A).rbegin(), (A).rend()) // 座標圧縮 (for vector) : ソートしてから使うのが一般的 ; SORT(A) => // COORDINATE_COMPRESSION(A) #define COORDINATE_COMPRESSION(A) \ (A).erase(unique((A).begin(), (A).end()), (A).end()) template <class T> inline int argmin(std::vector<T> vec) { return min_element(vec.begin(), vec.end()) - vec.begin(); } template <class T> inline int argmax(std::vector<T> vec) { return max_element(vec.begin(), vec.end()) - vec.begin(); } template <class T> inline void chmax(T &a, T b) { if (a < b) a = b; } template <class T> inline void chmin(T &a, T b) { if (a > b) a = b; } template <class T> inline void reverseSORT(Vec<T> &Array) { std::sort(Array.begin(), Array.end(), std::greater<T>()); } inline int BitI(int k) { return 1 << k; } inline lli BitL(int k) { return 1LL << k; } inline void putsDouble(double d) { printf("%.16lf\n", d); } inline int toInt(const string &s) { int res = 0; for (char a : s) res = 10 * res + (a - '0'); return res; } inline long long int toLong(const string &s) { lli res = 0; for (char a : s) res = 10 * res + (a - '0'); return res; } template <class T> inline std::string toString(T n) { if (n == 0) return "0"; std::string res; if (n < 0) { n = -n; while (n != 0) { res += (char)(n % 10 + '0'); n /= 10; } std::reverse(res.begin(), res.end()); return '-' + res; } while (n != 0) { res += (char)(n % 10 + '0'); n /= 10; } std::reverse(res.begin(), res.end()); return res; } // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int main(void) { int h, w; scanf("%d%d", &h, &w); Wbool Odd(h, Vbool(w)); REP(i, h) REP(j, w) { short a; scanf("%hd", &a); Odd[i][j] = (a & 1); } using information = std::tuple<int, int, int, int>; std::queue<information> ANS; REP(i, h) REP(j, w - 1) { if (Odd[i][j]) { ANS.push(make_tuple(i + 1, j + 1, i + 1, j + 2)); Odd[i][j] = false; Odd[i][j + 1] = not Odd[i][j + 1]; } } REP(i, h - 1) { if (Odd[i][w - 1]) { ANS.push(make_tuple(i + 1, w, i + 2, w)); Odd[i][w - 1] = false; Odd[i + 1][h - 1] = not Odd[i + 1][w - 1]; } } printf("%lu\n", ANS.size()); while (not ANS.empty()) { int a, b, c, d; std::tie(a, b, c, d) = ANS.front(); ANS.pop(); printf("%d %d %d %d\n", a, b, c, d); } return 0; }
#include <algorithm> #include <chrono> #include <deque> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <vector> using namespace std; using lli = long long int; using Vint = std::vector<int>; using Vlli = std::vector<lli>; using Wint = std::vector<Vint>; using Wlli = std::vector<Vlli>; using Vbool = std::vector<bool>; using Wbool = std::vector<Vbool>; using pii = std::pair<int, int>; using pll = std::pair<lli, lli>; template <class T> using Vec = std::vector<T>; constexpr int MOD = 1e9 + 7; constexpr int INFi = 2e9 + 1; constexpr lli INFl = (lli)(9e18) + 1; const vector<pii> DXDY = {std::make_pair(1, 0), std::make_pair(-1, 0), std::make_pair(0, 1), std::make_pair(0, -1)}; constexpr char BR = '\n'; #define DEBUG(x) std::cerr << #x << " = " << x << '\n'; #define FOR(i, a, b) for (int(i) = (a); (i) < (b); ++(i)) #define FOReq(i, a, b) for (int(i) = (a); (i) <= (b); ++(i)) #define rFOR(i, a, b) for (int(i) = (b); (i) >= (a); --(i)) #define FORstep(i, a, b, step) for (int(i) = (a); i < (b); i += (step)) #define REP(i, n) FOR(i, 0, n) #define rREP(i, n) rFOR(i, 0, (n - 1)) #define vREP(ele, vec) for (auto &(ele) : (vec)) #define vREPcopy(ele, vec) for (auto(ele) : (vec)) #define SORT(A) std::sort((A).begin(), (A).end()) #define RSORT(A) std::sort((A).rbegin(), (A).rend()) // 座標圧縮 (for vector) : ソートしてから使うのが一般的 ; SORT(A) => // COORDINATE_COMPRESSION(A) #define COORDINATE_COMPRESSION(A) \ (A).erase(unique((A).begin(), (A).end()), (A).end()) template <class T> inline int argmin(std::vector<T> vec) { return min_element(vec.begin(), vec.end()) - vec.begin(); } template <class T> inline int argmax(std::vector<T> vec) { return max_element(vec.begin(), vec.end()) - vec.begin(); } template <class T> inline void chmax(T &a, T b) { if (a < b) a = b; } template <class T> inline void chmin(T &a, T b) { if (a > b) a = b; } template <class T> inline void reverseSORT(Vec<T> &Array) { std::sort(Array.begin(), Array.end(), std::greater<T>()); } inline int BitI(int k) { return 1 << k; } inline lli BitL(int k) { return 1LL << k; } inline void putsDouble(double d) { printf("%.16lf\n", d); } inline int toInt(const string &s) { int res = 0; for (char a : s) res = 10 * res + (a - '0'); return res; } inline long long int toLong(const string &s) { lli res = 0; for (char a : s) res = 10 * res + (a - '0'); return res; } template <class T> inline std::string toString(T n) { if (n == 0) return "0"; std::string res; if (n < 0) { n = -n; while (n != 0) { res += (char)(n % 10 + '0'); n /= 10; } std::reverse(res.begin(), res.end()); return '-' + res; } while (n != 0) { res += (char)(n % 10 + '0'); n /= 10; } std::reverse(res.begin(), res.end()); return res; } // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int main(void) { int h, w; scanf("%d%d", &h, &w); Wbool Odd(h, Vbool(w)); REP(i, h) REP(j, w) { short a; scanf("%hd", &a); Odd[i][j] = (a & 1); } using information = std::tuple<int, int, int, int>; std::queue<information> ANS; REP(i, h) REP(j, w - 1) { if (Odd[i][j]) { ANS.push(make_tuple(i + 1, j + 1, i + 1, j + 2)); Odd[i][j] = false; Odd[i][j + 1] = not Odd[i][j + 1]; } } REP(i, h - 1) { if (Odd[i][w - 1]) { ANS.push(make_tuple(i + 1, w, i + 2, w)); Odd[i][w - 1] = false; Odd[i + 1][w - 1] = not Odd[i + 1][w - 1]; } } printf("%lu\n", ANS.size()); while (not ANS.empty()) { int a, b, c, d; std::tie(a, b, c, d) = ANS.front(); ANS.pop(); printf("%d %d %d %d\n", a, b, c, d); } return 0; }
replace
124
125
124
125
0
p03263
C++
Runtime Error
#include <algorithm> #include <bitset> #include <cassert> #include <climits> #include <cmath> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <string.h> #include <string> #include <vector> using namespace std; typedef long long ll; typedef pair<ll, ll> P; long long int INF = 1e18; double Pi = 3.141592653589; long long int mod = 998244353; // memset(a,0,sizeof(a)); →全部0にする vector<ll> G[100005]; vector<P> tree[100010]; priority_queue<ll> pql; priority_queue<P> pqp; // big priority queue priority_queue<ll, vector<ll>, greater<ll>> pqls; priority_queue<P, vector<P>, greater<P>> pqps; // small priority queue // top pop int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1}; int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1}; // ↓,→,↑,← #define p(x) cout << x << endl; #define el cout << endl; #define pe(x) cout << x << " "; #define ps(x) cout << fixed << setprecision(25) << x << endl; #define pu(x) cout << x; #define re(i, a, b) \ for (i = a; i <= b; i++) \ ; #define pb push_back #define lb lower_bound #define ub upper_bound #define deba(x) cout << #x << " = " << x << endl ll rui(ll abc, ll bed) { // aのb乗を計算する if (bed == 0) { return 1; } else { ll ced = rui(abc, bed / 2); ced *= ced; ced %= mod; if (bed % 2 == 1) { ced *= abc; ced %= mod; } return ced; } } ll i, j, k, ii, jj; ll n, m, num, sumxor, sum, ans; ll a, b, c, d, e, f, g, h, w, v; // ll x[800005],y[800005],z[900005]; ll d1[100005], d2[100005], d3[100005], d4[100005]; ll dp[1000][1000]; int main() { cin >> h >> w; for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { cin >> dp[i][j]; } } for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { if (dp[i][j] % 2 == 1) { if (j < w - 1) { d1[num] = i; d2[num] = j; d3[num] = i; d4[num] = j + 1; dp[i][j]--; dp[i][j + 1]++; num++; } else if (i < h - 1) { d1[num] = i; d2[num] = j; d3[num] = i + 1; d4[num] = j; dp[i][j]--; dp[i + 1][j]++; num++; } } } } // assert(num <= h*w); p(num); for (i = 0; i < num; i++) { pe(d1[i] + 1); pe(d2[i] + 1); pe(d3[i] + 1); p(d4[i] + 1); } return 0; }
#include <algorithm> #include <bitset> #include <cassert> #include <climits> #include <cmath> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <string.h> #include <string> #include <vector> using namespace std; typedef long long ll; typedef pair<ll, ll> P; long long int INF = 1e18; double Pi = 3.141592653589; long long int mod = 998244353; // memset(a,0,sizeof(a)); →全部0にする vector<ll> G[100005]; vector<P> tree[100010]; priority_queue<ll> pql; priority_queue<P> pqp; // big priority queue priority_queue<ll, vector<ll>, greater<ll>> pqls; priority_queue<P, vector<P>, greater<P>> pqps; // small priority queue // top pop int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1}; int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1}; // ↓,→,↑,← #define p(x) cout << x << endl; #define el cout << endl; #define pe(x) cout << x << " "; #define ps(x) cout << fixed << setprecision(25) << x << endl; #define pu(x) cout << x; #define re(i, a, b) \ for (i = a; i <= b; i++) \ ; #define pb push_back #define lb lower_bound #define ub upper_bound #define deba(x) cout << #x << " = " << x << endl ll rui(ll abc, ll bed) { // aのb乗を計算する if (bed == 0) { return 1; } else { ll ced = rui(abc, bed / 2); ced *= ced; ced %= mod; if (bed % 2 == 1) { ced *= abc; ced %= mod; } return ced; } } ll i, j, k, ii, jj; ll n, m, num, sumxor, sum, ans; ll a, b, c, d, e, f, g, h, w, v; // ll x[800005],y[800005],z[900005]; ll d1[500005], d2[500005], d3[500005], d4[500005]; ll dp[1000][1000]; int main() { cin >> h >> w; for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { cin >> dp[i][j]; } } for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { if (dp[i][j] % 2 == 1) { if (j < w - 1) { d1[num] = i; d2[num] = j; d3[num] = i; d4[num] = j + 1; dp[i][j]--; dp[i][j + 1]++; num++; } else if (i < h - 1) { d1[num] = i; d2[num] = j; d3[num] = i + 1; d4[num] = j; dp[i][j]--; dp[i + 1][j]++; num++; } } } } // assert(num <= h*w); p(num); for (i = 0; i < num; i++) { pe(d1[i] + 1); pe(d2[i] + 1); pe(d3[i] + 1); p(d4[i] + 1); } return 0; }
replace
73
74
73
74
0
p03263
C++
Runtime Error
#include <bits/stdc++.h> #define each(i, c) for (auto &i : c) #define unless(cond) if (!(cond)) using namespace std; typedef long long int lli; typedef unsigned long long ull; typedef complex<double> point; template <typename P, typename Q> ostream &operator<<(ostream &os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; } template <typename T> ostream &operator<<(ostream &os, vector<T> v) { os << "("; each(i, v) os << i << ","; os << ")"; return os; } int main(int argc, char *argv[]) { ios_base::sync_with_stdio(0); cin.tie(0); int h, w; while (cin >> h >> w) { int g[h][w]; for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) { cin >> g[i][j]; } } vector<pair<pair<int, int>, pair<int, int>>> v; for (int i = 0; i < h; ++i) { vector<int> odd; for (int j = 0; j + 1 < w; ++j) { if (g[i][j] % 2) { odd.push_back(j); v.push_back(make_pair(make_pair(i, j), make_pair(i, j + 1))); --g[i][j]; ++g[i][j + 1]; } } if (g[i][w - 1] % 2) { v.push_back(make_pair(make_pair(i, w - 1), make_pair(i + 1, w - 1))); --g[i][w - 1]; ++g[i + 1][w - 1]; } } cout << v.size() << endl; each(i, v) { int a = i.first.first; int b = i.first.second; int c = i.second.first; int d = i.second.second; cout << a + 1 << ' ' << b + 1 << ' ' << c + 1 << ' ' << d + 1 << endl; } } return 0; }
#include <bits/stdc++.h> #define each(i, c) for (auto &i : c) #define unless(cond) if (!(cond)) using namespace std; typedef long long int lli; typedef unsigned long long ull; typedef complex<double> point; template <typename P, typename Q> ostream &operator<<(ostream &os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; } template <typename T> ostream &operator<<(ostream &os, vector<T> v) { os << "("; each(i, v) os << i << ","; os << ")"; return os; } int main(int argc, char *argv[]) { ios_base::sync_with_stdio(0); cin.tie(0); int h, w; while (cin >> h >> w) { int g[h][w]; for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) { cin >> g[i][j]; } } vector<pair<pair<int, int>, pair<int, int>>> v; for (int i = 0; i < h; ++i) { vector<int> odd; for (int j = 0; j + 1 < w; ++j) { if (g[i][j] % 2) { odd.push_back(j); v.push_back(make_pair(make_pair(i, j), make_pair(i, j + 1))); --g[i][j]; ++g[i][j + 1]; } } if (i + 1 < h && g[i][w - 1] % 2) { v.push_back(make_pair(make_pair(i, w - 1), make_pair(i + 1, w - 1))); --g[i][w - 1]; ++g[i + 1][w - 1]; } } cout << v.size() << endl; each(i, v) { int a = i.first.first; int b = i.first.second; int c = i.second.first; int d = i.second.second; cout << a + 1 << ' ' << b + 1 << ' ' << c + 1 << ' ' << d + 1 << endl; } } return 0; }
replace
48
49
48
49
0
p03263
C++
Runtime Error
#include <bits/stdc++.h> // #include <boost/multiprecision/cpp_int.hpp> using namespace std; // using namespace boost::multiprecision; typedef long long int ll; typedef long double ld; #define MOD 1000000007 #define ALL(obj) (obj).begin(), (obj).end() template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } const long long INF = 1LL << 60; bool pairCompare(const pair<double, ll> &firstElof, const pair<double, ll> &secondElof) { return firstElof.first < secondElof.first; } bool pairCompareSecond(const pair<double, ll> &firstElof, const pair<double, ll> &secondElof) { return firstElof.second < secondElof.second; } // 四方向への移動ベクトル const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; struct edge { // グラフに使うヤツ ll from, to, cost; }; typedef vector<vector<edge>> G; ll gcd(ll a, ll b) { if (a % b == 0) return (b); else return (gcd(b, a % b)); } int main() { ll h, w; cin >> h >> w; ll a[h][w]; for (ll i = 0; i < h; i++) { for (ll j = 0; j < w; j++) { cin >> a[i][j]; } } vector<pair<pair<ll, ll>, pair<ll, ll>>> ans; for (ll i = 0; i < w; i++) { if (i % 2) { for (ll j = h - 1; j >= 0; j--) { if (i == w - 1 and j == 0) break; if (a[j][i] % 2) { pair<ll, ll> p1, p2; p1 = make_pair(j, i); a[j][i]--; if (j == 0) { p2 = make_pair(j, i + 1); a[j][i + 1]++; } else { p2 = make_pair(j + 1, i); a[j + 1][i]++; } ans.push_back(make_pair(p1, p2)); } } } else { for (ll j = 0; j < h; j++) { if (i == w - 1 and j == h - 1) break; if (a[j][i] % 2) { pair<ll, ll> p1, p2; p1 = make_pair(j, i); a[j][i]--; if (j == h - 1) { p2 = make_pair(j, i + 1); a[j][i + 1]++; } else { p2 = make_pair(j + 1, i); a[j + 1][i]++; } ans.push_back(make_pair(p1, p2)); } } } } cout << ans.size() << endl; for (ll i = 0; i < ans.size(); i++) { pair<ll, ll> p1, p2; p1 = ans[i].first; p2 = ans[i].second; cout << p1.first + 1 << " " << p1.second + 1 << " " << p2.first + 1 << " " << p2.second + 1 << endl; } return 0; }
#include <bits/stdc++.h> // #include <boost/multiprecision/cpp_int.hpp> using namespace std; // using namespace boost::multiprecision; typedef long long int ll; typedef long double ld; #define MOD 1000000007 #define ALL(obj) (obj).begin(), (obj).end() template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } const long long INF = 1LL << 60; bool pairCompare(const pair<double, ll> &firstElof, const pair<double, ll> &secondElof) { return firstElof.first < secondElof.first; } bool pairCompareSecond(const pair<double, ll> &firstElof, const pair<double, ll> &secondElof) { return firstElof.second < secondElof.second; } // 四方向への移動ベクトル const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; struct edge { // グラフに使うヤツ ll from, to, cost; }; typedef vector<vector<edge>> G; ll gcd(ll a, ll b) { if (a % b == 0) return (b); else return (gcd(b, a % b)); } int main() { ll h, w; cin >> h >> w; ll a[h][w]; for (ll i = 0; i < h; i++) { for (ll j = 0; j < w; j++) { cin >> a[i][j]; } } vector<pair<pair<ll, ll>, pair<ll, ll>>> ans; for (ll i = 0; i < w; i++) { if (i % 2) { for (ll j = h - 1; j >= 0; j--) { if (i == w - 1 and j == 0) break; if (a[j][i] % 2) { pair<ll, ll> p1, p2; p1 = make_pair(j, i); a[j][i]--; if (j == 0) { p2 = make_pair(j, i + 1); a[j][i + 1]++; } else { p2 = make_pair(j - 1, i); a[j - 1][i]++; } ans.push_back(make_pair(p1, p2)); } } } else { for (ll j = 0; j < h; j++) { if (i == w - 1 and j == h - 1) break; if (a[j][i] % 2) { pair<ll, ll> p1, p2; p1 = make_pair(j, i); a[j][i]--; if (j == h - 1) { p2 = make_pair(j, i + 1); a[j][i + 1]++; } else { p2 = make_pair(j + 1, i); a[j + 1][i]++; } ans.push_back(make_pair(p1, p2)); } } } } cout << ans.size() << endl; for (ll i = 0; i < ans.size(); i++) { pair<ll, ll> p1, p2; p1 = ans[i].first; p2 = ans[i].second; cout << p1.first + 1 << " " << p1.second + 1 << " " << p2.first + 1 << " " << p2.second + 1 << endl; } return 0; }
replace
70
72
70
72
0
p03263
C++
Runtime Error
#include <cstdio> using namespace std; int vv[505][505]; int v[50005][5]; int count = 0; int main() { int h, w; scanf("%d%d", &h, &w); for (int i = 1; i <= h; i++) for (int j = 1; j <= w; j++) scanf("%d", &vv[i][j]); for (int i = 1; i <= h; i++) for (int j = 1; j <= w; j++) { if (vv[i][j] % 2 == 1) { if (j + 1 <= w && (vv[i][j] + vv[i][j + 1]) % 2 == 0) { vv[i][j]--; vv[i][j + 1]++; count++; v[count][1] = v[count][3] = i; v[count][2] = j; v[count][4] = j + 1; } else if (i + 1 <= h && (vv[i][j] + vv[i + 1][j]) % 2 == 0) { vv[i][j]--; vv[i + 1][j]++; count++; v[count][1] = i; v[count][3] = i + 1; v[count][2] = v[count][4] = j; } else if (j + 1 <= w) { vv[i][j]--; vv[i][j + 1]++; count++; v[count][1] = v[count][3] = i; v[count][2] = j; v[count][4] = j + 1; } else if (i + 1 <= h) { vv[i][j]--; vv[i + 1][j]++; count++; v[count][1] = i; v[count][3] = i + 1; v[count][2] = v[count][4] = j; } } } printf("%d\n", count); for (int i = 1; i <= count; i++) printf("%d %d %d %d\n", v[i][1], v[i][2], v[i][3], v[i][4]); return 0; }
#include <cstdio> using namespace std; int vv[505][505]; int v[250005][5]; int count = 0; int main() { int h, w; scanf("%d%d", &h, &w); for (int i = 1; i <= h; i++) for (int j = 1; j <= w; j++) scanf("%d", &vv[i][j]); for (int i = 1; i <= h; i++) for (int j = 1; j <= w; j++) { if (vv[i][j] % 2 == 1) { if (j + 1 <= w && (vv[i][j] + vv[i][j + 1]) % 2 == 0) { vv[i][j]--; vv[i][j + 1]++; count++; v[count][1] = v[count][3] = i; v[count][2] = j; v[count][4] = j + 1; } else if (i + 1 <= h && (vv[i][j] + vv[i + 1][j]) % 2 == 0) { vv[i][j]--; vv[i + 1][j]++; count++; v[count][1] = i; v[count][3] = i + 1; v[count][2] = v[count][4] = j; } else if (j + 1 <= w) { vv[i][j]--; vv[i][j + 1]++; count++; v[count][1] = v[count][3] = i; v[count][2] = j; v[count][4] = j + 1; } else if (i + 1 <= h) { vv[i][j]--; vv[i + 1][j]++; count++; v[count][1] = i; v[count][3] = i + 1; v[count][2] = v[count][4] = j; } } } printf("%d\n", count); for (int i = 1; i <= count; i++) printf("%d %d %d %d\n", v[i][1], v[i][2], v[i][3], v[i][4]); return 0; }
replace
3
4
3
4
0
p03263
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define int long long typedef pair<int, int> P; int INF = 1e9 + 7; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; signed main() { int H, W; cin >> H >> W; vector<vector<int>> a(H, vector<int>(W)); vector<vector<int>> ans(H * W, vector<int>(4)); for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { cin >> a[i][j]; } } int X = 0; int Y = 0; int A = 0; int B = 0; int cnt = 0; while (X < H && Y < W) { bool ok = false; if (a[X][Y] % 2 == 1) { ok = true; A = X; B = Y; } if (X % 2 == 0) { if (Y + 1 < W) { Y++; } else { X++; } } else { if (Y - 1 >= 0) { Y--; } else { X++; } } if (ok) { a[X][Y] += 1; ans[cnt] = {A + 1, B + 1, X + 1, Y + 1}; cnt++; } } cout << cnt << endl; for (int i = 0; i < cnt; i++) { for (int j = 0; j < 4; j++) { cout << ans[i][j]; if (j + 1 != 4) { cout << " "; } } cout << endl; } }
#include <bits/stdc++.h> using namespace std; #define int long long typedef pair<int, int> P; int INF = 1e9 + 7; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; signed main() { int H, W; cin >> H >> W; vector<vector<int>> a(H, vector<int>(W)); vector<vector<int>> ans(H * W, vector<int>(4)); for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { cin >> a[i][j]; } } int X = 0; int Y = 0; int A = 0; int B = 0; int cnt = 0; while (X < H && Y < W) { bool ok = false; if (a[X][Y] % 2 == 1) { ok = true; A = X; B = Y; } if (X % 2 == 0) { if (Y + 1 < W) { Y++; } else { X++; } } else { if (Y - 1 >= 0) { Y--; } else { X++; } } if (ok && X < H) { a[X][Y] += 1; ans[cnt] = {A + 1, B + 1, X + 1, Y + 1}; cnt++; } } cout << cnt << endl; for (int i = 0; i < cnt; i++) { for (int j = 0; j < 4; j++) { cout << ans[i][j]; if (j + 1 != 4) { cout << " "; } } cout << endl; } }
replace
42
43
42
43
0
p03263
C++
Runtime Error
#include "iostream" using namespace std; int main() { int h, w; cin >> h >> w; int a[510][510]; int check[30000][4]; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { cin >> a[i][j]; } } int ans = 0; for (int i = 0; i < h; i++) { for (int j = 0; j < w - 1; j++) { if (a[i][j] % 2 == 1) { check[ans][0] = i; check[ans][1] = j; check[ans][2] = i; check[ans][3] = j + 1; ans++; a[i][j + 1]++; } } } for (int i = 0; i < h - 1; i++) { if (a[i][w - 1] % 2 == 1) { check[ans][0] = i; check[ans][1] = w - 1; check[ans][2] = i + 1; check[ans][3] = w - 1; ans++; a[i + 1][w - 1]++; } } cout << ans << endl; for (int i = 0; i < ans; i++) { cout << check[i][0] + 1 << " " << check[i][1] + 1 << " " << check[i][2] + 1 << " " << check[i][3] + 1 << endl; } }
#include "iostream" using namespace std; int main() { int h, w; cin >> h >> w; int a[510][510]; int check[250250][4]; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { cin >> a[i][j]; } } int ans = 0; for (int i = 0; i < h; i++) { for (int j = 0; j < w - 1; j++) { if (a[i][j] % 2 == 1) { check[ans][0] = i; check[ans][1] = j; check[ans][2] = i; check[ans][3] = j + 1; ans++; a[i][j + 1]++; } } } for (int i = 0; i < h - 1; i++) { if (a[i][w - 1] % 2 == 1) { check[ans][0] = i; check[ans][1] = w - 1; check[ans][2] = i + 1; check[ans][3] = w - 1; ans++; a[i + 1][w - 1]++; } } cout << ans << endl; for (int i = 0; i < ans; i++) { cout << check[i][0] + 1 << " " << check[i][1] + 1 << " " << check[i][2] + 1 << " " << check[i][3] + 1 << endl; } }
replace
7
8
7
8
0
p03263
C++
Runtime Error
// abc109_d.cpp // Sun Apr 21 19:49:14 2019 #include <algorithm> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <string> #include <unordered_map> #include <vector> #define INTINF 2147483647 #define LLINF 9223372036854775807 using namespace std; using ll = long long; typedef pair<int, int> P; int main() { int h, w; cin >> h >> w; vector<P> oddpair; int a[h][w]; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { cin >> a[i][j]; } } int dir = -1; for (int i = 0; i < h; i++) { dir = dir * (-1); if (dir == 1) { for (int j = 0; j < w; j++) { if (a[i][j] % 2 == 1) { P temp; temp.first = i; temp.second = j; oddpair.push_back(temp); } } } else { for (int j = w - 1; j >= 0; j--) { if (a[i][j] % 2 == 1) { P temp; temp.first = i; temp.second = j; oddpair.push_back(temp); } } } } int count = 0; int y1[500]; int x1[500]; int y1d[500]; int x1d[500]; for (int i = 0; i < oddpair.size(); i++) { if (i == oddpair.size() - 1) { break; } P fromp = oddpair[i]; i++; P top = oddpair[i]; // cout << fromp.first << " " << fromp.second << " - " << top.first << " //" << top.second << endl; int dir = 0; if (fromp.first % 2 == 0) { dir = 1; } else { dir = -1; } while (fromp.first != top.first || fromp.second != top.second) { // cout << "pass" << endl; if (fromp.second == 0 && dir == -1) { y1[count] = fromp.first; x1[count] = fromp.second; y1d[count] = fromp.first + 1; x1d[count] = fromp.second; fromp.first++; dir = 1; } else if (fromp.second == w - 1 && dir == 1) { y1[count] = fromp.first; x1[count] = fromp.second; y1d[count] = fromp.first + 1; x1d[count] = fromp.second; fromp.first++; dir = -1; } else { y1[count] = fromp.first; x1[count] = fromp.second; y1d[count] = fromp.first; x1d[count] = fromp.second + dir; fromp.second += dir; } count++; } } cout << count << endl; for (int i = 0; i < count; i++) { cout << y1[i] + 1 << " " << x1[i] + 1 << " " << y1d[i] + 1 << " " << x1d[i] + 1 << endl; } }
// abc109_d.cpp // Sun Apr 21 19:49:14 2019 #include <algorithm> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <string> #include <unordered_map> #include <vector> #define INTINF 2147483647 #define LLINF 9223372036854775807 using namespace std; using ll = long long; typedef pair<int, int> P; int main() { int h, w; cin >> h >> w; vector<P> oddpair; int a[h][w]; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { cin >> a[i][j]; } } int dir = -1; for (int i = 0; i < h; i++) { dir = dir * (-1); if (dir == 1) { for (int j = 0; j < w; j++) { if (a[i][j] % 2 == 1) { P temp; temp.first = i; temp.second = j; oddpair.push_back(temp); } } } else { for (int j = w - 1; j >= 0; j--) { if (a[i][j] % 2 == 1) { P temp; temp.first = i; temp.second = j; oddpair.push_back(temp); } } } } int count = 0; int y1[250000]; int x1[250000]; int y1d[250000]; int x1d[250000]; for (int i = 0; i < oddpair.size(); i++) { if (i == oddpair.size() - 1) { break; } P fromp = oddpair[i]; i++; P top = oddpair[i]; // cout << fromp.first << " " << fromp.second << " - " << top.first << " //" << top.second << endl; int dir = 0; if (fromp.first % 2 == 0) { dir = 1; } else { dir = -1; } while (fromp.first != top.first || fromp.second != top.second) { // cout << "pass" << endl; if (fromp.second == 0 && dir == -1) { y1[count] = fromp.first; x1[count] = fromp.second; y1d[count] = fromp.first + 1; x1d[count] = fromp.second; fromp.first++; dir = 1; } else if (fromp.second == w - 1 && dir == 1) { y1[count] = fromp.first; x1[count] = fromp.second; y1d[count] = fromp.first + 1; x1d[count] = fromp.second; fromp.first++; dir = -1; } else { y1[count] = fromp.first; x1[count] = fromp.second; y1d[count] = fromp.first; x1d[count] = fromp.second + dir; fromp.second += dir; } count++; } } cout << count << endl; for (int i = 0; i < count; i++) { cout << y1[i] + 1 << " " << x1[i] + 1 << " " << y1d[i] + 1 << " " << x1d[i] + 1 << endl; } }
replace
55
59
55
59
0
p03263
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; const int maxn = 250001; int he, le, a[501][501] = {0}, i, j, q[maxn], w[maxn], e[maxn], r[maxn], now = 0; int main() { cin >> he >> le; for (i = 1; i <= he; i++) { for (j = 1; j <= le; j++) { cin >> a[i][j]; } } for (i = 1; i <= he; i++) { for (j = 1; j <= le; j++) { if (a[i][j] % 2 == 0) continue; else if (a[i][j + 1] % 2 && j + 1 <= le) { a[i][j + 1] += 1; now++; q[now] = i; w[now] = j; e[now] = i; r[now] = j + 1; } else if (a[i + 1][j] % 2 && i + 1 <= he) { a[i + 1][j] += 1; now++; q[now] = i; w[now] = j; e[now] = i + 1; r[now] = j; } else if (j + 1 <= le) { a[i][j + 1] += 1; now++; q[now] = i; w[now] = j; e[now] = i; r[now] = j + 1; } else if (i + 1 <= he) { a[i + 1][j] += 1; now++; q[now] = i; w[now] = j; e[now] = i + 1; r[now] = j; } } } cout << now << endl; for (i = 1; i <= now; i++) { cout << q[i] << ' ' << w[i] << ' ' << e[i] << ' ' << r[i] << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; const int maxn = 300001; int he, le, a[501][501] = {0}, i, j, q[maxn], w[maxn], e[maxn], r[maxn], now = 0; int main() { cin >> he >> le; for (i = 1; i <= he; i++) { for (j = 1; j <= le; j++) { cin >> a[i][j]; } } for (i = 1; i <= he; i++) { for (j = 1; j <= le; j++) { if (a[i][j] % 2 == 0) continue; else if (a[i][j + 1] % 2 && j + 1 <= le) { a[i][j + 1] += 1; now++; q[now] = i; w[now] = j; e[now] = i; r[now] = j + 1; } else if (a[i + 1][j] % 2 && i + 1 <= he) { a[i + 1][j] += 1; now++; q[now] = i; w[now] = j; e[now] = i + 1; r[now] = j; } else if (j + 1 <= le) { a[i][j + 1] += 1; now++; q[now] = i; w[now] = j; e[now] = i; r[now] = j + 1; } else if (i + 1 <= he) { a[i + 1][j] += 1; now++; q[now] = i; w[now] = j; e[now] = i + 1; r[now] = j; } } } cout << now << endl; for (i = 1; i <= now; i++) { cout << q[i] << ' ' << w[i] << ' ' << e[i] << ' ' << r[i] << endl; } return 0; }
replace
2
3
2
3
0
p03263
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define erep(i, n) for (int i = 0; i <= n; i++) #define rep1(i, n) for (int i = 1; i < n; i++) #define erep1(i, n) for (int i = 1; i <= n; i++) typedef long long ll; #define vint vector<int> #define vvint vector<vector<int>> #define vstring vector<string> #define vdouble vector<double> #define vll vector<ll>: #define vbool vector<bool> #define INF 1101010101010101010 #define MOD 1000000007 #define int long long using P = pair<int, int>; signed main() { int h, w; cin >> h >> w; vvint mass(h, vint(w)); rep(i, h) rep(j, w) cin >> mass[i][j]; bool judge = false; int count = 0; vector<vector<int>> ans(30000, vint(4)); rep(i, h) { if (i % 2 == 0) { rep(j, w) { if (i != h - 1 || j != w - 1) { if (mass[i][j] % 2 == 1 && !(judge)) { judge = true; if (j == w - 1) { ans[count][0] = i + 1; ans[count][1] = j + 1; ans[count][2] = i + 2; ans[count][3] = j + 1; } else { ans[count][0] = i + 1; ans[count][1] = j + 1; ans[count][2] = i + 1; ans[count][3] = j + 2; } count++; } else if (mass[i][j] % 2 == 1 && judge) { judge = false; } else if (mass[i][j] % 2 == 0 && judge) { if (j == w - 1) { ans[count][0] = i + 1; ans[count][1] = j + 1; ans[count][2] = i + 2; ans[count][3] = j + 1; } else { ans[count][0] = i + 1; ans[count][1] = j + 1; ans[count][2] = i + 1; ans[count][3] = j + 2; } count++; } } } } else { for (int j = w - 1; j >= 0; j--) { if (i != h - 1 || j != 0) { if (mass[i][j] % 2 == 1 && !(judge)) { judge = true; if (j == 0) { ans[count][0] = i + 1; ans[count][1] = 1; ans[count][2] = i + 2; ans[count][3] = 1; } else { ans[count][0] = i + 1; ans[count][1] = j + 1; ans[count][2] = i + 1; ans[count][3] = j; } count++; } else if (mass[i][j] % 2 == 1 && judge) { judge = false; } else if (mass[i][j] % 2 == 0 && judge) { if (j == 0) { ans[count][0] = i + 1; ans[count][1] = 1; ans[count][2] = i + 2; ans[count][3] = 1; } else { ans[count][0] = i + 1; ans[count][1] = j + 1; ans[count][2] = i + 1; ans[count][3] = j; } count++; } } } } } cout << count << endl; rep(i, count) { cout << ans[i][0] << " " << ans[i][1] << " " << ans[i][2] << " " << ans[i][3] << endl; } }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define erep(i, n) for (int i = 0; i <= n; i++) #define rep1(i, n) for (int i = 1; i < n; i++) #define erep1(i, n) for (int i = 1; i <= n; i++) typedef long long ll; #define vint vector<int> #define vvint vector<vector<int>> #define vstring vector<string> #define vdouble vector<double> #define vll vector<ll>: #define vbool vector<bool> #define INF 1101010101010101010 #define MOD 1000000007 #define int long long using P = pair<int, int>; signed main() { int h, w; cin >> h >> w; vvint mass(h, vint(w)); rep(i, h) rep(j, w) cin >> mass[i][j]; bool judge = false; int count = 0; vector<vector<int>> ans(300000, vint(4)); rep(i, h) { if (i % 2 == 0) { rep(j, w) { if (i != h - 1 || j != w - 1) { if (mass[i][j] % 2 == 1 && !(judge)) { judge = true; if (j == w - 1) { ans[count][0] = i + 1; ans[count][1] = j + 1; ans[count][2] = i + 2; ans[count][3] = j + 1; } else { ans[count][0] = i + 1; ans[count][1] = j + 1; ans[count][2] = i + 1; ans[count][3] = j + 2; } count++; } else if (mass[i][j] % 2 == 1 && judge) { judge = false; } else if (mass[i][j] % 2 == 0 && judge) { if (j == w - 1) { ans[count][0] = i + 1; ans[count][1] = j + 1; ans[count][2] = i + 2; ans[count][3] = j + 1; } else { ans[count][0] = i + 1; ans[count][1] = j + 1; ans[count][2] = i + 1; ans[count][3] = j + 2; } count++; } } } } else { for (int j = w - 1; j >= 0; j--) { if (i != h - 1 || j != 0) { if (mass[i][j] % 2 == 1 && !(judge)) { judge = true; if (j == 0) { ans[count][0] = i + 1; ans[count][1] = 1; ans[count][2] = i + 2; ans[count][3] = 1; } else { ans[count][0] = i + 1; ans[count][1] = j + 1; ans[count][2] = i + 1; ans[count][3] = j; } count++; } else if (mass[i][j] % 2 == 1 && judge) { judge = false; } else if (mass[i][j] % 2 == 0 && judge) { if (j == 0) { ans[count][0] = i + 1; ans[count][1] = 1; ans[count][2] = i + 2; ans[count][3] = 1; } else { ans[count][0] = i + 1; ans[count][1] = j + 1; ans[count][2] = i + 1; ans[count][3] = j; } count++; } } } } } cout << count << endl; rep(i, count) { cout << ans[i][0] << " " << ans[i][1] << " " << ans[i][2] << " " << ans[i][3] << endl; } }
replace
25
26
25
26
0
p03263
C++
Runtime Error
#include <algorithm> #include <cstdio> #include <cstring> #include <functional> using namespace std; int main(void) { int i, j, h, w, a[501][501], q[25000][2], p1, p2, p3, x, y, x1, y1; int n, xy[25000][4]; scanf("%d %d", &h, &w); for (i = 1; i <= h; i++) { for (j = 1; j <= w; j++) { scanf("%d", &a[i][j]); } } p1 = 0; for (i = 1; i <= h; i++) { if (i % 2 == 1) { for (j = 1; j <= w; j++) { q[p1][0] = i; q[p1][1] = j; p1++; } } else { for (j = w; j >= 1; j--) { q[p1][0] = i; q[p1][1] = j; p1++; } } } p2 = 0; for (i = 0; i < p1 - 1; i++) { y = q[i][0]; x = q[i][1]; y1 = q[i + 1][0]; x1 = q[i + 1][1]; if (a[y][x] % 2 == 1) { a[y][x]--; a[y1][x1]++; xy[p2][0] = y; xy[p2][1] = x; xy[p2][2] = y1; xy[p2][3] = x1; p2++; } } printf("%d\n", p2); for (i = 0; i < p2; i++) { printf("%d %d %d %d\n", xy[i][0], xy[i][1], xy[i][2], xy[i][3]); } return 0; }
#include <algorithm> #include <cstdio> #include <cstring> #include <functional> using namespace std; int main(void) { int i, j, h, w, a[501][501], q[250000][2], p1, p2, p3, x, y, x1, y1; int n, xy[250000][4]; scanf("%d %d", &h, &w); for (i = 1; i <= h; i++) { for (j = 1; j <= w; j++) { scanf("%d", &a[i][j]); } } p1 = 0; for (i = 1; i <= h; i++) { if (i % 2 == 1) { for (j = 1; j <= w; j++) { q[p1][0] = i; q[p1][1] = j; p1++; } } else { for (j = w; j >= 1; j--) { q[p1][0] = i; q[p1][1] = j; p1++; } } } p2 = 0; for (i = 0; i < p1 - 1; i++) { y = q[i][0]; x = q[i][1]; y1 = q[i + 1][0]; x1 = q[i + 1][1]; if (a[y][x] % 2 == 1) { a[y][x]--; a[y1][x1]++; xy[p2][0] = y; xy[p2][1] = x; xy[p2][2] = y1; xy[p2][3] = x1; p2++; } } printf("%d\n", p2); for (i = 0; i < p2; i++) { printf("%d %d %d %d\n", xy[i][0], xy[i][1], xy[i][2], xy[i][3]); } return 0; }
replace
6
8
6
8
0
p03263
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int h, w, a[50005], i, j, cnt = 0; bool odd = false, t = false; scanf("%d%d", &h, &w); for (i = 0; i < h; i++) for (j = 0; j < w; j++) scanf("%d", &a[i * w + (i % 2 ? j : w - 1 - j)]); for (i = 0; i < h * w; i++) { if (odd) cnt++; if (a[i] % 2) odd ^= true; } printf("%d\n", cnt); for (i = 0; i < h * w; i++) { if (t) printf("%d %d %d %d\n", (i - 1) / w + 1, ((i - 1) / w % 2 ? (i - 1) % w : w - 1 - (i - 1) % w) + 1, i / w + 1, (i / w % 2 ? i % w : w - 1 - i % w) + 1); if (a[i] % 2) t ^= true; } }
#include <bits/stdc++.h> using namespace std; int main() { int h, w, a[250005], i, j, cnt = 0; bool odd = false, t = false; scanf("%d%d", &h, &w); for (i = 0; i < h; i++) for (j = 0; j < w; j++) scanf("%d", &a[i * w + (i % 2 ? j : w - 1 - j)]); for (i = 0; i < h * w; i++) { if (odd) cnt++; if (a[i] % 2) odd ^= true; } printf("%d\n", cnt); for (i = 0; i < h * w; i++) { if (t) printf("%d %d %d %d\n", (i - 1) / w + 1, ((i - 1) / w % 2 ? (i - 1) % w : w - 1 - (i - 1) % w) + 1, i / w + 1, (i / w % 2 ? i % w : w - 1 - i % w) + 1); if (a[i] % 2) t ^= true; } }
replace
4
5
4
5
0
p03263
C++
Runtime Error
#include <algorithm> #include <cstdio> #include <cstring> using namespace std; const int maxn = 510; int n, m; int a[maxn][maxn], b[maxn][5]; int main() { int ans = 0; scanf("%d%d", &n, &m); for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) scanf("%d", &a[i][j]); for (int i = 1; i <= n; i++) for (int j = 1; j <= m - 1; j++) { if (a[i][j] & 1) { b[ans][1] = i; b[ans][2] = j; b[ans][3] = i; b[ans][4] = j + 1; ans++; a[i][j + 1]++; } } for (int i = 1; i <= n - 1; i++) { if (a[i][m] & 1) { b[ans][1] = i; b[ans][2] = m; b[ans][3] = i + 1; b[ans][4] = m; ans++; a[i + 1][m]++; } } printf("%d\n", ans); for (int i = 0; i < ans; i++) printf("%d %d %d %d\n", b[i][1], b[i][2], b[i][3], b[i][4]); return 0; }
#include <algorithm> #include <cstdio> #include <cstring> using namespace std; const int maxn = 510; int n, m; int a[maxn][maxn], b[maxn * maxn][5]; int main() { int ans = 0; scanf("%d%d", &n, &m); for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) scanf("%d", &a[i][j]); for (int i = 1; i <= n; i++) for (int j = 1; j <= m - 1; j++) { if (a[i][j] & 1) { b[ans][1] = i; b[ans][2] = j; b[ans][3] = i; b[ans][4] = j + 1; ans++; a[i][j + 1]++; } } for (int i = 1; i <= n - 1; i++) { if (a[i][m] & 1) { b[ans][1] = i; b[ans][2] = m; b[ans][3] = i + 1; b[ans][4] = m; ans++; a[i + 1][m]++; } } printf("%d\n", ans); for (int i = 0; i < ans; i++) printf("%d %d %d %d\n", b[i][1], b[i][2], b[i][3], b[i][4]); return 0; }
replace
6
7
6
7
0
p03263
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; constexpr int Inf = 1000000000; constexpr ll INF = 1e18; constexpr ll MOD = 1000000007; const double PI = 3.1415926535897; typedef pair<int, int> P; int main() { int H, W; cin >> H >> W; vector<vector<int>> vec(H, vector<int>(W)); for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { cin >> vec.at(i).at(j); } } vector<pair<P, P>> ret; for (int i = 0; i < H; i++) { if (i % 2 == 0) { for (int j = 0; j < W - 1; j++) { if (vec.at(i).at(j) % 2 == 1) { ret.push_back(make_pair(P(i, j), P(i, j + 1))); vec.at(i).at(j + 1)++; } } if (vec.at(i).at(W - 1) % 2 == 1 && i != H - 1) { ret.push_back(make_pair(P(i, W - 1), P(i + 1, W - 1))); vec.at(i + 1).at(W + 1)++; } } else { for (int j = W - 1; j >= 1; j--) { if (vec.at(i).at(j) % 2 == 1) { ret.push_back(make_pair(P(i, j), P(i, j - 1))); vec.at(i).at(j - 1)++; } } if (vec.at(i).at(0) % 2 == 1 && i != H - 1) { ret.push_back(make_pair(P(i, 0), P(i + 1, 0))); vec.at(i + 1).at(0)++; } } } cout << ret.size() << endl; for (int i = 0; i < ret.size(); i++) { cout << ret.at(i).first.first + 1 << " " << ret.at(i).first.second + 1 << " " << ret.at(i).second.first + 1 << " " << ret.at(i).second.second + 1 << endl; } }
#include <bits/stdc++.h> using namespace std; typedef long long ll; constexpr int Inf = 1000000000; constexpr ll INF = 1e18; constexpr ll MOD = 1000000007; const double PI = 3.1415926535897; typedef pair<int, int> P; int main() { int H, W; cin >> H >> W; vector<vector<int>> vec(H, vector<int>(W)); for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { cin >> vec.at(i).at(j); } } vector<pair<P, P>> ret; for (int i = 0; i < H; i++) { if (i % 2 == 0) { for (int j = 0; j < W - 1; j++) { if (vec.at(i).at(j) % 2 == 1) { ret.push_back(make_pair(P(i, j), P(i, j + 1))); vec.at(i).at(j + 1)++; } } if (vec.at(i).at(W - 1) % 2 == 1 && i != H - 1) { ret.push_back(make_pair(P(i, W - 1), P(i + 1, W - 1))); vec.at(i + 1).at(W - 1)++; } } else { for (int j = W - 1; j >= 1; j--) { if (vec.at(i).at(j) % 2 == 1) { ret.push_back(make_pair(P(i, j), P(i, j - 1))); vec.at(i).at(j - 1)++; } } if (vec.at(i).at(0) % 2 == 1 && i != H - 1) { ret.push_back(make_pair(P(i, 0), P(i + 1, 0))); vec.at(i + 1).at(0)++; } } } cout << ret.size() << endl; for (int i = 0; i < ret.size(); i++) { cout << ret.at(i).first.first + 1 << " " << ret.at(i).first.second + 1 << " " << ret.at(i).second.first + 1 << " " << ret.at(i).second.second + 1 << endl; } }
replace
29
30
29
30
0
p03263
Python
Runtime Error
import sys sys.setrecursionlimit(10**6) INF = float("inf") MOD = 10**9 + 7 def input(): return sys.stdin.readline().strip() def main(): H, W = map(int, input().split()) A = [] cnt = 0 for _ in range(H): a = list(map(int, input().split())) cnt += sum(a) A.append(a) ans = [] for h in range(H): if h % 2 == 0: for w in range(W): if h == H - 1 and w == W - 1: continue if A[h][w] % 2 == 1: if w == W: A[h][w] -= 1 A[h + 1][w] += 1 ans.append((h, w, h + 1, w)) else: A[h][w] -= 1 A[h][w + 1] += 1 ans.append((h, w, h, w + 1)) else: continue else: for w in range(W)[::-1]: if h == H - 1 and w == 0: continue if A[h][w] % 2 == 1: if w == 0: A[h][w] -= 1 A[h + 1][w] += 1 ans.append((h, w, h + 1, w)) else: A[h][w] -= 1 A[h][w - 1] += 1 ans.append((h, w, h, w - 1)) else: continue print(len(ans)) for a, b, c, d in ans: print(a + 1, b + 1, c + 1, d + 1) if __name__ == "__main__": main()
import sys sys.setrecursionlimit(10**6) INF = float("inf") MOD = 10**9 + 7 def input(): return sys.stdin.readline().strip() def main(): H, W = map(int, input().split()) A = [] cnt = 0 for _ in range(H): a = list(map(int, input().split())) cnt += sum(a) A.append(a) ans = [] for h in range(H): if h % 2 == 0: for w in range(W): if h == H - 1 and w == W - 1: continue if A[h][w] % 2 == 1: if w == W - 1: A[h][w] -= 1 A[h + 1][w] += 1 ans.append((h, w, h + 1, w)) else: A[h][w] -= 1 A[h][w + 1] += 1 ans.append((h, w, h, w + 1)) else: continue else: for w in range(W)[::-1]: if h == H - 1 and w == 0: continue if A[h][w] % 2 == 1: if w == 0: A[h][w] -= 1 A[h + 1][w] += 1 ans.append((h, w, h + 1, w)) else: A[h][w] -= 1 A[h][w - 1] += 1 ans.append((h, w, h, w - 1)) else: continue print(len(ans)) for a, b, c, d in ans: print(a + 1, b + 1, c + 1, d + 1) if __name__ == "__main__": main()
replace
27
28
27
28
0
p03263
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, n) FOR(i, 0, n) #define ALL(a) (a).begin(), (a).end() #define VI vector<int> #define VVI vector<vector<int>> #define MOD 1000000007 using ll = long long int; using P = pair<int, int>; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } const ll INF = (ll)1e19; // const int INF=(1<<30); int cnt = 0; VVI ans; void f(VVI &a, int i, int j, int ni, int nj) { if (a[i][j] % 2 == 1) { a[i][j] -= 1; a[ni][nj] += 1; cnt++; VI tmp = {i, j, ni, nj}; ans.emplace_back(tmp); } } int main() { int h, w; cin >> h >> w; VVI a(h, VI(w, 0)); REP(i, h) REP(j, w) cin >> a[i][j]; int i = 0; int j = 0; do { if (i % 2 == 0) { if (j == w - 1) { f(a, i, j, i + 1, j); i++; } else { f(a, i, j, i, j + 1); j++; } } else { if (j == 0) { f(a, i, j, i + 1, j); i++; } else { f(a, i, j, i, j - 1); j--; } } } while (!(i == h - 1 && (i % 2 == 0 && j == w - 1 || i % 2 == 1 && j == 0))); cout << cnt << endl; for (auto v : ans) { REP(i, 4) { cout << v[i] + 1 << (i == 3 ? "\n" : " "); } } }
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) #define ALL(a) (a).begin(), (a).end() #define VI vector<int> #define VVI vector<vector<int>> #define MOD 1000000007 using ll = long long int; using P = pair<int, int>; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } const ll INF = (ll)1e19; // const int INF=(1<<30); int cnt = 0; VVI ans; void f(VVI &a, int i, int j, int ni, int nj) { if (a[i][j] % 2 == 1) { a[i][j] -= 1; a[ni][nj] += 1; cnt++; VI tmp = {i, j, ni, nj}; ans.emplace_back(tmp); } } int main() { int h, w; cin >> h >> w; if (h == 1 && w == 1) { cout << 0 << endl; return 0; } VVI a(h, VI(w, 0)); REP(i, h) REP(j, w) cin >> a[i][j]; int i = 0; int j = 0; do { if (i % 2 == 0) { if (j == w - 1) { f(a, i, j, i + 1, j); i++; } else { f(a, i, j, i, j + 1); j++; } } else { if (j == 0) { f(a, i, j, i + 1, j); i++; } else { f(a, i, j, i, j - 1); j--; } } } while (!(i == h - 1 && (i % 2 == 0 && j == w - 1 || i % 2 == 1 && j == 0))); cout << cnt << endl; for (auto v : ans) { REP(i, 4) { cout << v[i] + 1 << (i == 3 ? "\n" : " "); } } }
insert
47
47
47
52
0
p03263
C++
Runtime Error
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; using ll = long long; int H, W; bool used[500][500]; int coin[500][500]; int mov[250000][4]; int vecidx = 0; pair<int, int> vec[4] = {make_pair(0, 1), make_pair(1, 0), make_pair(0, -1), make_pair(-1, 0)}; void solve(); void init() { rep(i, 500) rep(j, 500) used[i][j] = true; } bool direction(int x, int y) { int kari_x = x + vec[vecidx].first; int kari_y = y + vec[vecidx].second; return !(!used[kari_x][kari_y] && 0 <= kari_x && kari_x < H && 0 <= kari_y && kari_y < W); } int main(void) { cin >> H >> W; init(); rep(i, H) rep(j, W) used[i][j] = false; rep(i, H) rep(j, W) cin >> coin[i][j]; int x = 0, y = 0; int cnt = 0; while (!used[x][y]) { used[x][y] = true; if (direction(x, y)) { if (vecidx == 3) vecidx = 0; else vecidx++; } if (direction(x, y)) break; int next_x = x + vec[vecidx].first; int next_y = y + vec[vecidx].second; if (coin[x][y] % 2 == 1) { coin[x][y]--; coin[next_x][next_y]++; mov[cnt][0] = x + 1; mov[cnt][1] = y + 1; mov[cnt][2] = next_x + 1; mov[cnt][3] = next_y + 1; cnt++; } x = next_x; y = next_y; } cout << cnt << endl; rep(i, cnt) { rep(j, 4) { if (j == 3) cout << mov[i][j] << endl; else cout << mov[i][j] << " "; } } return 0; } void solve() {}
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; using ll = long long; int H, W; bool used[500][500]; int coin[500][500]; int mov[250000][4]; int vecidx = 0; pair<int, int> vec[4] = {make_pair(0, 1), make_pair(1, 0), make_pair(0, -1), make_pair(-1, 0)}; void solve(); void init() { rep(i, 500) rep(j, 500) used[i][j] = true; } bool direction(int x, int y) { int kari_x = x + vec[vecidx].first; int kari_y = y + vec[vecidx].second; return !(0 <= kari_x && kari_x < H && 0 <= kari_y && kari_y < W && !used[kari_x][kari_y]); } int main(void) { cin >> H >> W; init(); rep(i, H) rep(j, W) used[i][j] = false; rep(i, H) rep(j, W) cin >> coin[i][j]; int x = 0, y = 0; int cnt = 0; while (!used[x][y]) { used[x][y] = true; if (direction(x, y)) { if (vecidx == 3) vecidx = 0; else vecidx++; } if (direction(x, y)) break; int next_x = x + vec[vecidx].first; int next_y = y + vec[vecidx].second; if (coin[x][y] % 2 == 1) { coin[x][y]--; coin[next_x][next_y]++; mov[cnt][0] = x + 1; mov[cnt][1] = y + 1; mov[cnt][2] = next_x + 1; mov[cnt][3] = next_y + 1; cnt++; } x = next_x; y = next_y; } cout << cnt << endl; rep(i, cnt) { rep(j, 4) { if (j == 3) cout << mov[i][j] << endl; else cout << mov[i][j] << " "; } } return 0; } void solve() {}
replace
22
24
22
24
0
p03263
C++
Runtime Error
#include <algorithm> #include <algorithm> //sort,二分探索,など #include <bitset> //固定長bit集合 #include <cmath> //pow,logなど #include <complex> //複素数 #include <deque> //両端アクセスのキュー #include <functional> //sortのgreater #include <iomanip> //setprecision(浮動小数点の出力の誤差) #include <iostream> //入出力 #include <iterator> //集合演算(積集合,和集合,差集合など) #include <map> //map(辞書) #include <numeric> //iota(整数列の生成),gcdとlcm(c++17) #include <queue> //キュー #include <set> //集合 #include <stack> //スタック #include <string> //文字列 #include <unordered_map> //イテレータあるけど順序保持しないmap #include <unordered_set> //イテレータあるけど順序保持しないset #include <utility> //pair #include <vector> //可変長配列 using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<ld> vld; typedef vector<string> vs; typedef vector<bool> vb; typedef vector<vector<int>> vvi; typedef vector<vector<ll>> vvll; typedef vector<vector<ld>> vvld; typedef vector<vector<string>> vvs; typedef vector<vector<bool>> vvb; const ll MOD = 1000000007; const ll INF = 1000000000000000000; #define rep(i, n) for (int i = 0; i < n; i++) #define repl(i, s, e) for (int i = s; i < e; i++) #define reple(i, s, e) for (int i = s; i <= e; i++) #define revrep(i, n) for (int i = n - 1; i >= 0; i--) #define all(x) (x).begin(), (x).end() template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } typedef pair<pair<int, int>, pair<int, int>> P; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int H, W; cin >> H >> W; vvi a(H, vi(W, 0)); rep(i, H) { rep(j, W) cin >> a[i][j]; } vector<P> v; int dh[2] = {0, 1}; int dw[2] = {1, 0}; rep(h, H) { rep(w, W) { if (a[h][w] % 2 == 0) continue; rep(i, 2) { int next_h = h + dh[i]; int next_w = w + dw[i]; if (h >= 0 && h < H && w >= 0 && w < W) { --a[h][w]; ++a[next_h][next_w]; v.push_back(make_pair(make_pair(h + 1, w + 1), make_pair(next_h + 1, next_w + 1))); break; } } } } cout << v.size() << endl; for (auto x : v) { cout << x.first.first << " " << x.first.second << " " << x.second.first << " " << x.second.second << endl; } return 0; }
#include <algorithm> #include <algorithm> //sort,二分探索,など #include <bitset> //固定長bit集合 #include <cmath> //pow,logなど #include <complex> //複素数 #include <deque> //両端アクセスのキュー #include <functional> //sortのgreater #include <iomanip> //setprecision(浮動小数点の出力の誤差) #include <iostream> //入出力 #include <iterator> //集合演算(積集合,和集合,差集合など) #include <map> //map(辞書) #include <numeric> //iota(整数列の生成),gcdとlcm(c++17) #include <queue> //キュー #include <set> //集合 #include <stack> //スタック #include <string> //文字列 #include <unordered_map> //イテレータあるけど順序保持しないmap #include <unordered_set> //イテレータあるけど順序保持しないset #include <utility> //pair #include <vector> //可変長配列 using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<ld> vld; typedef vector<string> vs; typedef vector<bool> vb; typedef vector<vector<int>> vvi; typedef vector<vector<ll>> vvll; typedef vector<vector<ld>> vvld; typedef vector<vector<string>> vvs; typedef vector<vector<bool>> vvb; const ll MOD = 1000000007; const ll INF = 1000000000000000000; #define rep(i, n) for (int i = 0; i < n; i++) #define repl(i, s, e) for (int i = s; i < e; i++) #define reple(i, s, e) for (int i = s; i <= e; i++) #define revrep(i, n) for (int i = n - 1; i >= 0; i--) #define all(x) (x).begin(), (x).end() template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } typedef pair<pair<int, int>, pair<int, int>> P; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int H, W; cin >> H >> W; vvi a(H, vi(W, 0)); rep(i, H) { rep(j, W) cin >> a[i][j]; } vector<P> v; int dh[2] = {0, 1}; int dw[2] = {1, 0}; rep(h, H) { rep(w, W) { if (a[h][w] % 2 == 0) continue; rep(i, 2) { int next_h = h + dh[i]; int next_w = w + dw[i]; if (next_h >= 0 && next_h < H && next_w >= 0 && next_w < W) { a[h][w]--; a[next_h][next_w]++; v.push_back(make_pair(make_pair(h + 1, w + 1), make_pair(next_h + 1, next_w + 1))); break; } } } } cout << v.size() << endl; for (auto x : v) { cout << x.first.first << " " << x.first.second << " " << x.second.first << " " << x.second.second << endl; } return 0; }
replace
84
87
84
87
0
p03263
C++
Runtime Error
#include <bits/stdc++.h> #define _overload3(_1, _2, _3, name, ...) name #define _rep(i, n) repi(i, 0, n) #define repi(i, a, b) for (int i = int(a); i < int(b); ++i) #define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__) #define all(x) (x).begin(), (x).end() #define PRINT(V) cout << V << "\n" #define SORT(V) sort((V).begin(), (V).end()) #define RSORT(V) sort((V).rbegin(), (V).rend()) using namespace std; using ll = long long; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } template <typename T> vector<T> table(int n, T v) { return vector<T>(n, v); } template <class... Args> auto table(int n, Args... args) { auto val = table(args...); return vector<decltype(val)>(n, move(val)); } const ll INF = 1e15; const ll MOD = 1000000007; typedef pair<ll, ll> P; int main() { cin.tie(0); ios::sync_with_stdio(false); int h, w; cin >> h >> w; int grid[h + 1][w + 1]; rep(i, h) { rep(j, w) { cin >> grid[i][j]; } } int ans[505][4]; int y = 0, x = 0, a, b, n = 0; bool re = 0, flag = 0; while (y <= h - 1 && x <= w - 1) { if (flag) { grid[y][x]++; ans[n][0] = a; ans[n][1] = b; ans[n][2] = y + 1; ans[n][3] = x + 1; n++; flag = 0; } if (grid[y][x] % 2) { grid[y][x]--; a = y + 1; b = x + 1; flag = 1; } if (y % 2 == 0 && x == w - 1) { y++; re = 1; } else if (y % 2 == 1 && x == 0) { y++; re = 0; } else if (re) x--; else x++; } PRINT(n); rep(i, n) { cout << ans[i][0] << " " << ans[i][1] << " " << ans[i][2] << " " << ans[i][3] << '\n'; } }
#include <bits/stdc++.h> #define _overload3(_1, _2, _3, name, ...) name #define _rep(i, n) repi(i, 0, n) #define repi(i, a, b) for (int i = int(a); i < int(b); ++i) #define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__) #define all(x) (x).begin(), (x).end() #define PRINT(V) cout << V << "\n" #define SORT(V) sort((V).begin(), (V).end()) #define RSORT(V) sort((V).rbegin(), (V).rend()) using namespace std; using ll = long long; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } template <typename T> vector<T> table(int n, T v) { return vector<T>(n, v); } template <class... Args> auto table(int n, Args... args) { auto val = table(args...); return vector<decltype(val)>(n, move(val)); } const ll INF = 1e15; const ll MOD = 1000000007; typedef pair<ll, ll> P; int main() { cin.tie(0); ios::sync_with_stdio(false); int h, w; cin >> h >> w; int grid[h + 1][w + 1]; rep(i, h) { rep(j, w) { cin >> grid[i][j]; } } int ans[250005][4]; int y = 0, x = 0, a, b, n = 0; bool re = 0, flag = 0; while (y <= h - 1 && x <= w - 1) { if (flag) { grid[y][x]++; ans[n][0] = a; ans[n][1] = b; ans[n][2] = y + 1; ans[n][3] = x + 1; n++; flag = 0; } if (grid[y][x] % 2) { grid[y][x]--; a = y + 1; b = x + 1; flag = 1; } if (y % 2 == 0 && x == w - 1) { y++; re = 1; } else if (y % 2 == 1 && x == 0) { y++; re = 0; } else if (re) x--; else x++; } PRINT(n); rep(i, n) { cout << ans[i][0] << " " << ans[i][1] << " " << ans[i][2] << " " << ans[i][3] << '\n'; } }
replace
44
45
44
45
0
p03263
C++
Runtime Error
#include <bits/stdc++.h> #define rep(n) for (int i = 0; i < n; i++) #define repp(j, n) for (int j = 0; j < n; j++) #define reppp(i, m, n) for (int i = m; i < n; i++) #define all(c) c.begin(), c.end() #define rall(c) c.rbegin(), c.rend() #define debug(x) cerr << #x << ": " << x << endl using namespace std; typedef long long ll; typedef pair<ll, ll> Pll; typedef pair<int, int> Pii; const ll MOD = 1000000007; const long double EPS = 10e-10; int main() { std::ios::sync_with_stdio(0); cin.tie(0); int h, w; cin >> h >> w; int a[h][w]; rep(h) repp(j, w) { cin >> a[i][j]; } int n = 0; int ans[500][4]; rep(h) { repp(j, w) { if (i == h - 1 && j == w - 1) break; if (a[i][j] % 2 == 0) continue; a[i][j]--; ans[n][0] = i + 1; ans[n][1] = j + 1; if (j == w - 1) { a[i + 1][j]++; ans[n][2] = i + 2; ans[n][3] = j + 1; } else { a[i][j + 1]++; ans[n][2] = i + 1; ans[n][3] = j + 2; } n++; } } cout << n << endl; rep(n) { cout << ans[i][0] << " " << ans[i][1] << " " << ans[i][2] << " " << ans[i][3] << endl; } return 0; }
#include <bits/stdc++.h> #define rep(n) for (int i = 0; i < n; i++) #define repp(j, n) for (int j = 0; j < n; j++) #define reppp(i, m, n) for (int i = m; i < n; i++) #define all(c) c.begin(), c.end() #define rall(c) c.rbegin(), c.rend() #define debug(x) cerr << #x << ": " << x << endl using namespace std; typedef long long ll; typedef pair<ll, ll> Pll; typedef pair<int, int> Pii; const ll MOD = 1000000007; const long double EPS = 10e-10; int main() { std::ios::sync_with_stdio(0); cin.tie(0); int h, w; cin >> h >> w; int a[h][w]; rep(h) repp(j, w) { cin >> a[i][j]; } int n = 0; int ans[500 * 500 + 10][4]; rep(h) { repp(j, w) { if (i == h - 1 && j == w - 1) break; if (a[i][j] % 2 == 0) continue; a[i][j]--; ans[n][0] = i + 1; ans[n][1] = j + 1; if (j == w - 1) { a[i + 1][j]++; ans[n][2] = i + 2; ans[n][3] = j + 1; } else { a[i][j + 1]++; ans[n][2] = i + 1; ans[n][3] = j + 2; } n++; } } cout << n << endl; rep(n) { cout << ans[i][0] << " " << ans[i][1] << " " << ans[i][2] << " " << ans[i][3] << endl; } return 0; }
replace
27
28
27
28
0
p03263
C++
Runtime Error
#include <iostream> #include <vector> using namespace std; int main() { int h, w; cin >> h >> w; vector<vector<int>> a(h + 1, vector<int>(w + 1, 0)); for (int i = 1; i <= h; i++) { for (int j = 1; j <= w; j++) { cin >> a[i][j]; } } int count = 0; int y_prev[25000] = {}, x_prev[25000] = {}, y_next[25000] = {}, x_next[25000] = {}; for (int i = 1; i <= h; i++) { for (int j = 1; j < w; j++) { if (a[i][j] % 2 == 1) { a[i][j]--; y_prev[count] = i; x_prev[count] = j; a[i][j + 1]++; y_next[count] = i; x_next[count] = j + 1; count++; } } if (a[i][w] % 2 == 1 && i < h) { a[i][w]--; y_prev[count] = i; x_prev[count] = w; a[i + 1][w]++; y_next[count] = i + 1; x_next[count] = w; count++; } } cout << count << endl; for (int i = 0; i < count; i++) { cout << y_prev[i] << " " << x_prev[i] << " " << y_next[i] << " " << x_next[i] << endl; } }
#include <iostream> #include <vector> using namespace std; int main() { int h, w; cin >> h >> w; vector<vector<int>> a(h + 1, vector<int>(w + 1, 0)); for (int i = 1; i <= h; i++) { for (int j = 1; j <= w; j++) { cin >> a[i][j]; } } int count = 0; int y_prev[250000] = {}, x_prev[250000] = {}, y_next[250000] = {}, x_next[250000] = {}; for (int i = 1; i <= h; i++) { for (int j = 1; j < w; j++) { if (a[i][j] % 2 == 1) { a[i][j]--; y_prev[count] = i; x_prev[count] = j; a[i][j + 1]++; y_next[count] = i; x_next[count] = j + 1; count++; } } if (a[i][w] % 2 == 1 && i < h) { a[i][w]--; y_prev[count] = i; x_prev[count] = w; a[i + 1][w]++; y_next[count] = i + 1; x_next[count] = w; count++; } } cout << count << endl; for (int i = 0; i < count; i++) { cout << y_prev[i] << " " << x_prev[i] << " " << y_next[i] << " " << x_next[i] << endl; } }
replace
15
17
15
17
0
p03263
C++
Runtime Error
#include <bits/stdc++.h> #define FOR(i, s, e) for (int i = (s); i < (e); i++) #define REP(i, n) FOR(i, 0, n) #define all(v) (v).begin(), (v).end() #define mp(a, b) make_pair(a, b) #define pb(a) push_back(a) using namespace std; typedef long long LL; typedef pair<int, int> P; int a[510][510]; int step[30000][4]; int main() { cin.tie(0); ios::sync_with_stdio(false); int H, W; cin >> H >> W; REP(i, H) REP(j, W) cin >> a[i][j]; int ans = 0; REP(i, H) REP(j, W - 1) { if (a[i][j] % 2) { step[ans][0] = i; step[ans][2] = i; step[ans][1] = j; step[ans][3] = j + 1; ++ans; a[i][j]--; a[i][j + 1]++; } } REP(i, H - 1) { int j = W - 1; if (a[i][j] % 2) { step[ans][0] = i; step[ans][2] = i + 1; step[ans][1] = j; step[ans][3] = j; ++ans; a[i][j]--; a[i + 1][j]++; } } cout << ans << endl; REP(i, ans) REP(j, 4) cout << step[i][j] + 1 << (j == 3 ? "\n" : " "); return 0; }
#include <bits/stdc++.h> #define FOR(i, s, e) for (int i = (s); i < (e); i++) #define REP(i, n) FOR(i, 0, n) #define all(v) (v).begin(), (v).end() #define mp(a, b) make_pair(a, b) #define pb(a) push_back(a) using namespace std; typedef long long LL; typedef pair<int, int> P; int a[510][510]; int step[250000][4]; int main() { cin.tie(0); ios::sync_with_stdio(false); int H, W; cin >> H >> W; REP(i, H) REP(j, W) cin >> a[i][j]; int ans = 0; REP(i, H) REP(j, W - 1) { if (a[i][j] % 2) { step[ans][0] = i; step[ans][2] = i; step[ans][1] = j; step[ans][3] = j + 1; ++ans; a[i][j]--; a[i][j + 1]++; } } REP(i, H - 1) { int j = W - 1; if (a[i][j] % 2) { step[ans][0] = i; step[ans][2] = i + 1; step[ans][1] = j; step[ans][3] = j; ++ans; a[i][j]--; a[i + 1][j]++; } } cout << ans << endl; REP(i, ans) REP(j, 4) cout << step[i][j] + 1 << (j == 3 ? "\n" : " "); return 0; }
replace
11
12
11
12
0
p03263
Python
Runtime Error
def solve(string): ins = string.split("\n") h, w = map(int, ins[0].split(" ")) cells = [list(map(lambda x: int(x) % 2 == 1, _i.split(" "))) for _i in ins[1:]] command = [] for i in range(h): for j in range(w): if cells[i][j]: if j < w - 1: cells[i][j + 1] ^= True command.append("{} {} {} {}".format(i + 1, j + 1, i + 1, j + 2)) elif i < h - 1: cells[i + 1][j] ^= True command.append("{} {} {} {}".format(i + 1, j + 1, i + 2, j + 1)) command.insert(0, str(len(command))) return "\n".join(command) """ ins = string.split("\n") h, w = map(int, ins[0].split(" ")) a = [list(map(lambda x: int(x) % 2 == 1, _i.split(" "))) for _i in ins[1:]] move = [] v_flag = False h_flag = False for i, _a in enumerate(a): for j, __a in enumerate(_a): curr = __a if h_flag: curr = not curr h_flag = False if j == w - 1 and v_flag: curr = not curr v_flag = False if not curr: continue if j < w - 1: h_flag = True move.append("{} {} {} {}".format(i + 1, j + 1, i + 1, j + 2)) elif i < h - 1: v_flag = True move.append("{} {} {} {}".format(i + 1, j + 1, i + 2, j + 1)) move.insert(0, str(len(move))) return "\n".join(move) """ if __name__ == "__main__": line = input() tmp = [line] for _ in range(int(line[0])): tmp.append(input()) print(solve("\n".join(tmp)))
h, w = map(int, input().split(" ")) a = [list(map(lambda x: int(x) % 2 == 1, input().split(" "))) for _i in range(h)] move = [] for i in range(h): for j in range(w): if not a[i][j]: continue if j < w - 1: a[i][j + 1] ^= True move.append("{} {} {} {}".format(i + 1, j + 1, i + 1, j + 2)) elif i < h - 1: a[i + 1][j] ^= True move.append("{} {} {} {}".format(i + 1, j + 1, i + 2, j + 1)) move.insert(0, str(len(move))) print("\n".join(move))
replace
0
52
0
15
0
p03263
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define int long long #define rep(i, s, e) for (int(i) = (s); (i) <= (e); (i)++) #define rrep(i, s, e) for (int(i) = (s); (i) >= (e); (i)--) int a[505][505]; vector<int> px; vector<int> py; vector<int> mx; vector<int> my; signed main() { int h, w; cin >> h >> w; if (h == 1 && w == 1) { cout << 0 << endl; return 0; } rep(i, 0, h - 1) rep(j, 0, w - 1) cin >> a[i][j]; rep(i, 0, h - 1) rep(j, 0, w - 1) { if (i == h - 1 && j == w - 1) break; if (a[i][j] % 2) { px.push_back(i); py.push_back(j); if (j != w - 1) { mx.push_back(i); my.push_back(j + 1); a[i][j + 1]++; } else { mx.push_back(i + 1); my.push_back(j); a[i + 1][j]++; } } } if (mx.empty()) { cout << 0 << endl; return 9; } cout << mx.size() << endl; rep(i, 0, mx.size() - 1) cout << px[i] + 1 << " " << py[i] + 1 << " " << mx[i] + 1 << " " << my[i] + 1 << endl; }
#include <bits/stdc++.h> using namespace std; #define int long long #define rep(i, s, e) for (int(i) = (s); (i) <= (e); (i)++) #define rrep(i, s, e) for (int(i) = (s); (i) >= (e); (i)--) int a[505][505]; vector<int> px; vector<int> py; vector<int> mx; vector<int> my; signed main() { int h, w; cin >> h >> w; if (h == 1 && w == 1) { cout << 0 << endl; return 0; } rep(i, 0, h - 1) rep(j, 0, w - 1) cin >> a[i][j]; rep(i, 0, h - 1) rep(j, 0, w - 1) { if (i == h - 1 && j == w - 1) break; if (a[i][j] % 2) { px.push_back(i); py.push_back(j); if (j != w - 1) { mx.push_back(i); my.push_back(j + 1); a[i][j + 1]++; } else { mx.push_back(i + 1); my.push_back(j); a[i + 1][j]++; } } } if (mx.empty()) { cout << 0 << endl; return 0; } cout << mx.size() << endl; rep(i, 0, mx.size() - 1) cout << px[i] + 1 << " " << py[i] + 1 << " " << mx[i] + 1 << " " << my[i] + 1 << endl; }
replace
43
44
43
44
0
p03263
C++
Runtime Error
#include <iostream> using namespace std; typedef long long ll; #define rep(i, s, n) for (ll i = s; i < n; i++) #define repe(i, s, n) for (ll i = s; i <= n; i++) static const double PI = 3.1415926535897932384626433; static const ll LL_MAX = (ll)1 << 62; static const ll MOD = 1000000007; ll y_1[100000]; ll x1[100000]; ll y2[100000]; ll x2[100000]; ll a[501][501] = {}; int main() { ll h, w; cin >> h >> w; repe(i, 1, h) repe(j, 1, w) cin >> a[i][j]; ll cnt = 0; repe(i, 1, h) rep(j, 1, w) { if (a[i][j] & 1) { a[i][j]--; a[i][j + 1]++; y_1[cnt] = i; x1[cnt] = j; y2[cnt] = i; x2[cnt] = j + 1; cnt++; } } rep(i, 1, h) { if (a[i][w] & 1) { a[i][w]--; a[i + 1][w]++; y_1[cnt] = i; x1[cnt] = w; y2[cnt] = i + 1; x2[cnt] = w; cnt++; } } cout << cnt << endl; rep(i, 0, cnt) { cout << y_1[i] << " " << x1[i] << " " << y2[i] << " " << x2[i] << endl; } return 0; }
#include <iostream> using namespace std; typedef long long ll; #define rep(i, s, n) for (ll i = s; i < n; i++) #define repe(i, s, n) for (ll i = s; i <= n; i++) static const double PI = 3.1415926535897932384626433; static const ll LL_MAX = (ll)1 << 62; static const ll MOD = 1000000007; ll y_1[300000]; ll x1[300000]; ll y2[300000]; ll x2[300000]; ll a[501][501] = {}; int main() { ll h, w; cin >> h >> w; repe(i, 1, h) repe(j, 1, w) cin >> a[i][j]; ll cnt = 0; repe(i, 1, h) rep(j, 1, w) { if (a[i][j] & 1) { a[i][j]--; a[i][j + 1]++; y_1[cnt] = i; x1[cnt] = j; y2[cnt] = i; x2[cnt] = j + 1; cnt++; } } rep(i, 1, h) { if (a[i][w] & 1) { a[i][w]--; a[i + 1][w]++; y_1[cnt] = i; x1[cnt] = w; y2[cnt] = i + 1; x2[cnt] = w; cnt++; } } cout << cnt << endl; rep(i, 0, cnt) { cout << y_1[i] << " " << x1[i] << " " << y2[i] << " " << x2[i] << endl; } return 0; }
replace
9
13
9
13
0
p03263
C++
Runtime Error
#include <algorithm> #include <iostream> #include <vector> using namespace std; int map[501][501]; int ans[501][4]; typedef pair<int, int> P; int N, H, W; vector<P> odd_point; int main() { cin >> H >> W; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { cin >> map[i][j]; } } vector<P> route; for (int i = 0; i < H; i++) { if (i % 2 == 0) for (int j = 0; j < W; j++) route.push_back(make_pair(i, j)); else for (int j = W - 1; j >= 0; j--) route.push_back(make_pair(i, j)); } bool odd = false; int N = 0; for (int i = 0; i < route.size() - 1; i++) { if (odd == false) { if (map[route[i].first][route[i].second] % 2 == 1) { odd = true; ans[N][0] = route[i].first; ans[N][1] = route[i].second; ans[N][2] = route[i + 1].first; ans[N][3] = route[i + 1].second; N++; } } else { if (map[route[i].first][route[i].second] % 2 == 1) { odd = false; continue; } ans[N][0] = route[i].first; ans[N][1] = route[i].second; ans[N][2] = route[i + 1].first; ans[N][3] = route[i + 1].second; N++; } } cout << N << '\n'; for (int i = 0; i < N; i++) { cout << ans[i][0] + 1 << ' ' << ans[i][1] + 1 << ' ' << ans[i][2] + 1 << ' ' << ans[i][3] + 1 << '\n'; } }
#include <algorithm> #include <iostream> #include <vector> using namespace std; int map[501][501]; int ans[250001][4]; typedef pair<int, int> P; int N, H, W; vector<P> odd_point; int main() { cin >> H >> W; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { cin >> map[i][j]; } } vector<P> route; for (int i = 0; i < H; i++) { if (i % 2 == 0) for (int j = 0; j < W; j++) route.push_back(make_pair(i, j)); else for (int j = W - 1; j >= 0; j--) route.push_back(make_pair(i, j)); } bool odd = false; int N = 0; for (int i = 0; i < route.size() - 1; i++) { if (odd == false) { if (map[route[i].first][route[i].second] % 2 == 1) { odd = true; ans[N][0] = route[i].first; ans[N][1] = route[i].second; ans[N][2] = route[i + 1].first; ans[N][3] = route[i + 1].second; N++; } } else { if (map[route[i].first][route[i].second] % 2 == 1) { odd = false; continue; } ans[N][0] = route[i].first; ans[N][1] = route[i].second; ans[N][2] = route[i + 1].first; ans[N][3] = route[i + 1].second; N++; } } cout << N << '\n'; for (int i = 0; i < N; i++) { cout << ans[i][0] + 1 << ' ' << ans[i][1] + 1 << ' ' << ans[i][2] + 1 << ' ' << ans[i][3] + 1 << '\n'; } }
replace
6
7
6
7
0
p03263
C++
Runtime Error
#include <bits/stdc++.h> // created [2020/02/02] 21:33:37 #pragma GCC diagnostic ignored "-Wsign-compare" #pragma GCC diagnostic ignored "-Wsign-conversion" using i32 = int32_t; using i64 = int64_t; using u32 = uint32_t; using u64 = uint64_t; using uint = unsigned int; using usize = std::size_t; using ll = long long; using ull = unsigned long long; using ld = long double; template <typename T, usize n> using arr = T (&)[n]; template <typename T, usize n> using c_arr = const T (&)[n]; template <typename T> using max_heap = std::priority_queue<T>; template <typename T> using min_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>; template <typename T> constexpr T popcount(const T u) { return u ? static_cast<T>(__builtin_popcountll(static_cast<u64>(u))) : static_cast<T>(0); } template <typename T> constexpr T log2p1(const T u) { return u ? static_cast<T>(64 - __builtin_clzll(static_cast<u64>(u))) : static_cast<T>(0); } template <typename T> constexpr T msbp1(const T u) { return log2p1(u); } template <typename T> constexpr T lsbp1(const T u) { return __builtin_ffsll(u); } template <typename T> constexpr T clog(const T u) { return u ? log2p1(u - 1) : static_cast<T>(u); } template <typename T> constexpr bool ispow2(const T u) { return u and (static_cast<u64>(u) & static_cast<u64>(u - 1)) == 0; } template <typename T> constexpr T ceil2(const T u) { return static_cast<T>(1) << clog(u); } template <typename T> constexpr T floor2(const T u) { return u == 0 ? static_cast<T>(0) : static_cast<T>(1) << (log2p1(u) - 1); } template <typename T> constexpr bool btest(const T mask, const usize ind) { return static_cast<bool>((static_cast<u64>(mask) >> ind) & static_cast<u64>(1)); } template <typename T> void bset(T &mask, const usize ind) { mask |= (static_cast<T>(1) << ind); } template <typename T> void breset(T &mask, const usize ind) { mask &= ~(static_cast<T>(1) << ind); } template <typename T> void bflip(T &mask, const usize ind) { mask ^= (static_cast<T>(1) << ind); } template <typename T> void bset(T &mask, const usize ind, const bool b) { (b ? bset(mask, ind) : breset(mask, ind)); } template <typename T> constexpr T bcut(const T mask, const usize ind) { return ind == 0 ? static_cast<T>(0) : static_cast<T>((static_cast<u64>(mask) << (64 - ind)) >> (64 - ind)); } template <typename T> bool chmin(T &a, const T &b) { return (a > b ? a = b, true : false); } template <typename T> bool chmax(T &a, const T &b) { return (a < b ? a = b, true : false); } constexpr unsigned int mod = 1000000007; template <typename T> constexpr T inf_v = std::numeric_limits<T>::max() / 4; template <typename Real> constexpr Real pi_v = Real{3.141592653589793238462643383279502884}; auto mfp = [](auto &&f) { return [=](auto &&...args) { return f(f, std::forward<decltype(args)>(args)...); }; }; template <typename T> T in() { T v; return std::cin >> v, v; } template <typename T, typename Uint, usize n, usize i> T in_v(typename std::enable_if<(i == n), c_arr<Uint, n>>::type) { return in<T>(); } template <typename T, typename Uint, usize n, usize i> auto in_v(typename std::enable_if<(i < n), c_arr<Uint, n>>::type &szs) { const usize s = (usize)szs[i]; std::vector<decltype(in_v<T, Uint, n, i + 1>(szs))> ans(s); for (usize j = 0; j < s; j++) { ans[j] = in_v<T, Uint, n, i + 1>(szs); } return ans; } template <typename T, typename Uint, usize n> auto in_v(c_arr<Uint, n> szs) { return in_v<T, Uint, n, 0>(szs); } template <typename... Types> auto in_t() { return std::tuple<std::decay_t<Types>...>{in<Types>()...}; } struct io_init { io_init() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(20); } void clear() { std::cin.tie(), std::ios::sync_with_stdio(true); } } io_setting; int out() { return 0; } template <typename T> int out(const T &v) { return std::cout << v, 0; } template <typename T> int out(const std::vector<T> &v) { for (usize i = 0; i < v.size(); i++) { if (i > 0) { std::cout << ' '; } out(v[i]); } return 0; } template <typename T1, typename T2> int out(const std::pair<T1, T2> &v) { return out(v.first), std::cout << ' ', out(v.second), 0; } template <typename T, typename... Args> int out(const T &v, const Args... args) { return out(v), std::cout << ' ', out(args...), 0; } template <typename... Args> int outln(const Args... args) { return out(args...), std::cout << '\n', 0; } template <typename... Args> int outel(const Args... args) { return out(args...), std::cout << std::endl, 0; } #define SHOW(...) static_cast<void>(0) constexpr ull TEN(const usize n) { return n == 0 ? 1ULL : TEN(n - 1) * 10ULL; } template <typename T, typename Uint, usize n, usize i> auto make_v(typename std::enable_if<(i == n), c_arr<Uint, n>>::type, const T &v = T{}) { return v; } template <typename T, typename Uint, usize n, usize i> auto make_v(typename std::enable_if<(i < n), c_arr<Uint, n>>::type szs, const T &v = T{}) { const usize s = (usize)szs[i]; return std::vector<decltype(make_v<T, Uint, n, i + 1>(szs, v))>( s, make_v<T, Uint, n, i + 1>(szs, v)); } template <typename T, typename Uint, usize n> auto make_v(c_arr<Uint, n> szs, const T &t = T{}) { return make_v<T, Uint, n, 0>(szs, t); } int main() { const auto H = in<int>(), W = in<int>(); auto ass = in_v<int>({H, W}); using pii = std::pair<int, int>; auto next = make_v<pii>({H, W}); for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { if (i % 2 == 0) { next[i][j] = (j == W - 1 ? pii{i + 1, j} : pii{i, j + 1}); } else { next[i][j] = (j == 0 ? pii{i + 1, j} : pii{i, j - 1}); } } } int y = 0, x = 0; std::vector<int> ys, xs, nys, nxs; while (y < H) { const auto nxt = next[y][x]; const int ny = nxt.first, nx = nxt.second; if (ass[y][x] % 2 == 1) { ys.push_back(y + 1), xs.push_back(x + 1); nys.push_back(ny + 1), nxs.push_back(nx + 1); ass[y][x]--, ass[ny][nx]++; } y = ny, x = nx; } outln(ys.size()); for (int i = 0; i < ys.size(); i++) { outln(ys[i], xs[i], nys[i], nxs[i]); } return 0; }
#include <bits/stdc++.h> // created [2020/02/02] 21:33:37 #pragma GCC diagnostic ignored "-Wsign-compare" #pragma GCC diagnostic ignored "-Wsign-conversion" using i32 = int32_t; using i64 = int64_t; using u32 = uint32_t; using u64 = uint64_t; using uint = unsigned int; using usize = std::size_t; using ll = long long; using ull = unsigned long long; using ld = long double; template <typename T, usize n> using arr = T (&)[n]; template <typename T, usize n> using c_arr = const T (&)[n]; template <typename T> using max_heap = std::priority_queue<T>; template <typename T> using min_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>; template <typename T> constexpr T popcount(const T u) { return u ? static_cast<T>(__builtin_popcountll(static_cast<u64>(u))) : static_cast<T>(0); } template <typename T> constexpr T log2p1(const T u) { return u ? static_cast<T>(64 - __builtin_clzll(static_cast<u64>(u))) : static_cast<T>(0); } template <typename T> constexpr T msbp1(const T u) { return log2p1(u); } template <typename T> constexpr T lsbp1(const T u) { return __builtin_ffsll(u); } template <typename T> constexpr T clog(const T u) { return u ? log2p1(u - 1) : static_cast<T>(u); } template <typename T> constexpr bool ispow2(const T u) { return u and (static_cast<u64>(u) & static_cast<u64>(u - 1)) == 0; } template <typename T> constexpr T ceil2(const T u) { return static_cast<T>(1) << clog(u); } template <typename T> constexpr T floor2(const T u) { return u == 0 ? static_cast<T>(0) : static_cast<T>(1) << (log2p1(u) - 1); } template <typename T> constexpr bool btest(const T mask, const usize ind) { return static_cast<bool>((static_cast<u64>(mask) >> ind) & static_cast<u64>(1)); } template <typename T> void bset(T &mask, const usize ind) { mask |= (static_cast<T>(1) << ind); } template <typename T> void breset(T &mask, const usize ind) { mask &= ~(static_cast<T>(1) << ind); } template <typename T> void bflip(T &mask, const usize ind) { mask ^= (static_cast<T>(1) << ind); } template <typename T> void bset(T &mask, const usize ind, const bool b) { (b ? bset(mask, ind) : breset(mask, ind)); } template <typename T> constexpr T bcut(const T mask, const usize ind) { return ind == 0 ? static_cast<T>(0) : static_cast<T>((static_cast<u64>(mask) << (64 - ind)) >> (64 - ind)); } template <typename T> bool chmin(T &a, const T &b) { return (a > b ? a = b, true : false); } template <typename T> bool chmax(T &a, const T &b) { return (a < b ? a = b, true : false); } constexpr unsigned int mod = 1000000007; template <typename T> constexpr T inf_v = std::numeric_limits<T>::max() / 4; template <typename Real> constexpr Real pi_v = Real{3.141592653589793238462643383279502884}; auto mfp = [](auto &&f) { return [=](auto &&...args) { return f(f, std::forward<decltype(args)>(args)...); }; }; template <typename T> T in() { T v; return std::cin >> v, v; } template <typename T, typename Uint, usize n, usize i> T in_v(typename std::enable_if<(i == n), c_arr<Uint, n>>::type) { return in<T>(); } template <typename T, typename Uint, usize n, usize i> auto in_v(typename std::enable_if<(i < n), c_arr<Uint, n>>::type &szs) { const usize s = (usize)szs[i]; std::vector<decltype(in_v<T, Uint, n, i + 1>(szs))> ans(s); for (usize j = 0; j < s; j++) { ans[j] = in_v<T, Uint, n, i + 1>(szs); } return ans; } template <typename T, typename Uint, usize n> auto in_v(c_arr<Uint, n> szs) { return in_v<T, Uint, n, 0>(szs); } template <typename... Types> auto in_t() { return std::tuple<std::decay_t<Types>...>{in<Types>()...}; } struct io_init { io_init() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(20); } void clear() { std::cin.tie(), std::ios::sync_with_stdio(true); } } io_setting; int out() { return 0; } template <typename T> int out(const T &v) { return std::cout << v, 0; } template <typename T> int out(const std::vector<T> &v) { for (usize i = 0; i < v.size(); i++) { if (i > 0) { std::cout << ' '; } out(v[i]); } return 0; } template <typename T1, typename T2> int out(const std::pair<T1, T2> &v) { return out(v.first), std::cout << ' ', out(v.second), 0; } template <typename T, typename... Args> int out(const T &v, const Args... args) { return out(v), std::cout << ' ', out(args...), 0; } template <typename... Args> int outln(const Args... args) { return out(args...), std::cout << '\n', 0; } template <typename... Args> int outel(const Args... args) { return out(args...), std::cout << std::endl, 0; } #define SHOW(...) static_cast<void>(0) constexpr ull TEN(const usize n) { return n == 0 ? 1ULL : TEN(n - 1) * 10ULL; } template <typename T, typename Uint, usize n, usize i> auto make_v(typename std::enable_if<(i == n), c_arr<Uint, n>>::type, const T &v = T{}) { return v; } template <typename T, typename Uint, usize n, usize i> auto make_v(typename std::enable_if<(i < n), c_arr<Uint, n>>::type szs, const T &v = T{}) { const usize s = (usize)szs[i]; return std::vector<decltype(make_v<T, Uint, n, i + 1>(szs, v))>( s, make_v<T, Uint, n, i + 1>(szs, v)); } template <typename T, typename Uint, usize n> auto make_v(c_arr<Uint, n> szs, const T &t = T{}) { return make_v<T, Uint, n, 0>(szs, t); } int main() { const auto H = in<int>(), W = in<int>(); auto ass = in_v<int>({H, W}); using pii = std::pair<int, int>; auto next = make_v<pii>({H, W}); for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { if (i % 2 == 0) { next[i][j] = (j == W - 1 ? pii{i + 1, j} : pii{i, j + 1}); } else { next[i][j] = (j == 0 ? pii{i + 1, j} : pii{i, j - 1}); } } } int y = 0, x = 0; std::vector<int> ys, xs, nys, nxs; while (y < H) { const auto nxt = next[y][x]; const int ny = nxt.first, nx = nxt.second; if (ny < H and ass[y][x] % 2 == 1) { ys.push_back(y + 1), xs.push_back(x + 1); nys.push_back(ny + 1), nxs.push_back(nx + 1); ass[y][x]--, ass[ny][nx]++; } y = ny, x = nx; } outln(ys.size()); for (int i = 0; i < ys.size(); i++) { outln(ys[i], xs[i], nys[i], nxs[i]); } return 0; }
replace
173
174
173
175
0
p03263
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int H, W; int a[100000][4]; int main() { cin >> H >> W; int map[H][W]; for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) cin >> map[i][j]; int s = 0, u = 0; for (int i = 0; i < H; i++) { if (i % 2 == 0) { for (int j = 0; j < W; j++) { if (((s == 0 && map[i][j] % 2 == 1) || (s == 1 && map[i][j] % 2 == 0)) && (i != H - 1 || j != W - 1)) { a[u][0] = i; a[u][1] = j; if (j < W - 1) { a[u][2] = i; a[u][3] = j + 1; } else { a[u][2] = i + 1; a[u][3] = j; } u++; s = 1; } else if (s == 1 && map[i][j] % 2 == 1 && (i != H - 1 || j != W - 1)) { s = 0; } } } else { for (int j = W - 1; j >= 0; j--) { if (((s == 0 && map[i][j] % 2 == 1) || (s == 1 && map[i][j] % 2 == 0)) && (i != H - 1 || j != 0)) { a[u][0] = i; a[u][1] = j; if (j > 0) { a[u][2] = i; a[u][3] = j - 1; } else { a[u][2] = i + 1; a[u][3] = j; } u++; s = 1; } else if (s == 1 && map[i][j] % 2 == 1 && (i != H - 1 || j != 0)) { s = 0; } } } } cout << u << endl; for (int i = 0; i < u; i++) { for (int j = 0; j <= 3; j++) { if (j == 3) cout << a[i][j] + 1 << endl; else cout << a[i][j] + 1 << " "; } } }
#include <bits/stdc++.h> using namespace std; int H, W; int a[1000000][4]; int main() { cin >> H >> W; int map[H][W]; for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) cin >> map[i][j]; int s = 0, u = 0; for (int i = 0; i < H; i++) { if (i % 2 == 0) { for (int j = 0; j < W; j++) { if (((s == 0 && map[i][j] % 2 == 1) || (s == 1 && map[i][j] % 2 == 0)) && (i != H - 1 || j != W - 1)) { a[u][0] = i; a[u][1] = j; if (j < W - 1) { a[u][2] = i; a[u][3] = j + 1; } else { a[u][2] = i + 1; a[u][3] = j; } u++; s = 1; } else if (s == 1 && map[i][j] % 2 == 1 && (i != H - 1 || j != W - 1)) { s = 0; } } } else { for (int j = W - 1; j >= 0; j--) { if (((s == 0 && map[i][j] % 2 == 1) || (s == 1 && map[i][j] % 2 == 0)) && (i != H - 1 || j != 0)) { a[u][0] = i; a[u][1] = j; if (j > 0) { a[u][2] = i; a[u][3] = j - 1; } else { a[u][2] = i + 1; a[u][3] = j; } u++; s = 1; } else if (s == 1 && map[i][j] % 2 == 1 && (i != H - 1 || j != 0)) { s = 0; } } } } cout << u << endl; for (int i = 0; i < u; i++) { for (int j = 0; j <= 3; j++) { if (j == 3) cout << a[i][j] + 1 << endl; else cout << a[i][j] + 1 << " "; } } }
replace
4
5
4
5
0
p03263
C++
Runtime Error
// Created by conan1024hao in 2019. // Copyright © 2019 conan1024hao. All rights reserved. // 専用ライブラリです、自由にコピーして構いません。 // 感谢看我的代码!Wechat:conan1024hao QQ:810396815 #pragma GCC optimize("O3") #include <algorithm> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <iomanip> #include <iostream> #include <istream> #include <iterator> #include <list> #include <map> #include <ostream> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> #define INF 10e16 #define MOD 1000000007 #define rep(i, a, n) for (ll i = a; i < (ll)(n); i++) #define fi first #define se second #define pb push_back #define mp make_pair #define eb emplace_back #define mmax(x, y) (x > y ? x : y) #define mmin(x, y) (x < y ? x : y) #define chmax(x, y) x = mmax(x, y) #define chmin(x, y) x = mmin(x, y) #define all(x) (x).begin(), (x).end() #define siz(x) (ll)(x).size() #define PI acos(-1.0) using namespace std; typedef long long int ll; typedef pair<ll, ll> P; long long GCD(long long a, long long b) { return b ? GCD(b, a % b) : a; } long long LCM(long long a, long long b) { return a / GCD(a, b) * b; } int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; ll cmp(pair<ll, string> a, pair<ll, string> b) { if (a.fi != b.fi) return a.fi < b.fi; else return a.se < b.se; } //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- int main() { // 問題をちゃんと見ろ!!!!!!!!!!!!!!!!! llか?????????? cin.tie(0); ios::sync_with_stdio(false); //------------------------------- int h, w; int a[600][600]; int color[600][600]; vector<pair<pair<int, int>, pair<int, int>>> ans; int n = 0; int odd = 0; bool err = 0; int nx = 1; int ny = 1; bool abc = 0; cin >> h >> w; for (int i = 1; i <= h; i++) for (int j = 1; j <= w; j++) { cin >> a[i][j]; if (a[i][j] % 2 != 0) odd++; } odd /= 2; int i = 1, j = 1; int ca = 1; while (1) { if ((i == h && j == w && ca == 1) || (i == h && j == 1 && ca == -1)) break; int pi = i, pj = j; if (j == w && ca == 1) { ca = (-1); i++; } else if (j == 1 && i != 1) { ca = 1; i++; } else j += ca; // cout<<i<<" "<<j<<endl; if (a[pi][pj] % 2 != 0) { a[i][j]++; a[pi][pj]--; n++; ans.pb(mp(mp(pi, pj), mp(i, j))); } } cout << n << endl; for (int i = 0; i < siz(ans); i++) cout << ans[i].fi.fi << " " << ans[i].fi.se << " " << ans[i].se.fi << " " << ans[i].se.se << endl; //------------------------------- return 0; } //---------------------------------------------------------------------------
// Created by conan1024hao in 2019. // Copyright © 2019 conan1024hao. All rights reserved. // 専用ライブラリです、自由にコピーして構いません。 // 感谢看我的代码!Wechat:conan1024hao QQ:810396815 #pragma GCC optimize("O3") #include <algorithm> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <iomanip> #include <iostream> #include <istream> #include <iterator> #include <list> #include <map> #include <ostream> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> #define INF 10e16 #define MOD 1000000007 #define rep(i, a, n) for (ll i = a; i < (ll)(n); i++) #define fi first #define se second #define pb push_back #define mp make_pair #define eb emplace_back #define mmax(x, y) (x > y ? x : y) #define mmin(x, y) (x < y ? x : y) #define chmax(x, y) x = mmax(x, y) #define chmin(x, y) x = mmin(x, y) #define all(x) (x).begin(), (x).end() #define siz(x) (ll)(x).size() #define PI acos(-1.0) using namespace std; typedef long long int ll; typedef pair<ll, ll> P; long long GCD(long long a, long long b) { return b ? GCD(b, a % b) : a; } long long LCM(long long a, long long b) { return a / GCD(a, b) * b; } int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; ll cmp(pair<ll, string> a, pair<ll, string> b) { if (a.fi != b.fi) return a.fi < b.fi; else return a.se < b.se; } //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- int main() { // 問題をちゃんと見ろ!!!!!!!!!!!!!!!!! llか?????????? cin.tie(0); ios::sync_with_stdio(false); //------------------------------- int h, w; int a[600][600]; int color[600][600]; vector<pair<pair<int, int>, pair<int, int>>> ans; int n = 0; int odd = 0; bool err = 0; int nx = 1; int ny = 1; bool abc = 0; cin >> h >> w; for (int i = 1; i <= h; i++) for (int j = 1; j <= w; j++) { cin >> a[i][j]; if (a[i][j] % 2 != 0) odd++; } odd /= 2; int i = 1, j = 1; int ca = 1; while (1) { if ((i == h && j == w && ca == 1) || (i == h && j == 1 && ca == -1)) break; int pi = i, pj = j; if (j == w && ca == 1) { ca = (-1); i++; } else if (j == 1 && ca == -1) { ca = 1; i++; } else j += ca; // cout<<i<<" "<<j<<endl; if (a[pi][pj] % 2 != 0) { a[i][j]++; a[pi][pj]--; n++; ans.pb(mp(mp(pi, pj), mp(i, j))); } } cout << n << endl; for (int i = 0; i < siz(ans); i++) cout << ans[i].fi.fi << " " << ans[i].fi.se << " " << ans[i].se.fi << " " << ans[i].se.se << endl; //------------------------------- return 0; } //---------------------------------------------------------------------------
replace
91
92
91
92
0
p03263
C++
Runtime Error
#include <iostream> using namespace std; int AftermoveLogX[2600]; int AftermoveLogY[2600]; int BeforemoveLogX[2600]; int BeforemoveLogY[2600]; int main(void) { int h, w; int n = 0; cin >> h >> w; int a[h][w]; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { cin >> a[i][j]; } } int moveindex; moveindex = 0; for (int i = 0; i < h - 1; i++) { for (int j = 0; j < w; j++) { if (a[i][j] % 2 == 1) { a[i + 1][j] += 1; a[i][j]--; n++; BeforemoveLogX[moveindex] = j + 1; BeforemoveLogY[moveindex] = i + 1; AftermoveLogX[moveindex] = j + 1; AftermoveLogY[moveindex] = i + 2; moveindex++; } } } for (int i = 0; i < w - 1; i++) { if (a[h - 1][i] % 2 == 1) { a[h - 1][i + 1]++; a[h - 1][i]--; BeforemoveLogX[moveindex] = i + 1; BeforemoveLogY[moveindex] = h; AftermoveLogX[moveindex] = i + 2; AftermoveLogY[moveindex] = h; moveindex++; n++; } } cout << n << endl; for (int i = 0; i < moveindex; i++) { cout << BeforemoveLogY[i] << " " << BeforemoveLogX[i] << " "; cout << AftermoveLogY[i] << " " << AftermoveLogX[i] << endl; } return 0; }
#include <iostream> using namespace std; int AftermoveLogX[250000]; int AftermoveLogY[250000]; int BeforemoveLogX[250000]; int BeforemoveLogY[250000]; int main(void) { int h, w; int n = 0; cin >> h >> w; int a[h][w]; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { cin >> a[i][j]; } } int moveindex; moveindex = 0; for (int i = 0; i < h - 1; i++) { for (int j = 0; j < w; j++) { if (a[i][j] % 2 == 1) { a[i + 1][j] += 1; a[i][j]--; n++; BeforemoveLogX[moveindex] = j + 1; BeforemoveLogY[moveindex] = i + 1; AftermoveLogX[moveindex] = j + 1; AftermoveLogY[moveindex] = i + 2; moveindex++; } } } for (int i = 0; i < w - 1; i++) { if (a[h - 1][i] % 2 == 1) { a[h - 1][i + 1]++; a[h - 1][i]--; BeforemoveLogX[moveindex] = i + 1; BeforemoveLogY[moveindex] = h; AftermoveLogX[moveindex] = i + 2; AftermoveLogY[moveindex] = h; moveindex++; n++; } } cout << n << endl; for (int i = 0; i < moveindex; i++) { cout << BeforemoveLogY[i] << " " << BeforemoveLogX[i] << " "; cout << AftermoveLogY[i] << " " << AftermoveLogX[i] << endl; } return 0; }
replace
3
7
3
7
0
p03263
C++
Runtime Error
#include <iostream> using namespace std; static const int MAX = 500; static const int MAX_ANS = 2500; bool a[MAX][MAX]; bool change(bool t) { return t ? false : true; } int main(void) { int h, w; cin >> h >> w; for (int i = 1; i <= h; i++) { for (int j = 1; j <= w; j++) { int f; cin >> f; if (f % 2) a[i][j] = true; } } int x_1[MAX_ANS], x_2[MAX_ANS], y_1[MAX_ANS], y_2[MAX_ANS]; int n = 0; for (int i = 1; i <= h; i++) { for (int j = 1; j < w; j++) { if (a[i][j]) { x_1[n] = i; x_2[n] = i; y_1[n] = j; y_2[n] = j + 1; n++; a[i][j] = false; a[i][j + 1] = change(a[i][j + 1]); } } } for (int i = 0; i < h; i++) { if (a[i][w]) { x_1[n] = i; x_2[n] = i + 1; y_1[n] = w; y_2[n] = w; n++; a[i][w] = true; a[i + 1][w] = change(a[i + 1][w]); } } cout << n << endl; for (int i = 0; i < n; i++) cout << x_1[i] << " " << y_1[i] << " " << x_2[i] << " " << y_2[i] << endl; return 0; }
#include <iostream> using namespace std; static const int MAX = 500; static const int MAX_ANS = 2e5 + 5; bool a[MAX][MAX]; bool change(bool t) { return t ? false : true; } int main(void) { int h, w; cin >> h >> w; for (int i = 1; i <= h; i++) { for (int j = 1; j <= w; j++) { int f; cin >> f; if (f % 2) a[i][j] = true; } } int x_1[MAX_ANS], x_2[MAX_ANS], y_1[MAX_ANS], y_2[MAX_ANS]; int n = 0; for (int i = 1; i <= h; i++) { for (int j = 1; j < w; j++) { if (a[i][j]) { x_1[n] = i; x_2[n] = i; y_1[n] = j; y_2[n] = j + 1; n++; a[i][j] = false; a[i][j + 1] = change(a[i][j + 1]); } } } for (int i = 0; i < h; i++) { if (a[i][w]) { x_1[n] = i; x_2[n] = i + 1; y_1[n] = w; y_2[n] = w; n++; a[i][w] = true; a[i + 1][w] = change(a[i + 1][w]); } } cout << n << endl; for (int i = 0; i < n; i++) cout << x_1[i] << " " << y_1[i] << " " << x_2[i] << " " << y_2[i] << endl; return 0; }
replace
3
4
3
4
0
p03263
C++
Runtime Error
#include <bits/stdc++.h> #define rep(i, m, n) for (int i = (m); i < (n); i++) #define rrep(i, m, n) for (int i = (m); i >= (n); i--) #define print(x) cout << (x) << endl; #define print2(x, y) cout << (x) << " " << (y) << endl; #define printa(x, n) \ for (int i = 0; i < n; i++) { \ cout << (x[i]); \ if (i != n - 1) \ cout << " "; \ } \ cout << endl; #define printp(x, n) \ for (int i = 0; i < n; i++) { \ cout << "(" << x[i].first << ", " << x[i].second << ") "; \ } \ cout << endl; #define INF (1e18) using namespace std; typedef long long ll; const ll MOD = 1e9 + 7; typedef pair<ll, ll> lpair; int main() { cin.tie(0); ios::sync_with_stdio(false); ll H, W; cin >> H >> W; ll a[510][510]; rep(i, 0, H) { rep(j, 0, W) { cin >> a[i][j]; } } ll ans[100010][4] = {}; ll cnt = 0; rep(i, 0, H) { rep(j, 0, W - 1) { if (a[i][j] % 2 == 1) { ans[cnt][0] = i + 1; ans[cnt][1] = j + 1; ans[cnt][2] = i + 1; ans[cnt][3] = j + 2; a[i][j]--; a[i][j + 1]++; cnt++; } } } rep(j, 0, W) { rep(i, 0, H - 1) { if (a[i][j] % 2 == 1) { ans[cnt][0] = i + 1; ans[cnt][1] = j + 1; ans[cnt][2] = i + 2; ans[cnt][3] = j + 1; a[i][j]--; a[i + 1][j]++; cnt++; } } } print(cnt); rep(i, 0, cnt) { rep(j, 0, 4) { cout << ans[i][j]; if (j != 3) cout << " "; } cout << endl; } }
#include <bits/stdc++.h> #define rep(i, m, n) for (int i = (m); i < (n); i++) #define rrep(i, m, n) for (int i = (m); i >= (n); i--) #define print(x) cout << (x) << endl; #define print2(x, y) cout << (x) << " " << (y) << endl; #define printa(x, n) \ for (int i = 0; i < n; i++) { \ cout << (x[i]); \ if (i != n - 1) \ cout << " "; \ } \ cout << endl; #define printp(x, n) \ for (int i = 0; i < n; i++) { \ cout << "(" << x[i].first << ", " << x[i].second << ") "; \ } \ cout << endl; #define INF (1e18) using namespace std; typedef long long ll; const ll MOD = 1e9 + 7; typedef pair<ll, ll> lpair; int main() { cin.tie(0); ios::sync_with_stdio(false); ll H, W; cin >> H >> W; ll a[510][510]; rep(i, 0, H) { rep(j, 0, W) { cin >> a[i][j]; } } ll ans[300010][4] = {}; ll cnt = 0; rep(i, 0, H) { rep(j, 0, W - 1) { if (a[i][j] % 2 == 1) { ans[cnt][0] = i + 1; ans[cnt][1] = j + 1; ans[cnt][2] = i + 1; ans[cnt][3] = j + 2; a[i][j]--; a[i][j + 1]++; cnt++; } } } rep(j, 0, W) { rep(i, 0, H - 1) { if (a[i][j] % 2 == 1) { ans[cnt][0] = i + 1; ans[cnt][1] = j + 1; ans[cnt][2] = i + 2; ans[cnt][3] = j + 1; a[i][j]--; a[i + 1][j]++; cnt++; } } } print(cnt); rep(i, 0, cnt) { rep(j, 0, 4) { cout << ans[i][j]; if (j != 3) cout << " "; } cout << endl; } }
replace
33
34
33
34
0
p03263
C++
Runtime Error
#include <algorithm> #include <bits/stdc++.h> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; int INF = 1e9; int grid[505][505]; int ans[25005][4]; int main() { int h, w; cin >> h >> w; rep(i, h) rep(j, w) cin >> grid[i][j]; int cnt = 0; rep(i, h) rep(j, w) { if (j == w - 1 && grid[i][j] % 2 == 1) { if (i == h - 1) continue; ans[cnt][0] = i + 1; ans[cnt][1] = w; ans[cnt][2] = i + 2; ans[cnt][3] = w; grid[i + 1][w - 1]++; cnt++; continue; } if (grid[i][j] % 2 == 1) { ans[cnt][0] = i + 1; ans[cnt][1] = j + 1; ans[cnt][2] = i + 1; ans[cnt][3] = j + 2; grid[i][j + 1]++; cnt++; } } cout << cnt << endl; rep(i, cnt) { printf("%d %d %d %d\n", ans[i][0], ans[i][1], ans[i][2], ans[i][3]); } }
#include <algorithm> #include <bits/stdc++.h> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; int INF = 1e9; int grid[505][505]; int ans[250005][4]; int main() { int h, w; cin >> h >> w; rep(i, h) rep(j, w) cin >> grid[i][j]; int cnt = 0; rep(i, h) rep(j, w) { if (j == w - 1 && grid[i][j] % 2 == 1) { if (i == h - 1) continue; ans[cnt][0] = i + 1; ans[cnt][1] = w; ans[cnt][2] = i + 2; ans[cnt][3] = w; grid[i + 1][w - 1]++; cnt++; continue; } if (grid[i][j] % 2 == 1) { ans[cnt][0] = i + 1; ans[cnt][1] = j + 1; ans[cnt][2] = i + 1; ans[cnt][3] = j + 2; grid[i][j + 1]++; cnt++; } } cout << cnt << endl; rep(i, cnt) { printf("%d %d %d %d\n", ans[i][0], ans[i][1], ans[i][2], ans[i][3]); } }
replace
11
12
11
12
0
p03263
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int h, w; cin >> h >> w; vector<vector<int>> a(h, vector<int>(w)); for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) cin >> a[i][j]; vector<int> x1, y1, x2, y2; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { if (a[i][j] % 2 == 1) { a[i][j]--; if (i == h - 1 and j == h - 1) continue; if (j < w - 1 or i == h - 1) { a[i][j + 1]++; x1.push_back(i + 1); y1.push_back(j + 1); x2.push_back(i + 1); y2.push_back(j + 2); } else { a[i + 1][j]++; x1.push_back(i + 1); y1.push_back(j + 1); x2.push_back(i + 2); y2.push_back(j + 1); } } } } cout << x1.size() << endl; for (int i = 0; i < x1.size(); i++) cout << x1[i] << ' ' << y1[i] << ' ' << x2[i] << ' ' << y2[i] << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int h, w; cin >> h >> w; vector<vector<int>> a(h, vector<int>(w)); for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) cin >> a[i][j]; vector<int> x1, y1, x2, y2; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { if (a[i][j] % 2 == 1) { a[i][j]--; if (i == h - 1 and j == w - 1) continue; if (j < w - 1 or i == h - 1) { a[i][j + 1]++; x1.push_back(i + 1); y1.push_back(j + 1); x2.push_back(i + 1); y2.push_back(j + 2); } else { a[i + 1][j]++; x1.push_back(i + 1); y1.push_back(j + 1); x2.push_back(i + 2); y2.push_back(j + 1); } } } } cout << x1.size() << endl; for (int i = 0; i < x1.size(); i++) cout << x1[i] << ' ' << y1[i] << ' ' << x2[i] << ' ' << y2[i] << endl; return 0; }
replace
16
17
16
17
0
p03263
C++
Runtime Error
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #define MX 505 using namespace std; int arr[MX][MX]; int opr[MX * 4][4], num; int main() { int n, m; scanf("%d%d", &n, &m); for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) scanf("%d", &arr[i][j]); for (int i = 1; i <= n; i++) for (int j = 1; j < m; j++) if (arr[i][j] & 1) { arr[i][j]--, arr[i][j + 1]++; num++; opr[num][0] = i; opr[num][1] = j; opr[num][2] = i; opr[num][3] = j + 1; } for (int i = 1; i < n; i++) if (arr[i][m] & 1) { arr[i][m]--, arr[i + 1][m]++; num++; opr[num][0] = i; opr[num][1] = m; opr[num][2] = i + 1; opr[num][3] = m; } printf("%d\n", num); for (int i = 1; i <= num; i++) printf("%d %d %d %d\n", opr[i][0], opr[i][1], opr[i][2], opr[i][3]); return 0; }
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #define MX 505 using namespace std; int arr[MX][MX]; int opr[MX * MX][4], num; int main() { int n, m; scanf("%d%d", &n, &m); for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) scanf("%d", &arr[i][j]); for (int i = 1; i <= n; i++) for (int j = 1; j < m; j++) if (arr[i][j] & 1) { arr[i][j]--, arr[i][j + 1]++; num++; opr[num][0] = i; opr[num][1] = j; opr[num][2] = i; opr[num][3] = j + 1; } for (int i = 1; i < n; i++) if (arr[i][m] & 1) { arr[i][m]--, arr[i + 1][m]++; num++; opr[num][0] = i; opr[num][1] = m; opr[num][2] = i + 1; opr[num][3] = m; } printf("%d\n", num); for (int i = 1; i <= num; i++) printf("%d %d %d %d\n", opr[i][0], opr[i][1], opr[i][2], opr[i][3]); return 0; }
replace
9
10
9
10
0
p03263
C++
Runtime Error
// #include "bits/stdc++.h" #include <algorithm> #include <bitset> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <regex> #include <set> #include <stack> #include <tuple> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> #define int long long #define REP(i, l, r) REPEAT(i, l, r, true) //[l, r) #define rep(i, n) REP(i, 0, n) //[0, n) #define REPEAT(i, l, r, condition) \ for (int i = (condition) ? l : r - 1; (condition) ? i < r : i >= l; \ (condition) ? ++i : --i) // false<-[l, r)->true #define all(e) e.begin(), e.end() #define rall(e) e.rbegin(), e.rend() #define pb push_back #define fs first #define sc second #define show(...) \ cerr << #__VA_ARGS__ << " = "; \ _DEBUG(__VA_ARGS__) #define shows(n) \ for (auto z : n) { \ cerr << z << ", "; \ } \ cerr << endl #define showslr(n, l, r) \ cerr << #n << " = "; \ for (int i = l; i < r; i++) { \ cerr << n[i]; \ } \ cerr << endl //[l, r)) #define yes puts("Yes") #define no puts("No") #define case(i) printf("Case #%lld: ", i) using namespace std; using vi = vector<int>; using pint = pair<int, int>; inline void io() { cin.tie(0); ios::sync_with_stdio(false); cout.tie(0); cout << fixed << setprecision(20); } void _DEBUG() { cerr << endl; } template <typename H, typename... T> void _DEBUG(H a, T... b) { cerr << a << ","; _DEBUG(b...); } template <typename T> inline void in(T &e) { cin >> e; } template <typename H, typename... T> void in(H &a, T &...b) { in(a); in(b...); } template <typename T> inline void out(T e) { cout << e << endl; } template <typename H, typename... T> void out(H a, T... b) { out(a); out(b...); } const int INF = 1LL << 55; const int MOD = 1000000007; const double EPS = 1e-8; const int max_w = 510; int h, w; vi grid[max_w]; vector<pair<pint, pint>> ki; void p(pint from, pint to) { printf("%lld %lld %lld %lld\n", from.fs, from.sc, to.fs, to.sc); } signed main() { io(); in(h, w); rep(i, w) grid[i].resize(h + 10); rep(y, h) { rep(x, w) { in(grid[x][y]); } } int tmp = 0; rep(y, h) { REPEAT(x, 0, w, y % 2 == 0) { if (tmp != 0) { grid[x][y] += tmp; ki[ki.size() - 1].sc = {y + 1, x + 1}; } // show(y+1,x+1,grid[x][y]); if (grid[x][y] & 1) { tmp = grid[x][y]; ki.pb({{y + 1, x + 1}, {}}); } else tmp = 0; } } if (ki[ki.size() - 1].sc.fs == 0 && ki[ki.size() - 1].sc.sc == 0) { ki.erase(ki.end() - 1); } out(ki.size()); for (auto e : ki) { p(e.fs, e.sc); } return 0; }
// #include "bits/stdc++.h" #include <algorithm> #include <bitset> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <regex> #include <set> #include <stack> #include <tuple> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> #define int long long #define REP(i, l, r) REPEAT(i, l, r, true) //[l, r) #define rep(i, n) REP(i, 0, n) //[0, n) #define REPEAT(i, l, r, condition) \ for (int i = (condition) ? l : r - 1; (condition) ? i < r : i >= l; \ (condition) ? ++i : --i) // false<-[l, r)->true #define all(e) e.begin(), e.end() #define rall(e) e.rbegin(), e.rend() #define pb push_back #define fs first #define sc second #define show(...) \ cerr << #__VA_ARGS__ << " = "; \ _DEBUG(__VA_ARGS__) #define shows(n) \ for (auto z : n) { \ cerr << z << ", "; \ } \ cerr << endl #define showslr(n, l, r) \ cerr << #n << " = "; \ for (int i = l; i < r; i++) { \ cerr << n[i]; \ } \ cerr << endl //[l, r)) #define yes puts("Yes") #define no puts("No") #define case(i) printf("Case #%lld: ", i) using namespace std; using vi = vector<int>; using pint = pair<int, int>; inline void io() { cin.tie(0); ios::sync_with_stdio(false); cout.tie(0); cout << fixed << setprecision(20); } void _DEBUG() { cerr << endl; } template <typename H, typename... T> void _DEBUG(H a, T... b) { cerr << a << ","; _DEBUG(b...); } template <typename T> inline void in(T &e) { cin >> e; } template <typename H, typename... T> void in(H &a, T &...b) { in(a); in(b...); } template <typename T> inline void out(T e) { cout << e << endl; } template <typename H, typename... T> void out(H a, T... b) { out(a); out(b...); } const int INF = 1LL << 55; const int MOD = 1000000007; const double EPS = 1e-8; const int max_w = 510; int h, w; vi grid[max_w]; vector<pair<pint, pint>> ki; void p(pint from, pint to) { printf("%lld %lld %lld %lld\n", from.fs, from.sc, to.fs, to.sc); } signed main() { io(); in(h, w); rep(i, w) grid[i].resize(h + 10); rep(y, h) { rep(x, w) { in(grid[x][y]); } } int tmp = 0; rep(y, h) { REPEAT(x, 0, w, y % 2 == 0) { if (tmp != 0) { grid[x][y] += tmp; ki[ki.size() - 1].sc = {y + 1, x + 1}; } // show(y+1,x+1,grid[x][y]); if (grid[x][y] & 1) { tmp = grid[x][y]; ki.pb({{y + 1, x + 1}, {}}); } else tmp = 0; } } if (ki.size() > 0) { if (ki[ki.size() - 1].sc.fs == 0 && ki[ki.size() - 1].sc.sc == 0) { ki.erase(ki.end() - 1); } } out(ki.size()); for (auto e : ki) { p(e.fs, e.sc); } return 0; }
replace
118
121
118
122
0
p03263
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int a[510][510]; struct move { int srx, sry, tx, ty; } mv[2510]; int main() { // freopen("matrix.in","r",stdin); // freopen("matrix.out","w",stdout); int n, m, k = 0, i, j, count = 0; cin >> n >> m; for (i = 1; i <= n; i++) for (j = 1; j <= m; j++) cin >> a[i][j]; memset(mv, 0, sizeof(mv)); for (i = 1; i <= n; i++) for (j = 1; j <= m - 1; j++) if (a[i][j] % 2 == 1) { a[i][j]--; a[i][j + 1]++; k++; mv[k].srx = i; mv[k].sry = j; mv[k].tx = i; mv[k].ty = j + 1; count++; } for (i = 1; i <= n - 1; i++) if (a[i][m] % 2 == 1) { a[i][m]--; a[i + 1][m]++; k++; mv[k].srx = i, mv[k].sry = m, mv[k].tx = i + 1, mv[k].ty = m; count++; } cout << count << endl; for (i = 1; i <= k; i++) cout << mv[i].srx << " " << mv[i].sry << " " << mv[i].tx << " " << mv[i].ty << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int a[510][510]; struct move { int srx, sry, tx, ty; } mv[250010]; int main() { // freopen("matrix.in","r",stdin); // freopen("matrix.out","w",stdout); int n, m, k = 0, i, j, count = 0; cin >> n >> m; for (i = 1; i <= n; i++) for (j = 1; j <= m; j++) cin >> a[i][j]; memset(mv, 0, sizeof(mv)); for (i = 1; i <= n; i++) for (j = 1; j <= m - 1; j++) if (a[i][j] % 2 == 1) { a[i][j]--; a[i][j + 1]++; k++; mv[k].srx = i; mv[k].sry = j; mv[k].tx = i; mv[k].ty = j + 1; count++; } for (i = 1; i <= n - 1; i++) if (a[i][m] % 2 == 1) { a[i][m]--; a[i + 1][m]++; k++; mv[k].srx = i, mv[k].sry = m, mv[k].tx = i + 1, mv[k].ty = m; count++; } cout << count << endl; for (i = 1; i <= k; i++) cout << mv[i].srx << " " << mv[i].sry << " " << mv[i].tx << " " << mv[i].ty << endl; return 0; }
replace
5
6
5
6
0
p03263
C++
Runtime Error
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; const ll MOD_CONST = 1000000007; const ll BIG_NUM = 1000000000000000000; int main() { int h, w; cin >> h >> w; vector<vector<int>> a(h, vector<int>(w)); for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { cin >> a[i][j]; } } vector<string> ans; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { stringstream ss; if (a[i][j] % 2 == 1) { if (j < w - 1) { a[i][j + 1]++; a[i][j]--; ss << i + 1 << " " << j + 1 << " " << i + 1 << " " << j + 2; ans.emplace_back(ss.str()); } else if (i < h - 1) { a[i][j + 1]++; a[i][j]--; ss << i + 1 << " " << j + 1 << " " << i + 2 << " " << j + 1; ans.emplace_back(ss.str()); } } } } cout << ans.size() << endl; for (int i = 0; i < ans.size(); i++) { cout << ans[i] << endl; } }
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; const ll MOD_CONST = 1000000007; const ll BIG_NUM = 1000000000000000000; int main() { int h, w; cin >> h >> w; vector<vector<int>> a(h, vector<int>(w)); for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { cin >> a[i][j]; } } vector<string> ans; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { stringstream ss; if (a[i][j] % 2 == 1) { if (j < w - 1) { a[i][j + 1]++; a[i][j]--; ss << i + 1 << " " << j + 1 << " " << i + 1 << " " << j + 2; ans.emplace_back(ss.str()); } else if (i < h - 1) { a[i + 1][j]++; a[i][j]--; ss << i + 1 << " " << j + 1 << " " << i + 2 << " " << j + 1; ans.emplace_back(ss.str()); } } } } cout << ans.size() << endl; for (int i = 0; i < ans.size(); i++) { cout << ans[i] << endl; } }
replace
41
42
41
42
0
p03263
Python
Runtime Error
import sys def input(): return sys.stdin.readline().strip() sys.setrecursionlimit(20000000) def main(): H, W = map(int, input().split()) A = [list(map(int, input().split())) for _ in range(H)] answer = [] for h in range(H): for w in range(W): if A[h][w] % 2 == 0: continue else: if h + 1 <= H - 1 and w + 1 <= W + 1: if A[h + 1][w] % 2 == 1: A[h + 1][w] += 1 answer.append([h + 1, w + 1, h + 2, w + 1]) else: A[h][w + 1] += 1 answer.append([h + 1, w + 1, h + 1, w + 2]) elif h + 1 <= H - 1: A[h + 1][w] += 1 answer.append([h + 1, w + 1, h + 2, w + 1]) elif w + 1 <= W - 1: A[h][w + 1] += 1 answer.append([h + 1, w + 1, h + 1, w + 2]) else: continue N = len(answer) print(N) for i in range(N): print(*answer[i], sep=" ") if __name__ == "__main__": main()
import sys def input(): return sys.stdin.readline().strip() sys.setrecursionlimit(20000000) def main(): H, W = map(int, input().split()) A = [list(map(int, input().split())) for _ in range(H)] answer = [] for h in range(H): for w in range(W): if A[h][w] % 2 == 0: continue else: if h + 1 <= H - 1 and w + 1 <= W - 1: if A[h + 1][w] % 2 == 1: A[h + 1][w] += 1 answer.append([h + 1, w + 1, h + 2, w + 1]) else: A[h][w + 1] += 1 answer.append([h + 1, w + 1, h + 1, w + 2]) elif h + 1 <= H - 1: A[h + 1][w] += 1 answer.append([h + 1, w + 1, h + 2, w + 1]) elif w + 1 <= W - 1: A[h][w + 1] += 1 answer.append([h + 1, w + 1, h + 1, w + 2]) else: continue N = len(answer) print(N) for i in range(N): print(*answer[i], sep=" ") if __name__ == "__main__": main()
replace
19
20
19
20
0
p03263
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int H, W; cin >> H >> W; vector<vector<int>> a(H + 1, vector<int>(W + 1)), ans; for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++) { cin >> a[i][j]; } } for (int i = 1; i <= H; i++) { for (int j = 1; j < W; j++) { if (a[i][j] & 1) { ans.push_back({i, j, i, j + 1}); a[i][j]--; a[i][j + 1]++; } } } for (int i = 1; i <= H; i++) { if (a[i][W] & 1) { ans.push_back({i, W, i + 1, W}); a[i][W]--; a[i + 1][W]++; } } cout << ans.size() << endl; for (auto a : ans) { cout << a[0] << " " << a[1] << " " << a[2] << " " << a[3] << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int H, W; cin >> H >> W; vector<vector<int>> a(H + 1, vector<int>(W + 1)), ans; for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++) { cin >> a[i][j]; } } for (int i = 1; i <= H; i++) { for (int j = 1; j < W; j++) { if (a[i][j] & 1) { ans.push_back({i, j, i, j + 1}); a[i][j]--; a[i][j + 1]++; } } } for (int i = 1; i < H; i++) { if (a[i][W] & 1) { ans.push_back({i, W, i + 1, W}); a[i][W]--; a[i + 1][W]++; } } cout << ans.size() << endl; for (auto a : ans) { cout << a[0] << " " << a[1] << " " << a[2] << " " << a[3] << endl; } }
replace
21
22
21
22
0
p03263
C++
Runtime Error
// #define _GLIBCXX_DEBUG #include <algorithm> #include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define all(a) (a).begin(), (a).end() using namespace std; using Graph = vector<vector<int>>; typedef long long ll; // using Graph = vector<vector<pair<ll,ll>>>; const int mod = 1e+9 + 7; const int dy[4] = {0, 1, 0, -1}; const int dx[4] = {1, 0, -1, 0}; const ll INF = 1e10; int main() { ll h, w; cin >> h >> w; vector<vector<ll>> a(h, vector<ll>(w)); rep(i, h) { rep(j, w) { cin >> a[i][j]; } } vector<vector<ll>> ans(h * w * 10, vector<ll>(4)); ll cnt = 0; ll ny, nx; rep(i, h) { if (i % 2 == 0) { rep(j, w) { if (a[i][j] % 2 == 0) continue; else if (h % 2 != 0 && i == h - 1 && j == w - 1) break; a[i][j]--; if (j + 1 <= w - 1) { a[i][j + 1]++; ny = i; nx = j + 1; } else { a[i + 1][j]++; ny = i + 1; nx = j; } ans[cnt][0] = i; ans[cnt][1] = j; ans[cnt][2] = ny; ans[cnt][3] = nx; cnt++; } } else { for (int j = w - 1; 0 <= j; j--) { if (a[i][j] % 2 == 0) continue; else if (h % 2 == 0 && i == h && j == 0) break; a[i][j]--; if (j - 1 >= 0) { a[i][j - 1]++; ny = i; nx = j - 1; } else { a[i + 1][j]++; ny = i + 1; nx = j; } ans[cnt][0] = i; ans[cnt][1] = j; ans[cnt][2] = ny; ans[cnt][3] = nx; cnt++; } } } /*rep(i,h){ rep(j,w){ cout<<a[i][j]; } cout<<endl; } return 0;*/ a.resize(cnt); cout << cnt << endl; rep(i, cnt) { cout << ans[i][0] + 1 << " " << ans[i][1] + 1 << " " << ans[i][2] + 1 << " " << ans[i][3] + 1 << endl; } }
// #define _GLIBCXX_DEBUG #include <algorithm> #include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define all(a) (a).begin(), (a).end() using namespace std; using Graph = vector<vector<int>>; typedef long long ll; // using Graph = vector<vector<pair<ll,ll>>>; const int mod = 1e+9 + 7; const int dy[4] = {0, 1, 0, -1}; const int dx[4] = {1, 0, -1, 0}; const ll INF = 1e10; int main() { ll h, w; cin >> h >> w; vector<vector<ll>> a(h, vector<ll>(w)); rep(i, h) { rep(j, w) { cin >> a[i][j]; } } vector<vector<ll>> ans(h * w * 10, vector<ll>(4)); ll cnt = 0; ll ny, nx; rep(i, h) { if (i % 2 == 0) { rep(j, w) { if (a[i][j] % 2 == 0) continue; else if (h % 2 != 0 && i == h - 1 && j == w - 1) break; a[i][j]--; if (j + 1 <= w - 1) { a[i][j + 1]++; ny = i; nx = j + 1; } else { a[i + 1][j]++; ny = i + 1; nx = j; } ans[cnt][0] = i; ans[cnt][1] = j; ans[cnt][2] = ny; ans[cnt][3] = nx; cnt++; } } else { for (int j = w - 1; 0 <= j; j--) { if (a[i][j] % 2 == 0) continue; else if (h % 2 == 0 && i == h - 1 && j == 0) break; a[i][j]--; if (j - 1 >= 0) { a[i][j - 1]++; ny = i; nx = j - 1; } else { a[i + 1][j]++; ny = i + 1; nx = j; } ans[cnt][0] = i; ans[cnt][1] = j; ans[cnt][2] = ny; ans[cnt][3] = nx; cnt++; } } } /*rep(i,h){ rep(j,w){ cout<<a[i][j]; } cout<<endl; } return 0;*/ a.resize(cnt); cout << cnt << endl; rep(i, cnt) { cout << ans[i][0] + 1 << " " << ans[i][1] + 1 << " " << ans[i][2] + 1 << " " << ans[i][3] + 1 << endl; } }
replace
52
53
52
53
0
p03263
C++
Runtime Error
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iostream> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> // #include <boost/multiprecision/cpp_int.hpp> #define BIT(a) (1 << (a)) #define EPS (1e-10) using namespace std; // using namespace boost::multiprecision; const long long MOD = 1000000007; const int COUNTER_CLOCKWISE = 1; const int CLOCKWISE = -1; const int ONLINE_BACK = 2; const int ONLINE_FRONT = -2; const int ON_SEGMENT = 0; class DisjointSet { public: vector<int> rank, p; DisjointSet() {} DisjointSet(int size) { rank.resize(size, 0); p.resize(size, 0); for (int i = 0; i < size; i++) makeSet(i); } void makeSet(int x) { p[x] = x; rank[x] = 0; } bool same(int x, int y) { return findSet(x) == findSet(y); } void unite(int x, int y) { link(findSet(x), findSet(y)); } void link(int x, int y) { if (rank[x] > rank[y]) { p[y] = x; } else { p[x] = y; if (rank[x] == rank[y]) { rank[y]++; } } } int findSet(int x) { if (x != p[x]) { p[x] = findSet(p[x]); } return p[x]; } }; class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator-(Point p) { return Point(x - p.x, y - p.y); } Point operator*(double a) { return Point(a * x, a * y); } Point operator/(double a) { return Point(x / a, y / a); } bool operator<(const Point &p) const { return y != p.y ? y < p.y : x < p.x; } double norm() { return x * x + y * y; } }; typedef Point Vector; typedef vector<Vector> Polygon; double cross(Vector a, Vector b) { return a.x * b.y - a.y * b.x; } double dot(Vector a, Vector b) { return a.x * b.x + a.y * b.y; } int ccw(Point p0, Point p1, Point p2) { Vector a = p1 - p0; Vector b = p2 - p0; if (cross(a, b) > EPS) return COUNTER_CLOCKWISE; if (cross(a, b) > -EPS) return CLOCKWISE; if (dot(a, b) < -EPS) return ONLINE_BACK; if (a.norm() < b.norm()) return ONLINE_FRONT; return ON_SEGMENT; } Polygon andrewScan(Polygon s) { Polygon u, l; if (s.size() < 3) return s; sort(s.begin(), s.end()); u.push_back(s[0]); u.push_back(s[1]); l.push_back(s[s.size() - 1]); l.push_back(s[s.size() - 2]); for (size_t i = 2; i < s.size(); i++) { for (size_t n = u.size(); n >= 2 && ccw(u[n - 2], u[n - 1], s[i]) == COUNTER_CLOCKWISE; n--) { u.pop_back(); } u.push_back(s[i]); } for (int i = (int)s.size() - 3; i >= 0; i--) { for (size_t n = l.size(); n >= 2 && ccw(l[n - 2], l[n - 1], s[i]) == COUNTER_CLOCKWISE; n--) { l.pop_back(); } l.push_back(s[i]); } reverse(l.begin(), l.end()); for (size_t i = u.size() - 2; i >= 1; i--) l.push_back(u[i]); return l; } long long mss(long long A[], int l, int r) { int left; int right; long long ma; long long ma2; for (int i = l; i < r; i++) { if (i == l) { ma = A[i]; ma2 = A[i]; continue; } ma2 = max(A[i], ma2 + A[i]); ma = max(ma2, ma); } return ma; } long long mod_pow(long long x, long long n) { long long res = 1; for (int i = 0; i < 60; i++) { if (n >> i & 1) res = res * x % MOD; x = x * x % MOD; } return res; } #define Int long long Int gcd(Int a, Int b) { return b != 0 ? gcd(b, a % b) : a; } Int lcm(Int a, Int b) { return a * b / gcd(a, b); } // a x + b y = gcd(a, b) Int extgcd(Int a, Int b, Int &x, Int &y) { Int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; } // field[H][W] int field[505][505]; int ans[100000][4]; int main() { int H, W; cin >> H >> W; int N = 0; for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++) { cin >> field[i][j]; } } for (int i = 1; i <= H; i++) { if (i % 2) { for (int j = 1; j <= W; j++) { if (field[i][j] % 2) { if (j != W) { ans[N][0] = i; ans[N][1] = j; ans[N][2] = i; ans[N][3] = j + 1; N++; field[i][j] -= 1; field[i][j + 1] += 1; } else { if (i == H) break; ans[N][0] = i; ans[N][1] = j; ans[N][2] = i + 1; ans[N][3] = j; N++; field[i][j] -= 1; field[i + 1][j] += 1; } } } } else { for (int j = W; j >= 1; j--) { if (field[i][j] % 2) { if (j != 1) { ans[N][0] = i; ans[N][1] = j; ans[N][2] = i; ans[N][3] = j - 1; N++; field[i][j] -= 1; field[i][j - 1] += 1; } else { if (i == H) break; ans[N][0] = i; ans[N][1] = j; ans[N][2] = i + 1; ans[N][3] = j; N++; field[i][j] -= 1; field[i + 1][j] += 1; } } } } } cout << N << endl; for (int i = 0; i < N; i++) { for (int j = 0; j < 4; j++) { cout << ans[i][j]; if (j == 3) cout << endl; else cout << " "; } } }
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iostream> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> // #include <boost/multiprecision/cpp_int.hpp> #define BIT(a) (1 << (a)) #define EPS (1e-10) using namespace std; // using namespace boost::multiprecision; const long long MOD = 1000000007; const int COUNTER_CLOCKWISE = 1; const int CLOCKWISE = -1; const int ONLINE_BACK = 2; const int ONLINE_FRONT = -2; const int ON_SEGMENT = 0; class DisjointSet { public: vector<int> rank, p; DisjointSet() {} DisjointSet(int size) { rank.resize(size, 0); p.resize(size, 0); for (int i = 0; i < size; i++) makeSet(i); } void makeSet(int x) { p[x] = x; rank[x] = 0; } bool same(int x, int y) { return findSet(x) == findSet(y); } void unite(int x, int y) { link(findSet(x), findSet(y)); } void link(int x, int y) { if (rank[x] > rank[y]) { p[y] = x; } else { p[x] = y; if (rank[x] == rank[y]) { rank[y]++; } } } int findSet(int x) { if (x != p[x]) { p[x] = findSet(p[x]); } return p[x]; } }; class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator-(Point p) { return Point(x - p.x, y - p.y); } Point operator*(double a) { return Point(a * x, a * y); } Point operator/(double a) { return Point(x / a, y / a); } bool operator<(const Point &p) const { return y != p.y ? y < p.y : x < p.x; } double norm() { return x * x + y * y; } }; typedef Point Vector; typedef vector<Vector> Polygon; double cross(Vector a, Vector b) { return a.x * b.y - a.y * b.x; } double dot(Vector a, Vector b) { return a.x * b.x + a.y * b.y; } int ccw(Point p0, Point p1, Point p2) { Vector a = p1 - p0; Vector b = p2 - p0; if (cross(a, b) > EPS) return COUNTER_CLOCKWISE; if (cross(a, b) > -EPS) return CLOCKWISE; if (dot(a, b) < -EPS) return ONLINE_BACK; if (a.norm() < b.norm()) return ONLINE_FRONT; return ON_SEGMENT; } Polygon andrewScan(Polygon s) { Polygon u, l; if (s.size() < 3) return s; sort(s.begin(), s.end()); u.push_back(s[0]); u.push_back(s[1]); l.push_back(s[s.size() - 1]); l.push_back(s[s.size() - 2]); for (size_t i = 2; i < s.size(); i++) { for (size_t n = u.size(); n >= 2 && ccw(u[n - 2], u[n - 1], s[i]) == COUNTER_CLOCKWISE; n--) { u.pop_back(); } u.push_back(s[i]); } for (int i = (int)s.size() - 3; i >= 0; i--) { for (size_t n = l.size(); n >= 2 && ccw(l[n - 2], l[n - 1], s[i]) == COUNTER_CLOCKWISE; n--) { l.pop_back(); } l.push_back(s[i]); } reverse(l.begin(), l.end()); for (size_t i = u.size() - 2; i >= 1; i--) l.push_back(u[i]); return l; } long long mss(long long A[], int l, int r) { int left; int right; long long ma; long long ma2; for (int i = l; i < r; i++) { if (i == l) { ma = A[i]; ma2 = A[i]; continue; } ma2 = max(A[i], ma2 + A[i]); ma = max(ma2, ma); } return ma; } long long mod_pow(long long x, long long n) { long long res = 1; for (int i = 0; i < 60; i++) { if (n >> i & 1) res = res * x % MOD; x = x * x % MOD; } return res; } #define Int long long Int gcd(Int a, Int b) { return b != 0 ? gcd(b, a % b) : a; } Int lcm(Int a, Int b) { return a * b / gcd(a, b); } // a x + b y = gcd(a, b) Int extgcd(Int a, Int b, Int &x, Int &y) { Int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; } // field[H][W] int field[505][505]; int ans[2550250][4]; int main() { int H, W; cin >> H >> W; int N = 0; for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++) { cin >> field[i][j]; } } for (int i = 1; i <= H; i++) { if (i % 2) { for (int j = 1; j <= W; j++) { if (field[i][j] % 2) { if (j != W) { ans[N][0] = i; ans[N][1] = j; ans[N][2] = i; ans[N][3] = j + 1; N++; field[i][j] -= 1; field[i][j + 1] += 1; } else { if (i == H) break; ans[N][0] = i; ans[N][1] = j; ans[N][2] = i + 1; ans[N][3] = j; N++; field[i][j] -= 1; field[i + 1][j] += 1; } } } } else { for (int j = W; j >= 1; j--) { if (field[i][j] % 2) { if (j != 1) { ans[N][0] = i; ans[N][1] = j; ans[N][2] = i; ans[N][3] = j - 1; N++; field[i][j] -= 1; field[i][j - 1] += 1; } else { if (i == H) break; ans[N][0] = i; ans[N][1] = j; ans[N][2] = i + 1; ans[N][3] = j; N++; field[i][j] -= 1; field[i + 1][j] += 1; } } } } } cout << N << endl; for (int i = 0; i < N; i++) { for (int j = 0; j < 4; j++) { cout << ans[i][j]; if (j == 3) cout << endl; else cout << " "; } } }
replace
187
188
187
188
0
p03263
C++
Runtime Error
#include <algorithm> #include <cassert> #include <climits> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <fstream> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define TOSTRING(x) #x #define SZ(x) (int)(x).size() #define REP(i, n) for (int i = 0; i < (n); i++) #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define REPR(i, n) for (int i = (n)-1; i >= 0; i--) #define ALL(s) (s).begin(), (s).end() #define so(V) sort(ALL(V)) #define rev(V) reverse(ALL(V)) #define uni(v) v.erase(unique(ALL(v)), v.end()); #define PAU system("pause") typedef long long unsigned int llu; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<bool> vb; typedef vector<vi> vvi; typedef vector<vll> vvll; typedef vector<vb> vvb; const double EPS = 1e-9; const int MOD = 1e9 + 7; const int INF = (1 << 30); const double PI = acos(-1); struct Move { int x, y, ax, ay; Move() {} Move(int _y, int _x, int _ay, int _ax) { x = _x; y = _y; ax = _ax; ay = _ay; } }; int H, W; bool check(int y, int x) { if (y < 0 || y >= H) return false; if (x < 0 || x >= W) return false; return true; } int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> H >> W; vvi A(9, vi(9, 0)); REP(i, H) REP(j, W) { cin >> A[i][j]; } vector<Move> VM; REP(i, H) REP(j, W) { if (A[i][j] % 2 == 1) { if (!check(i, j + 1)) { // 必ず下に動かさなければならない if (!check(i + 1, j)) continue; A[i][j] -= 1; A[i + 1][j] += 1; VM.push_back(Move(i + 1, j + 1, i + 2, j + 1)); } else { A[i][j] -= 1; A[i][j + 1] += 1; VM.push_back(Move(i + 1, j + 1, i + 1, j + 2)); } } } cout << SZ(VM) << endl; for (Move m : VM) { cout << m.y << " " << m.x << " " << m.ay << " " << m.ax << endl; } PAU; return 0; }
#include <algorithm> #include <cassert> #include <climits> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <fstream> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define TOSTRING(x) #x #define SZ(x) (int)(x).size() #define REP(i, n) for (int i = 0; i < (n); i++) #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define REPR(i, n) for (int i = (n)-1; i >= 0; i--) #define ALL(s) (s).begin(), (s).end() #define so(V) sort(ALL(V)) #define rev(V) reverse(ALL(V)) #define uni(v) v.erase(unique(ALL(v)), v.end()); #define PAU system("pause") typedef long long unsigned int llu; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<bool> vb; typedef vector<vi> vvi; typedef vector<vll> vvll; typedef vector<vb> vvb; const double EPS = 1e-9; const int MOD = 1e9 + 7; const int INF = (1 << 30); const double PI = acos(-1); struct Move { int x, y, ax, ay; Move() {} Move(int _y, int _x, int _ay, int _ax) { x = _x; y = _y; ax = _ax; ay = _ay; } }; int H, W; bool check(int y, int x) { if (y < 0 || y >= H) return false; if (x < 0 || x >= W) return false; return true; } int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> H >> W; vvi A(H, vi(W, 0)); REP(i, H) REP(j, W) { cin >> A[i][j]; } vector<Move> VM; REP(i, H) REP(j, W) { if (A[i][j] % 2 == 1) { if (!check(i, j + 1)) { // 必ず下に動かさなければならない if (!check(i + 1, j)) continue; A[i][j] -= 1; A[i + 1][j] += 1; VM.push_back(Move(i + 1, j + 1, i + 2, j + 1)); } else { A[i][j] -= 1; A[i][j + 1] += 1; VM.push_back(Move(i + 1, j + 1, i + 1, j + 2)); } } } cout << SZ(VM) << endl; for (Move m : VM) { cout << m.y << " " << m.x << " " << m.ay << " " << m.ax << endl; } PAU; return 0; }
replace
69
70
69
70
0
sh: 1: pause: not found
p03263
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (n); i++) #define rep1(i, n) for (int i = 1; i <= (n); i++) #define co(x) cout << (x) << "\n" #define cosp(x) cout << (x) << " " #define ce(x) cerr << (x) << "\n" #define cesp(x) cerr << (x) << " " #define pb push_back #define mp make_pair #define getchar getchar_unlocked #define putchar putchar_unlocked #define Would #define you #define please const int cm = 1 << 10; char cn[cm], ct; inline int getint() { int A = 0; while ((ct = getchar()) >= '0') A = A * 10 + ct - '0'; return A; } const int dm = 1 << 20; char dn[dm], *di = dn, dt; char n[501] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}; char c[2004] = { 48, 0, 0, 1, 49, 0, 0, 1, 50, 0, 0, 1, 51, 0, 0, 1, 52, 0, 0, 1, 53, 0, 0, 1, 54, 0, 0, 1, 55, 0, 0, 1, 56, 0, 0, 1, 57, 0, 0, 2, 49, 48, 0, 2, 49, 49, 0, 2, 49, 50, 0, 2, 49, 51, 0, 2, 49, 52, 0, 2, 49, 53, 0, 2, 49, 54, 0, 2, 49, 55, 0, 2, 49, 56, 0, 2, 49, 57, 0, 2, 50, 48, 0, 2, 50, 49, 0, 2, 50, 50, 0, 2, 50, 51, 0, 2, 50, 52, 0, 2, 50, 53, 0, 2, 50, 54, 0, 2, 50, 55, 0, 2, 50, 56, 0, 2, 50, 57, 0, 2, 51, 48, 0, 2, 51, 49, 0, 2, 51, 50, 0, 2, 51, 51, 0, 2, 51, 52, 0, 2, 51, 53, 0, 2, 51, 54, 0, 2, 51, 55, 0, 2, 51, 56, 0, 2, 51, 57, 0, 2, 52, 48, 0, 2, 52, 49, 0, 2, 52, 50, 0, 2, 52, 51, 0, 2, 52, 52, 0, 2, 52, 53, 0, 2, 52, 54, 0, 2, 52, 55, 0, 2, 52, 56, 0, 2, 52, 57, 0, 2, 53, 48, 0, 2, 53, 49, 0, 2, 53, 50, 0, 2, 53, 51, 0, 2, 53, 52, 0, 2, 53, 53, 0, 2, 53, 54, 0, 2, 53, 55, 0, 2, 53, 56, 0, 2, 53, 57, 0, 2, 54, 48, 0, 2, 54, 49, 0, 2, 54, 50, 0, 2, 54, 51, 0, 2, 54, 52, 0, 2, 54, 53, 0, 2, 54, 54, 0, 2, 54, 55, 0, 2, 54, 56, 0, 2, 54, 57, 0, 2, 55, 48, 0, 2, 55, 49, 0, 2, 55, 50, 0, 2, 55, 51, 0, 2, 55, 52, 0, 2, 55, 53, 0, 2, 55, 54, 0, 2, 55, 55, 0, 2, 55, 56, 0, 2, 55, 57, 0, 2, 56, 48, 0, 2, 56, 49, 0, 2, 56, 50, 0, 2, 56, 51, 0, 2, 56, 52, 0, 2, 56, 53, 0, 2, 56, 54, 0, 2, 56, 55, 0, 2, 56, 56, 0, 2, 56, 57, 0, 2, 57, 48, 0, 2, 57, 49, 0, 2, 57, 50, 0, 2, 57, 51, 0, 2, 57, 52, 0, 2, 57, 53, 0, 2, 57, 54, 0, 2, 57, 55, 0, 2, 57, 56, 0, 2, 57, 57, 0, 3, 49, 48, 48, 3, 49, 48, 49, 3, 49, 48, 50, 3, 49, 48, 51, 3, 49, 48, 52, 3, 49, 48, 53, 3, 49, 48, 54, 3, 49, 48, 55, 3, 49, 48, 56, 3, 49, 48, 57, 3, 49, 49, 48, 3, 49, 49, 49, 3, 49, 49, 50, 3, 49, 49, 51, 3, 49, 49, 52, 3, 49, 49, 53, 3, 49, 49, 54, 3, 49, 49, 55, 3, 49, 49, 56, 3, 49, 49, 57, 3, 49, 50, 48, 3, 49, 50, 49, 3, 49, 50, 50, 3, 49, 50, 51, 3, 49, 50, 52, 3, 49, 50, 53, 3, 49, 50, 54, 3, 49, 50, 55, 3, 49, 50, 56, 3, 49, 50, 57, 3, 49, 51, 48, 3, 49, 51, 49, 3, 49, 51, 50, 3, 49, 51, 51, 3, 49, 51, 52, 3, 49, 51, 53, 3, 49, 51, 54, 3, 49, 51, 55, 3, 49, 51, 56, 3, 49, 51, 57, 3, 49, 52, 48, 3, 49, 52, 49, 3, 49, 52, 50, 3, 49, 52, 51, 3, 49, 52, 52, 3, 49, 52, 53, 3, 49, 52, 54, 3, 49, 52, 55, 3, 49, 52, 56, 3, 49, 52, 57, 3, 49, 53, 48, 3, 49, 53, 49, 3, 49, 53, 50, 3, 49, 53, 51, 3, 49, 53, 52, 3, 49, 53, 53, 3, 49, 53, 54, 3, 49, 53, 55, 3, 49, 53, 56, 3, 49, 53, 57, 3, 49, 54, 48, 3, 49, 54, 49, 3, 49, 54, 50, 3, 49, 54, 51, 3, 49, 54, 52, 3, 49, 54, 53, 3, 49, 54, 54, 3, 49, 54, 55, 3, 49, 54, 56, 3, 49, 54, 57, 3, 49, 55, 48, 3, 49, 55, 49, 3, 49, 55, 50, 3, 49, 55, 51, 3, 49, 55, 52, 3, 49, 55, 53, 3, 49, 55, 54, 3, 49, 55, 55, 3, 49, 55, 56, 3, 49, 55, 57, 3, 49, 56, 48, 3, 49, 56, 49, 3, 49, 56, 50, 3, 49, 56, 51, 3, 49, 56, 52, 3, 49, 56, 53, 3, 49, 56, 54, 3, 49, 56, 55, 3, 49, 56, 56, 3, 49, 56, 57, 3, 49, 57, 48, 3, 49, 57, 49, 3, 49, 57, 50, 3, 49, 57, 51, 3, 49, 57, 52, 3, 49, 57, 53, 3, 49, 57, 54, 3, 49, 57, 55, 3, 49, 57, 56, 3, 49, 57, 57, 3, 50, 48, 48, 3, 50, 48, 49, 3, 50, 48, 50, 3, 50, 48, 51, 3, 50, 48, 52, 3, 50, 48, 53, 3, 50, 48, 54, 3, 50, 48, 55, 3, 50, 48, 56, 3, 50, 48, 57, 3, 50, 49, 48, 3, 50, 49, 49, 3, 50, 49, 50, 3, 50, 49, 51, 3, 50, 49, 52, 3, 50, 49, 53, 3, 50, 49, 54, 3, 50, 49, 55, 3, 50, 49, 56, 3, 50, 49, 57, 3, 50, 50, 48, 3, 50, 50, 49, 3, 50, 50, 50, 3, 50, 50, 51, 3, 50, 50, 52, 3, 50, 50, 53, 3, 50, 50, 54, 3, 50, 50, 55, 3, 50, 50, 56, 3, 50, 50, 57, 3, 50, 51, 48, 3, 50, 51, 49, 3, 50, 51, 50, 3, 50, 51, 51, 3, 50, 51, 52, 3, 50, 51, 53, 3, 50, 51, 54, 3, 50, 51, 55, 3, 50, 51, 56, 3, 50, 51, 57, 3, 50, 52, 48, 3, 50, 52, 49, 3, 50, 52, 50, 3, 50, 52, 51, 3, 50, 52, 52, 3, 50, 52, 53, 3, 50, 52, 54, 3, 50, 52, 55, 3, 50, 52, 56, 3, 50, 52, 57, 3, 50, 53, 48, 3, 50, 53, 49, 3, 50, 53, 50, 3, 50, 53, 51, 3, 50, 53, 52, 3, 50, 53, 53, 3, 50, 53, 54, 3, 50, 53, 55, 3, 50, 53, 56, 3, 50, 53, 57, 3, 50, 54, 48, 3, 50, 54, 49, 3, 50, 54, 50, 3, 50, 54, 51, 3, 50, 54, 52, 3, 50, 54, 53, 3, 50, 54, 54, 3, 50, 54, 55, 3, 50, 54, 56, 3, 50, 54, 57, 3, 50, 55, 48, 3, 50, 55, 49, 3, 50, 55, 50, 3, 50, 55, 51, 3, 50, 55, 52, 3, 50, 55, 53, 3, 50, 55, 54, 3, 50, 55, 55, 3, 50, 55, 56, 3, 50, 55, 57, 3, 50, 56, 48, 3, 50, 56, 49, 3, 50, 56, 50, 3, 50, 56, 51, 3, 50, 56, 52, 3, 50, 56, 53, 3, 50, 56, 54, 3, 50, 56, 55, 3, 50, 56, 56, 3, 50, 56, 57, 3, 50, 57, 48, 3, 50, 57, 49, 3, 50, 57, 50, 3, 50, 57, 51, 3, 50, 57, 52, 3, 50, 57, 53, 3, 50, 57, 54, 3, 50, 57, 55, 3, 50, 57, 56, 3, 50, 57, 57, 3, 51, 48, 48, 3, 51, 48, 49, 3, 51, 48, 50, 3, 51, 48, 51, 3, 51, 48, 52, 3, 51, 48, 53, 3, 51, 48, 54, 3, 51, 48, 55, 3, 51, 48, 56, 3, 51, 48, 57, 3, 51, 49, 48, 3, 51, 49, 49, 3, 51, 49, 50, 3, 51, 49, 51, 3, 51, 49, 52, 3, 51, 49, 53, 3, 51, 49, 54, 3, 51, 49, 55, 3, 51, 49, 56, 3, 51, 49, 57, 3, 51, 50, 48, 3, 51, 50, 49, 3, 51, 50, 50, 3, 51, 50, 51, 3, 51, 50, 52, 3, 51, 50, 53, 3, 51, 50, 54, 3, 51, 50, 55, 3, 51, 50, 56, 3, 51, 50, 57, 3, 51, 51, 48, 3, 51, 51, 49, 3, 51, 51, 50, 3, 51, 51, 51, 3, 51, 51, 52, 3, 51, 51, 53, 3, 51, 51, 54, 3, 51, 51, 55, 3, 51, 51, 56, 3, 51, 51, 57, 3, 51, 52, 48, 3, 51, 52, 49, 3, 51, 52, 50, 3, 51, 52, 51, 3, 51, 52, 52, 3, 51, 52, 53, 3, 51, 52, 54, 3, 51, 52, 55, 3, 51, 52, 56, 3, 51, 52, 57, 3, 51, 53, 48, 3, 51, 53, 49, 3, 51, 53, 50, 3, 51, 53, 51, 3, 51, 53, 52, 3, 51, 53, 53, 3, 51, 53, 54, 3, 51, 53, 55, 3, 51, 53, 56, 3, 51, 53, 57, 3, 51, 54, 48, 3, 51, 54, 49, 3, 51, 54, 50, 3, 51, 54, 51, 3, 51, 54, 52, 3, 51, 54, 53, 3, 51, 54, 54, 3, 51, 54, 55, 3, 51, 54, 56, 3, 51, 54, 57, 3, 51, 55, 48, 3, 51, 55, 49, 3, 51, 55, 50, 3, 51, 55, 51, 3, 51, 55, 52, 3, 51, 55, 53, 3, 51, 55, 54, 3, 51, 55, 55, 3, 51, 55, 56, 3, 51, 55, 57, 3, 51, 56, 48, 3, 51, 56, 49, 3, 51, 56, 50, 3, 51, 56, 51, 3, 51, 56, 52, 3, 51, 56, 53, 3, 51, 56, 54, 3, 51, 56, 55, 3, 51, 56, 56, 3, 51, 56, 57, 3, 51, 57, 48, 3, 51, 57, 49, 3, 51, 57, 50, 3, 51, 57, 51, 3, 51, 57, 52, 3, 51, 57, 53, 3, 51, 57, 54, 3, 51, 57, 55, 3, 51, 57, 56, 3, 51, 57, 57, 3, 52, 48, 48, 3, 52, 48, 49, 3, 52, 48, 50, 3, 52, 48, 51, 3, 52, 48, 52, 3, 52, 48, 53, 3, 52, 48, 54, 3, 52, 48, 55, 3, 52, 48, 56, 3, 52, 48, 57, 3, 52, 49, 48, 3, 52, 49, 49, 3, 52, 49, 50, 3, 52, 49, 51, 3, 52, 49, 52, 3, 52, 49, 53, 3, 52, 49, 54, 3, 52, 49, 55, 3, 52, 49, 56, 3, 52, 49, 57, 3, 52, 50, 48, 3, 52, 50, 49, 3, 52, 50, 50, 3, 52, 50, 51, 3, 52, 50, 52, 3, 52, 50, 53, 3, 52, 50, 54, 3, 52, 50, 55, 3, 52, 50, 56, 3, 52, 50, 57, 3, 52, 51, 48, 3, 52, 51, 49, 3, 52, 51, 50, 3, 52, 51, 51, 3, 52, 51, 52, 3, 52, 51, 53, 3, 52, 51, 54, 3, 52, 51, 55, 3, 52, 51, 56, 3, 52, 51, 57, 3, 52, 52, 48, 3, 52, 52, 49, 3, 52, 52, 50, 3, 52, 52, 51, 3, 52, 52, 52, 3, 52, 52, 53, 3, 52, 52, 54, 3, 52, 52, 55, 3, 52, 52, 56, 3, 52, 52, 57, 3, 52, 53, 48, 3, 52, 53, 49, 3, 52, 53, 50, 3, 52, 53, 51, 3, 52, 53, 52, 3, 52, 53, 53, 3, 52, 53, 54, 3, 52, 53, 55, 3, 52, 53, 56, 3, 52, 53, 57, 3, 52, 54, 48, 3, 52, 54, 49, 3, 52, 54, 50, 3, 52, 54, 51, 3, 52, 54, 52, 3, 52, 54, 53, 3, 52, 54, 54, 3, 52, 54, 55, 3, 52, 54, 56, 3, 52, 54, 57, 3, 52, 55, 48, 3, 52, 55, 49, 3, 52, 55, 50, 3, 52, 55, 51, 3, 52, 55, 52, 3, 52, 55, 53, 3, 52, 55, 54, 3, 52, 55, 55, 3, 52, 55, 56, 3, 52, 55, 57, 3, 52, 56, 48, 3, 52, 56, 49, 3, 52, 56, 50, 3, 52, 56, 51, 3, 52, 56, 52, 3, 52, 56, 53, 3, 52, 56, 54, 3, 52, 56, 55, 3, 52, 56, 56, 3, 52, 56, 57, 3, 52, 57, 48, 3, 52, 57, 49, 3, 52, 57, 50, 3, 52, 57, 51, 3, 52, 57, 52, 3, 52, 57, 53, 3, 52, 57, 54, 3, 52, 57, 55, 3, 52, 57, 56, 3, 52, 57, 57, 3, 53, 48, 48}; inline void putints(int X) { auto N = *(n + X); memcpy(di, c + (X << 2), N); di += N; *di++ = ' '; } inline void putint(int X) { auto N = *(n + X); memcpy(di, c + (X << 2), N); di += N; *di++ = '\n'; } inline void putk(int X) { if (X == 0) putchar('0'); int keta = 0; char C[10]; while (X) { *(C + keta) = '0' + X % 10; X /= 10; keta++; } for (int i = keta - 1; i >= 0; i--) putchar(*(C + i)); putchar('\n'); } int main() { int H, W; bool a = 0, b = 0; H = getint(); W = getint(); int k = 0; rep1(i, H) { fread(cn, 1, W << 1, stdin); auto ci = cn; rep1(ii, W - 1) { a ^= *ci & 1; ci += 2; if (a) { k++; putints(i); putints(ii); putints(i); putint(ii + 1); } } if (i != H) { b ^= a ^ (*ci & 1); if (b) { k++; putints(i); putints(W); putints(i + 1); putint(W); } } a = false; } putk(k); fwrite(dn, 1, di - dn, stdout); Would you please return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (n); i++) #define rep1(i, n) for (int i = 1; i <= (n); i++) #define co(x) cout << (x) << "\n" #define cosp(x) cout << (x) << " " #define ce(x) cerr << (x) << "\n" #define cesp(x) cerr << (x) << " " #define pb push_back #define mp make_pair #define getchar getchar_unlocked #define putchar putchar_unlocked #define Would #define you #define please const int cm = 1 << 10; char cn[cm], ct; inline int getint() { int A = 0; while ((ct = getchar()) >= '0') A = A * 10 + ct - '0'; return A; } const int dm = 1 << 21; char dn[dm], *di = dn, dt; char n[501] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}; char c[2004] = { 48, 0, 0, 1, 49, 0, 0, 1, 50, 0, 0, 1, 51, 0, 0, 1, 52, 0, 0, 1, 53, 0, 0, 1, 54, 0, 0, 1, 55, 0, 0, 1, 56, 0, 0, 1, 57, 0, 0, 2, 49, 48, 0, 2, 49, 49, 0, 2, 49, 50, 0, 2, 49, 51, 0, 2, 49, 52, 0, 2, 49, 53, 0, 2, 49, 54, 0, 2, 49, 55, 0, 2, 49, 56, 0, 2, 49, 57, 0, 2, 50, 48, 0, 2, 50, 49, 0, 2, 50, 50, 0, 2, 50, 51, 0, 2, 50, 52, 0, 2, 50, 53, 0, 2, 50, 54, 0, 2, 50, 55, 0, 2, 50, 56, 0, 2, 50, 57, 0, 2, 51, 48, 0, 2, 51, 49, 0, 2, 51, 50, 0, 2, 51, 51, 0, 2, 51, 52, 0, 2, 51, 53, 0, 2, 51, 54, 0, 2, 51, 55, 0, 2, 51, 56, 0, 2, 51, 57, 0, 2, 52, 48, 0, 2, 52, 49, 0, 2, 52, 50, 0, 2, 52, 51, 0, 2, 52, 52, 0, 2, 52, 53, 0, 2, 52, 54, 0, 2, 52, 55, 0, 2, 52, 56, 0, 2, 52, 57, 0, 2, 53, 48, 0, 2, 53, 49, 0, 2, 53, 50, 0, 2, 53, 51, 0, 2, 53, 52, 0, 2, 53, 53, 0, 2, 53, 54, 0, 2, 53, 55, 0, 2, 53, 56, 0, 2, 53, 57, 0, 2, 54, 48, 0, 2, 54, 49, 0, 2, 54, 50, 0, 2, 54, 51, 0, 2, 54, 52, 0, 2, 54, 53, 0, 2, 54, 54, 0, 2, 54, 55, 0, 2, 54, 56, 0, 2, 54, 57, 0, 2, 55, 48, 0, 2, 55, 49, 0, 2, 55, 50, 0, 2, 55, 51, 0, 2, 55, 52, 0, 2, 55, 53, 0, 2, 55, 54, 0, 2, 55, 55, 0, 2, 55, 56, 0, 2, 55, 57, 0, 2, 56, 48, 0, 2, 56, 49, 0, 2, 56, 50, 0, 2, 56, 51, 0, 2, 56, 52, 0, 2, 56, 53, 0, 2, 56, 54, 0, 2, 56, 55, 0, 2, 56, 56, 0, 2, 56, 57, 0, 2, 57, 48, 0, 2, 57, 49, 0, 2, 57, 50, 0, 2, 57, 51, 0, 2, 57, 52, 0, 2, 57, 53, 0, 2, 57, 54, 0, 2, 57, 55, 0, 2, 57, 56, 0, 2, 57, 57, 0, 3, 49, 48, 48, 3, 49, 48, 49, 3, 49, 48, 50, 3, 49, 48, 51, 3, 49, 48, 52, 3, 49, 48, 53, 3, 49, 48, 54, 3, 49, 48, 55, 3, 49, 48, 56, 3, 49, 48, 57, 3, 49, 49, 48, 3, 49, 49, 49, 3, 49, 49, 50, 3, 49, 49, 51, 3, 49, 49, 52, 3, 49, 49, 53, 3, 49, 49, 54, 3, 49, 49, 55, 3, 49, 49, 56, 3, 49, 49, 57, 3, 49, 50, 48, 3, 49, 50, 49, 3, 49, 50, 50, 3, 49, 50, 51, 3, 49, 50, 52, 3, 49, 50, 53, 3, 49, 50, 54, 3, 49, 50, 55, 3, 49, 50, 56, 3, 49, 50, 57, 3, 49, 51, 48, 3, 49, 51, 49, 3, 49, 51, 50, 3, 49, 51, 51, 3, 49, 51, 52, 3, 49, 51, 53, 3, 49, 51, 54, 3, 49, 51, 55, 3, 49, 51, 56, 3, 49, 51, 57, 3, 49, 52, 48, 3, 49, 52, 49, 3, 49, 52, 50, 3, 49, 52, 51, 3, 49, 52, 52, 3, 49, 52, 53, 3, 49, 52, 54, 3, 49, 52, 55, 3, 49, 52, 56, 3, 49, 52, 57, 3, 49, 53, 48, 3, 49, 53, 49, 3, 49, 53, 50, 3, 49, 53, 51, 3, 49, 53, 52, 3, 49, 53, 53, 3, 49, 53, 54, 3, 49, 53, 55, 3, 49, 53, 56, 3, 49, 53, 57, 3, 49, 54, 48, 3, 49, 54, 49, 3, 49, 54, 50, 3, 49, 54, 51, 3, 49, 54, 52, 3, 49, 54, 53, 3, 49, 54, 54, 3, 49, 54, 55, 3, 49, 54, 56, 3, 49, 54, 57, 3, 49, 55, 48, 3, 49, 55, 49, 3, 49, 55, 50, 3, 49, 55, 51, 3, 49, 55, 52, 3, 49, 55, 53, 3, 49, 55, 54, 3, 49, 55, 55, 3, 49, 55, 56, 3, 49, 55, 57, 3, 49, 56, 48, 3, 49, 56, 49, 3, 49, 56, 50, 3, 49, 56, 51, 3, 49, 56, 52, 3, 49, 56, 53, 3, 49, 56, 54, 3, 49, 56, 55, 3, 49, 56, 56, 3, 49, 56, 57, 3, 49, 57, 48, 3, 49, 57, 49, 3, 49, 57, 50, 3, 49, 57, 51, 3, 49, 57, 52, 3, 49, 57, 53, 3, 49, 57, 54, 3, 49, 57, 55, 3, 49, 57, 56, 3, 49, 57, 57, 3, 50, 48, 48, 3, 50, 48, 49, 3, 50, 48, 50, 3, 50, 48, 51, 3, 50, 48, 52, 3, 50, 48, 53, 3, 50, 48, 54, 3, 50, 48, 55, 3, 50, 48, 56, 3, 50, 48, 57, 3, 50, 49, 48, 3, 50, 49, 49, 3, 50, 49, 50, 3, 50, 49, 51, 3, 50, 49, 52, 3, 50, 49, 53, 3, 50, 49, 54, 3, 50, 49, 55, 3, 50, 49, 56, 3, 50, 49, 57, 3, 50, 50, 48, 3, 50, 50, 49, 3, 50, 50, 50, 3, 50, 50, 51, 3, 50, 50, 52, 3, 50, 50, 53, 3, 50, 50, 54, 3, 50, 50, 55, 3, 50, 50, 56, 3, 50, 50, 57, 3, 50, 51, 48, 3, 50, 51, 49, 3, 50, 51, 50, 3, 50, 51, 51, 3, 50, 51, 52, 3, 50, 51, 53, 3, 50, 51, 54, 3, 50, 51, 55, 3, 50, 51, 56, 3, 50, 51, 57, 3, 50, 52, 48, 3, 50, 52, 49, 3, 50, 52, 50, 3, 50, 52, 51, 3, 50, 52, 52, 3, 50, 52, 53, 3, 50, 52, 54, 3, 50, 52, 55, 3, 50, 52, 56, 3, 50, 52, 57, 3, 50, 53, 48, 3, 50, 53, 49, 3, 50, 53, 50, 3, 50, 53, 51, 3, 50, 53, 52, 3, 50, 53, 53, 3, 50, 53, 54, 3, 50, 53, 55, 3, 50, 53, 56, 3, 50, 53, 57, 3, 50, 54, 48, 3, 50, 54, 49, 3, 50, 54, 50, 3, 50, 54, 51, 3, 50, 54, 52, 3, 50, 54, 53, 3, 50, 54, 54, 3, 50, 54, 55, 3, 50, 54, 56, 3, 50, 54, 57, 3, 50, 55, 48, 3, 50, 55, 49, 3, 50, 55, 50, 3, 50, 55, 51, 3, 50, 55, 52, 3, 50, 55, 53, 3, 50, 55, 54, 3, 50, 55, 55, 3, 50, 55, 56, 3, 50, 55, 57, 3, 50, 56, 48, 3, 50, 56, 49, 3, 50, 56, 50, 3, 50, 56, 51, 3, 50, 56, 52, 3, 50, 56, 53, 3, 50, 56, 54, 3, 50, 56, 55, 3, 50, 56, 56, 3, 50, 56, 57, 3, 50, 57, 48, 3, 50, 57, 49, 3, 50, 57, 50, 3, 50, 57, 51, 3, 50, 57, 52, 3, 50, 57, 53, 3, 50, 57, 54, 3, 50, 57, 55, 3, 50, 57, 56, 3, 50, 57, 57, 3, 51, 48, 48, 3, 51, 48, 49, 3, 51, 48, 50, 3, 51, 48, 51, 3, 51, 48, 52, 3, 51, 48, 53, 3, 51, 48, 54, 3, 51, 48, 55, 3, 51, 48, 56, 3, 51, 48, 57, 3, 51, 49, 48, 3, 51, 49, 49, 3, 51, 49, 50, 3, 51, 49, 51, 3, 51, 49, 52, 3, 51, 49, 53, 3, 51, 49, 54, 3, 51, 49, 55, 3, 51, 49, 56, 3, 51, 49, 57, 3, 51, 50, 48, 3, 51, 50, 49, 3, 51, 50, 50, 3, 51, 50, 51, 3, 51, 50, 52, 3, 51, 50, 53, 3, 51, 50, 54, 3, 51, 50, 55, 3, 51, 50, 56, 3, 51, 50, 57, 3, 51, 51, 48, 3, 51, 51, 49, 3, 51, 51, 50, 3, 51, 51, 51, 3, 51, 51, 52, 3, 51, 51, 53, 3, 51, 51, 54, 3, 51, 51, 55, 3, 51, 51, 56, 3, 51, 51, 57, 3, 51, 52, 48, 3, 51, 52, 49, 3, 51, 52, 50, 3, 51, 52, 51, 3, 51, 52, 52, 3, 51, 52, 53, 3, 51, 52, 54, 3, 51, 52, 55, 3, 51, 52, 56, 3, 51, 52, 57, 3, 51, 53, 48, 3, 51, 53, 49, 3, 51, 53, 50, 3, 51, 53, 51, 3, 51, 53, 52, 3, 51, 53, 53, 3, 51, 53, 54, 3, 51, 53, 55, 3, 51, 53, 56, 3, 51, 53, 57, 3, 51, 54, 48, 3, 51, 54, 49, 3, 51, 54, 50, 3, 51, 54, 51, 3, 51, 54, 52, 3, 51, 54, 53, 3, 51, 54, 54, 3, 51, 54, 55, 3, 51, 54, 56, 3, 51, 54, 57, 3, 51, 55, 48, 3, 51, 55, 49, 3, 51, 55, 50, 3, 51, 55, 51, 3, 51, 55, 52, 3, 51, 55, 53, 3, 51, 55, 54, 3, 51, 55, 55, 3, 51, 55, 56, 3, 51, 55, 57, 3, 51, 56, 48, 3, 51, 56, 49, 3, 51, 56, 50, 3, 51, 56, 51, 3, 51, 56, 52, 3, 51, 56, 53, 3, 51, 56, 54, 3, 51, 56, 55, 3, 51, 56, 56, 3, 51, 56, 57, 3, 51, 57, 48, 3, 51, 57, 49, 3, 51, 57, 50, 3, 51, 57, 51, 3, 51, 57, 52, 3, 51, 57, 53, 3, 51, 57, 54, 3, 51, 57, 55, 3, 51, 57, 56, 3, 51, 57, 57, 3, 52, 48, 48, 3, 52, 48, 49, 3, 52, 48, 50, 3, 52, 48, 51, 3, 52, 48, 52, 3, 52, 48, 53, 3, 52, 48, 54, 3, 52, 48, 55, 3, 52, 48, 56, 3, 52, 48, 57, 3, 52, 49, 48, 3, 52, 49, 49, 3, 52, 49, 50, 3, 52, 49, 51, 3, 52, 49, 52, 3, 52, 49, 53, 3, 52, 49, 54, 3, 52, 49, 55, 3, 52, 49, 56, 3, 52, 49, 57, 3, 52, 50, 48, 3, 52, 50, 49, 3, 52, 50, 50, 3, 52, 50, 51, 3, 52, 50, 52, 3, 52, 50, 53, 3, 52, 50, 54, 3, 52, 50, 55, 3, 52, 50, 56, 3, 52, 50, 57, 3, 52, 51, 48, 3, 52, 51, 49, 3, 52, 51, 50, 3, 52, 51, 51, 3, 52, 51, 52, 3, 52, 51, 53, 3, 52, 51, 54, 3, 52, 51, 55, 3, 52, 51, 56, 3, 52, 51, 57, 3, 52, 52, 48, 3, 52, 52, 49, 3, 52, 52, 50, 3, 52, 52, 51, 3, 52, 52, 52, 3, 52, 52, 53, 3, 52, 52, 54, 3, 52, 52, 55, 3, 52, 52, 56, 3, 52, 52, 57, 3, 52, 53, 48, 3, 52, 53, 49, 3, 52, 53, 50, 3, 52, 53, 51, 3, 52, 53, 52, 3, 52, 53, 53, 3, 52, 53, 54, 3, 52, 53, 55, 3, 52, 53, 56, 3, 52, 53, 57, 3, 52, 54, 48, 3, 52, 54, 49, 3, 52, 54, 50, 3, 52, 54, 51, 3, 52, 54, 52, 3, 52, 54, 53, 3, 52, 54, 54, 3, 52, 54, 55, 3, 52, 54, 56, 3, 52, 54, 57, 3, 52, 55, 48, 3, 52, 55, 49, 3, 52, 55, 50, 3, 52, 55, 51, 3, 52, 55, 52, 3, 52, 55, 53, 3, 52, 55, 54, 3, 52, 55, 55, 3, 52, 55, 56, 3, 52, 55, 57, 3, 52, 56, 48, 3, 52, 56, 49, 3, 52, 56, 50, 3, 52, 56, 51, 3, 52, 56, 52, 3, 52, 56, 53, 3, 52, 56, 54, 3, 52, 56, 55, 3, 52, 56, 56, 3, 52, 56, 57, 3, 52, 57, 48, 3, 52, 57, 49, 3, 52, 57, 50, 3, 52, 57, 51, 3, 52, 57, 52, 3, 52, 57, 53, 3, 52, 57, 54, 3, 52, 57, 55, 3, 52, 57, 56, 3, 52, 57, 57, 3, 53, 48, 48}; inline void putints(int X) { auto N = *(n + X); memcpy(di, c + (X << 2), N); di += N; *di++ = ' '; } inline void putint(int X) { auto N = *(n + X); memcpy(di, c + (X << 2), N); di += N; *di++ = '\n'; } inline void putk(int X) { if (X == 0) putchar('0'); int keta = 0; char C[10]; while (X) { *(C + keta) = '0' + X % 10; X /= 10; keta++; } for (int i = keta - 1; i >= 0; i--) putchar(*(C + i)); putchar('\n'); } int main() { int H, W; bool a = 0, b = 0; H = getint(); W = getint(); int k = 0; rep1(i, H) { fread(cn, 1, W << 1, stdin); auto ci = cn; rep1(ii, W - 1) { a ^= *ci & 1; ci += 2; if (a) { k++; putints(i); putints(ii); putints(i); putint(ii + 1); } } if (i != H) { b ^= a ^ (*ci & 1); if (b) { k++; putints(i); putints(W); putints(i + 1); putint(W); } } a = false; } putk(k); fwrite(dn, 1, di - dn, stdout); Would you please return 0; }
replace
27
28
27
28
0
p03263
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (n); i++) #define rep1(i, n) for (int i = 1; i <= (n); i++) #define co(x) cout << (x) << "\n" #define cosp(x) cout << (x) << " " #define ce(x) cerr << (x) << "\n" #define cesp(x) cerr << (x) << " " #define pb push_back #define mp make_pair #define putchar putchar_unlocked #define Would #define you #define please const int cm = 1 << 17; char cn[cm], *ci = cn, ct; inline int getint() { int A = 0; while ((ct = *ci++) >= '0') A = A * 10 + ct - '0'; return A; } inline bool getA() { bool A = *ci++ & 1; ci++; return A; } const int dm = 1 << 21; char dn[dm], *di = dn, dt; char c[2004] = { 1, 48, 0, 0, 1, 49, 0, 0, 1, 50, 0, 0, 1, 51, 0, 0, 1, 52, 0, 0, 1, 53, 0, 0, 1, 54, 0, 0, 1, 55, 0, 0, 1, 56, 0, 0, 1, 57, 0, 0, 2, 49, 48, 0, 2, 49, 49, 0, 2, 49, 50, 0, 2, 49, 51, 0, 2, 49, 52, 0, 2, 49, 53, 0, 2, 49, 54, 0, 2, 49, 55, 0, 2, 49, 56, 0, 2, 49, 57, 0, 2, 50, 48, 0, 2, 50, 49, 0, 2, 50, 50, 0, 2, 50, 51, 0, 2, 50, 52, 0, 2, 50, 53, 0, 2, 50, 54, 0, 2, 50, 55, 0, 2, 50, 56, 0, 2, 50, 57, 0, 2, 51, 48, 0, 2, 51, 49, 0, 2, 51, 50, 0, 2, 51, 51, 0, 2, 51, 52, 0, 2, 51, 53, 0, 2, 51, 54, 0, 2, 51, 55, 0, 2, 51, 56, 0, 2, 51, 57, 0, 2, 52, 48, 0, 2, 52, 49, 0, 2, 52, 50, 0, 2, 52, 51, 0, 2, 52, 52, 0, 2, 52, 53, 0, 2, 52, 54, 0, 2, 52, 55, 0, 2, 52, 56, 0, 2, 52, 57, 0, 2, 53, 48, 0, 2, 53, 49, 0, 2, 53, 50, 0, 2, 53, 51, 0, 2, 53, 52, 0, 2, 53, 53, 0, 2, 53, 54, 0, 2, 53, 55, 0, 2, 53, 56, 0, 2, 53, 57, 0, 2, 54, 48, 0, 2, 54, 49, 0, 2, 54, 50, 0, 2, 54, 51, 0, 2, 54, 52, 0, 2, 54, 53, 0, 2, 54, 54, 0, 2, 54, 55, 0, 2, 54, 56, 0, 2, 54, 57, 0, 2, 55, 48, 0, 2, 55, 49, 0, 2, 55, 50, 0, 2, 55, 51, 0, 2, 55, 52, 0, 2, 55, 53, 0, 2, 55, 54, 0, 2, 55, 55, 0, 2, 55, 56, 0, 2, 55, 57, 0, 2, 56, 48, 0, 2, 56, 49, 0, 2, 56, 50, 0, 2, 56, 51, 0, 2, 56, 52, 0, 2, 56, 53, 0, 2, 56, 54, 0, 2, 56, 55, 0, 2, 56, 56, 0, 2, 56, 57, 0, 2, 57, 48, 0, 2, 57, 49, 0, 2, 57, 50, 0, 2, 57, 51, 0, 2, 57, 52, 0, 2, 57, 53, 0, 2, 57, 54, 0, 2, 57, 55, 0, 2, 57, 56, 0, 2, 57, 57, 0, 3, 49, 48, 48, 3, 49, 48, 49, 3, 49, 48, 50, 3, 49, 48, 51, 3, 49, 48, 52, 3, 49, 48, 53, 3, 49, 48, 54, 3, 49, 48, 55, 3, 49, 48, 56, 3, 49, 48, 57, 3, 49, 49, 48, 3, 49, 49, 49, 3, 49, 49, 50, 3, 49, 49, 51, 3, 49, 49, 52, 3, 49, 49, 53, 3, 49, 49, 54, 3, 49, 49, 55, 3, 49, 49, 56, 3, 49, 49, 57, 3, 49, 50, 48, 3, 49, 50, 49, 3, 49, 50, 50, 3, 49, 50, 51, 3, 49, 50, 52, 3, 49, 50, 53, 3, 49, 50, 54, 3, 49, 50, 55, 3, 49, 50, 56, 3, 49, 50, 57, 3, 49, 51, 48, 3, 49, 51, 49, 3, 49, 51, 50, 3, 49, 51, 51, 3, 49, 51, 52, 3, 49, 51, 53, 3, 49, 51, 54, 3, 49, 51, 55, 3, 49, 51, 56, 3, 49, 51, 57, 3, 49, 52, 48, 3, 49, 52, 49, 3, 49, 52, 50, 3, 49, 52, 51, 3, 49, 52, 52, 3, 49, 52, 53, 3, 49, 52, 54, 3, 49, 52, 55, 3, 49, 52, 56, 3, 49, 52, 57, 3, 49, 53, 48, 3, 49, 53, 49, 3, 49, 53, 50, 3, 49, 53, 51, 3, 49, 53, 52, 3, 49, 53, 53, 3, 49, 53, 54, 3, 49, 53, 55, 3, 49, 53, 56, 3, 49, 53, 57, 3, 49, 54, 48, 3, 49, 54, 49, 3, 49, 54, 50, 3, 49, 54, 51, 3, 49, 54, 52, 3, 49, 54, 53, 3, 49, 54, 54, 3, 49, 54, 55, 3, 49, 54, 56, 3, 49, 54, 57, 3, 49, 55, 48, 3, 49, 55, 49, 3, 49, 55, 50, 3, 49, 55, 51, 3, 49, 55, 52, 3, 49, 55, 53, 3, 49, 55, 54, 3, 49, 55, 55, 3, 49, 55, 56, 3, 49, 55, 57, 3, 49, 56, 48, 3, 49, 56, 49, 3, 49, 56, 50, 3, 49, 56, 51, 3, 49, 56, 52, 3, 49, 56, 53, 3, 49, 56, 54, 3, 49, 56, 55, 3, 49, 56, 56, 3, 49, 56, 57, 3, 49, 57, 48, 3, 49, 57, 49, 3, 49, 57, 50, 3, 49, 57, 51, 3, 49, 57, 52, 3, 49, 57, 53, 3, 49, 57, 54, 3, 49, 57, 55, 3, 49, 57, 56, 3, 49, 57, 57, 3, 50, 48, 48, 3, 50, 48, 49, 3, 50, 48, 50, 3, 50, 48, 51, 3, 50, 48, 52, 3, 50, 48, 53, 3, 50, 48, 54, 3, 50, 48, 55, 3, 50, 48, 56, 3, 50, 48, 57, 3, 50, 49, 48, 3, 50, 49, 49, 3, 50, 49, 50, 3, 50, 49, 51, 3, 50, 49, 52, 3, 50, 49, 53, 3, 50, 49, 54, 3, 50, 49, 55, 3, 50, 49, 56, 3, 50, 49, 57, 3, 50, 50, 48, 3, 50, 50, 49, 3, 50, 50, 50, 3, 50, 50, 51, 3, 50, 50, 52, 3, 50, 50, 53, 3, 50, 50, 54, 3, 50, 50, 55, 3, 50, 50, 56, 3, 50, 50, 57, 3, 50, 51, 48, 3, 50, 51, 49, 3, 50, 51, 50, 3, 50, 51, 51, 3, 50, 51, 52, 3, 50, 51, 53, 3, 50, 51, 54, 3, 50, 51, 55, 3, 50, 51, 56, 3, 50, 51, 57, 3, 50, 52, 48, 3, 50, 52, 49, 3, 50, 52, 50, 3, 50, 52, 51, 3, 50, 52, 52, 3, 50, 52, 53, 3, 50, 52, 54, 3, 50, 52, 55, 3, 50, 52, 56, 3, 50, 52, 57, 3, 50, 53, 48, 3, 50, 53, 49, 3, 50, 53, 50, 3, 50, 53, 51, 3, 50, 53, 52, 3, 50, 53, 53, 3, 50, 53, 54, 3, 50, 53, 55, 3, 50, 53, 56, 3, 50, 53, 57, 3, 50, 54, 48, 3, 50, 54, 49, 3, 50, 54, 50, 3, 50, 54, 51, 3, 50, 54, 52, 3, 50, 54, 53, 3, 50, 54, 54, 3, 50, 54, 55, 3, 50, 54, 56, 3, 50, 54, 57, 3, 50, 55, 48, 3, 50, 55, 49, 3, 50, 55, 50, 3, 50, 55, 51, 3, 50, 55, 52, 3, 50, 55, 53, 3, 50, 55, 54, 3, 50, 55, 55, 3, 50, 55, 56, 3, 50, 55, 57, 3, 50, 56, 48, 3, 50, 56, 49, 3, 50, 56, 50, 3, 50, 56, 51, 3, 50, 56, 52, 3, 50, 56, 53, 3, 50, 56, 54, 3, 50, 56, 55, 3, 50, 56, 56, 3, 50, 56, 57, 3, 50, 57, 48, 3, 50, 57, 49, 3, 50, 57, 50, 3, 50, 57, 51, 3, 50, 57, 52, 3, 50, 57, 53, 3, 50, 57, 54, 3, 50, 57, 55, 3, 50, 57, 56, 3, 50, 57, 57, 3, 51, 48, 48, 3, 51, 48, 49, 3, 51, 48, 50, 3, 51, 48, 51, 3, 51, 48, 52, 3, 51, 48, 53, 3, 51, 48, 54, 3, 51, 48, 55, 3, 51, 48, 56, 3, 51, 48, 57, 3, 51, 49, 48, 3, 51, 49, 49, 3, 51, 49, 50, 3, 51, 49, 51, 3, 51, 49, 52, 3, 51, 49, 53, 3, 51, 49, 54, 3, 51, 49, 55, 3, 51, 49, 56, 3, 51, 49, 57, 3, 51, 50, 48, 3, 51, 50, 49, 3, 51, 50, 50, 3, 51, 50, 51, 3, 51, 50, 52, 3, 51, 50, 53, 3, 51, 50, 54, 3, 51, 50, 55, 3, 51, 50, 56, 3, 51, 50, 57, 3, 51, 51, 48, 3, 51, 51, 49, 3, 51, 51, 50, 3, 51, 51, 51, 3, 51, 51, 52, 3, 51, 51, 53, 3, 51, 51, 54, 3, 51, 51, 55, 3, 51, 51, 56, 3, 51, 51, 57, 3, 51, 52, 48, 3, 51, 52, 49, 3, 51, 52, 50, 3, 51, 52, 51, 3, 51, 52, 52, 3, 51, 52, 53, 3, 51, 52, 54, 3, 51, 52, 55, 3, 51, 52, 56, 3, 51, 52, 57, 3, 51, 53, 48, 3, 51, 53, 49, 3, 51, 53, 50, 3, 51, 53, 51, 3, 51, 53, 52, 3, 51, 53, 53, 3, 51, 53, 54, 3, 51, 53, 55, 3, 51, 53, 56, 3, 51, 53, 57, 3, 51, 54, 48, 3, 51, 54, 49, 3, 51, 54, 50, 3, 51, 54, 51, 3, 51, 54, 52, 3, 51, 54, 53, 3, 51, 54, 54, 3, 51, 54, 55, 3, 51, 54, 56, 3, 51, 54, 57, 3, 51, 55, 48, 3, 51, 55, 49, 3, 51, 55, 50, 3, 51, 55, 51, 3, 51, 55, 52, 3, 51, 55, 53, 3, 51, 55, 54, 3, 51, 55, 55, 3, 51, 55, 56, 3, 51, 55, 57, 3, 51, 56, 48, 3, 51, 56, 49, 3, 51, 56, 50, 3, 51, 56, 51, 3, 51, 56, 52, 3, 51, 56, 53, 3, 51, 56, 54, 3, 51, 56, 55, 3, 51, 56, 56, 3, 51, 56, 57, 3, 51, 57, 48, 3, 51, 57, 49, 3, 51, 57, 50, 3, 51, 57, 51, 3, 51, 57, 52, 3, 51, 57, 53, 3, 51, 57, 54, 3, 51, 57, 55, 3, 51, 57, 56, 3, 51, 57, 57, 3, 52, 48, 48, 3, 52, 48, 49, 3, 52, 48, 50, 3, 52, 48, 51, 3, 52, 48, 52, 3, 52, 48, 53, 3, 52, 48, 54, 3, 52, 48, 55, 3, 52, 48, 56, 3, 52, 48, 57, 3, 52, 49, 48, 3, 52, 49, 49, 3, 52, 49, 50, 3, 52, 49, 51, 3, 52, 49, 52, 3, 52, 49, 53, 3, 52, 49, 54, 3, 52, 49, 55, 3, 52, 49, 56, 3, 52, 49, 57, 3, 52, 50, 48, 3, 52, 50, 49, 3, 52, 50, 50, 3, 52, 50, 51, 3, 52, 50, 52, 3, 52, 50, 53, 3, 52, 50, 54, 3, 52, 50, 55, 3, 52, 50, 56, 3, 52, 50, 57, 3, 52, 51, 48, 3, 52, 51, 49, 3, 52, 51, 50, 3, 52, 51, 51, 3, 52, 51, 52, 3, 52, 51, 53, 3, 52, 51, 54, 3, 52, 51, 55, 3, 52, 51, 56, 3, 52, 51, 57, 3, 52, 52, 48, 3, 52, 52, 49, 3, 52, 52, 50, 3, 52, 52, 51, 3, 52, 52, 52, 3, 52, 52, 53, 3, 52, 52, 54, 3, 52, 52, 55, 3, 52, 52, 56, 3, 52, 52, 57, 3, 52, 53, 48, 3, 52, 53, 49, 3, 52, 53, 50, 3, 52, 53, 51, 3, 52, 53, 52, 3, 52, 53, 53, 3, 52, 53, 54, 3, 52, 53, 55, 3, 52, 53, 56, 3, 52, 53, 57, 3, 52, 54, 48, 3, 52, 54, 49, 3, 52, 54, 50, 3, 52, 54, 51, 3, 52, 54, 52, 3, 52, 54, 53, 3, 52, 54, 54, 3, 52, 54, 55, 3, 52, 54, 56, 3, 52, 54, 57, 3, 52, 55, 48, 3, 52, 55, 49, 3, 52, 55, 50, 3, 52, 55, 51, 3, 52, 55, 52, 3, 52, 55, 53, 3, 52, 55, 54, 3, 52, 55, 55, 3, 52, 55, 56, 3, 52, 55, 57, 3, 52, 56, 48, 3, 52, 56, 49, 3, 52, 56, 50, 3, 52, 56, 51, 3, 52, 56, 52, 3, 52, 56, 53, 3, 52, 56, 54, 3, 52, 56, 55, 3, 52, 56, 56, 3, 52, 56, 57, 3, 52, 57, 48, 3, 52, 57, 49, 3, 52, 57, 50, 3, 52, 57, 51, 3, 52, 57, 52, 3, 52, 57, 53, 3, 52, 57, 54, 3, 52, 57, 55, 3, 52, 57, 56, 3, 52, 57, 57, 3, 53, 48, 48}; inline void putints(int X) { auto n = c + 4 * X; for (auto itr = n + 1; itr != n + *n + 1; itr++) { *di++ = *itr; } *di++ = ' '; } inline void putint(int X) { auto n = c + 4 * X; for (auto itr = n + 1; itr != n + *n + 1; itr++) { *di++ = *itr; } *di++ = '\n'; } inline void putk(int X) { if (X == 0) putchar('0'); int keta = 0; char C[10]; while (X) { *(C + keta) = '0' + X % 10; X /= 10; keta++; } for (int i = keta - 1; i >= 0; i--) putchar(*(C + i)); putchar('\n'); } int main() { fread(cn, 1, cm, stdin); ci = cn; int H, W; bool a = 0, b = 0; H = getint(); W = getint(); int k = 0; rep1(i, H) { rep1(ii, W - 1) { a ^= getA(); if (a) { k++; putints(i); putints(ii); putints(i); putint(ii + 1); } } if (i != H) { b ^= a ^ getA(); if (b) { k++; putints(i); putints(W); putints(i + 1); putint(W); } } a = false; } putk(k); fwrite(dn, 1, di - dn, stdout); Would you please return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (n); i++) #define rep1(i, n) for (int i = 1; i <= (n); i++) #define co(x) cout << (x) << "\n" #define cosp(x) cout << (x) << " " #define ce(x) cerr << (x) << "\n" #define cesp(x) cerr << (x) << " " #define pb push_back #define mp make_pair #define putchar putchar_unlocked #define Would #define you #define please const int cm = 1 << 19; char cn[cm], *ci = cn, ct; inline int getint() { int A = 0; while ((ct = *ci++) >= '0') A = A * 10 + ct - '0'; return A; } inline bool getA() { bool A = *ci++ & 1; ci++; return A; } const int dm = 1 << 21; char dn[dm], *di = dn, dt; char c[2004] = { 1, 48, 0, 0, 1, 49, 0, 0, 1, 50, 0, 0, 1, 51, 0, 0, 1, 52, 0, 0, 1, 53, 0, 0, 1, 54, 0, 0, 1, 55, 0, 0, 1, 56, 0, 0, 1, 57, 0, 0, 2, 49, 48, 0, 2, 49, 49, 0, 2, 49, 50, 0, 2, 49, 51, 0, 2, 49, 52, 0, 2, 49, 53, 0, 2, 49, 54, 0, 2, 49, 55, 0, 2, 49, 56, 0, 2, 49, 57, 0, 2, 50, 48, 0, 2, 50, 49, 0, 2, 50, 50, 0, 2, 50, 51, 0, 2, 50, 52, 0, 2, 50, 53, 0, 2, 50, 54, 0, 2, 50, 55, 0, 2, 50, 56, 0, 2, 50, 57, 0, 2, 51, 48, 0, 2, 51, 49, 0, 2, 51, 50, 0, 2, 51, 51, 0, 2, 51, 52, 0, 2, 51, 53, 0, 2, 51, 54, 0, 2, 51, 55, 0, 2, 51, 56, 0, 2, 51, 57, 0, 2, 52, 48, 0, 2, 52, 49, 0, 2, 52, 50, 0, 2, 52, 51, 0, 2, 52, 52, 0, 2, 52, 53, 0, 2, 52, 54, 0, 2, 52, 55, 0, 2, 52, 56, 0, 2, 52, 57, 0, 2, 53, 48, 0, 2, 53, 49, 0, 2, 53, 50, 0, 2, 53, 51, 0, 2, 53, 52, 0, 2, 53, 53, 0, 2, 53, 54, 0, 2, 53, 55, 0, 2, 53, 56, 0, 2, 53, 57, 0, 2, 54, 48, 0, 2, 54, 49, 0, 2, 54, 50, 0, 2, 54, 51, 0, 2, 54, 52, 0, 2, 54, 53, 0, 2, 54, 54, 0, 2, 54, 55, 0, 2, 54, 56, 0, 2, 54, 57, 0, 2, 55, 48, 0, 2, 55, 49, 0, 2, 55, 50, 0, 2, 55, 51, 0, 2, 55, 52, 0, 2, 55, 53, 0, 2, 55, 54, 0, 2, 55, 55, 0, 2, 55, 56, 0, 2, 55, 57, 0, 2, 56, 48, 0, 2, 56, 49, 0, 2, 56, 50, 0, 2, 56, 51, 0, 2, 56, 52, 0, 2, 56, 53, 0, 2, 56, 54, 0, 2, 56, 55, 0, 2, 56, 56, 0, 2, 56, 57, 0, 2, 57, 48, 0, 2, 57, 49, 0, 2, 57, 50, 0, 2, 57, 51, 0, 2, 57, 52, 0, 2, 57, 53, 0, 2, 57, 54, 0, 2, 57, 55, 0, 2, 57, 56, 0, 2, 57, 57, 0, 3, 49, 48, 48, 3, 49, 48, 49, 3, 49, 48, 50, 3, 49, 48, 51, 3, 49, 48, 52, 3, 49, 48, 53, 3, 49, 48, 54, 3, 49, 48, 55, 3, 49, 48, 56, 3, 49, 48, 57, 3, 49, 49, 48, 3, 49, 49, 49, 3, 49, 49, 50, 3, 49, 49, 51, 3, 49, 49, 52, 3, 49, 49, 53, 3, 49, 49, 54, 3, 49, 49, 55, 3, 49, 49, 56, 3, 49, 49, 57, 3, 49, 50, 48, 3, 49, 50, 49, 3, 49, 50, 50, 3, 49, 50, 51, 3, 49, 50, 52, 3, 49, 50, 53, 3, 49, 50, 54, 3, 49, 50, 55, 3, 49, 50, 56, 3, 49, 50, 57, 3, 49, 51, 48, 3, 49, 51, 49, 3, 49, 51, 50, 3, 49, 51, 51, 3, 49, 51, 52, 3, 49, 51, 53, 3, 49, 51, 54, 3, 49, 51, 55, 3, 49, 51, 56, 3, 49, 51, 57, 3, 49, 52, 48, 3, 49, 52, 49, 3, 49, 52, 50, 3, 49, 52, 51, 3, 49, 52, 52, 3, 49, 52, 53, 3, 49, 52, 54, 3, 49, 52, 55, 3, 49, 52, 56, 3, 49, 52, 57, 3, 49, 53, 48, 3, 49, 53, 49, 3, 49, 53, 50, 3, 49, 53, 51, 3, 49, 53, 52, 3, 49, 53, 53, 3, 49, 53, 54, 3, 49, 53, 55, 3, 49, 53, 56, 3, 49, 53, 57, 3, 49, 54, 48, 3, 49, 54, 49, 3, 49, 54, 50, 3, 49, 54, 51, 3, 49, 54, 52, 3, 49, 54, 53, 3, 49, 54, 54, 3, 49, 54, 55, 3, 49, 54, 56, 3, 49, 54, 57, 3, 49, 55, 48, 3, 49, 55, 49, 3, 49, 55, 50, 3, 49, 55, 51, 3, 49, 55, 52, 3, 49, 55, 53, 3, 49, 55, 54, 3, 49, 55, 55, 3, 49, 55, 56, 3, 49, 55, 57, 3, 49, 56, 48, 3, 49, 56, 49, 3, 49, 56, 50, 3, 49, 56, 51, 3, 49, 56, 52, 3, 49, 56, 53, 3, 49, 56, 54, 3, 49, 56, 55, 3, 49, 56, 56, 3, 49, 56, 57, 3, 49, 57, 48, 3, 49, 57, 49, 3, 49, 57, 50, 3, 49, 57, 51, 3, 49, 57, 52, 3, 49, 57, 53, 3, 49, 57, 54, 3, 49, 57, 55, 3, 49, 57, 56, 3, 49, 57, 57, 3, 50, 48, 48, 3, 50, 48, 49, 3, 50, 48, 50, 3, 50, 48, 51, 3, 50, 48, 52, 3, 50, 48, 53, 3, 50, 48, 54, 3, 50, 48, 55, 3, 50, 48, 56, 3, 50, 48, 57, 3, 50, 49, 48, 3, 50, 49, 49, 3, 50, 49, 50, 3, 50, 49, 51, 3, 50, 49, 52, 3, 50, 49, 53, 3, 50, 49, 54, 3, 50, 49, 55, 3, 50, 49, 56, 3, 50, 49, 57, 3, 50, 50, 48, 3, 50, 50, 49, 3, 50, 50, 50, 3, 50, 50, 51, 3, 50, 50, 52, 3, 50, 50, 53, 3, 50, 50, 54, 3, 50, 50, 55, 3, 50, 50, 56, 3, 50, 50, 57, 3, 50, 51, 48, 3, 50, 51, 49, 3, 50, 51, 50, 3, 50, 51, 51, 3, 50, 51, 52, 3, 50, 51, 53, 3, 50, 51, 54, 3, 50, 51, 55, 3, 50, 51, 56, 3, 50, 51, 57, 3, 50, 52, 48, 3, 50, 52, 49, 3, 50, 52, 50, 3, 50, 52, 51, 3, 50, 52, 52, 3, 50, 52, 53, 3, 50, 52, 54, 3, 50, 52, 55, 3, 50, 52, 56, 3, 50, 52, 57, 3, 50, 53, 48, 3, 50, 53, 49, 3, 50, 53, 50, 3, 50, 53, 51, 3, 50, 53, 52, 3, 50, 53, 53, 3, 50, 53, 54, 3, 50, 53, 55, 3, 50, 53, 56, 3, 50, 53, 57, 3, 50, 54, 48, 3, 50, 54, 49, 3, 50, 54, 50, 3, 50, 54, 51, 3, 50, 54, 52, 3, 50, 54, 53, 3, 50, 54, 54, 3, 50, 54, 55, 3, 50, 54, 56, 3, 50, 54, 57, 3, 50, 55, 48, 3, 50, 55, 49, 3, 50, 55, 50, 3, 50, 55, 51, 3, 50, 55, 52, 3, 50, 55, 53, 3, 50, 55, 54, 3, 50, 55, 55, 3, 50, 55, 56, 3, 50, 55, 57, 3, 50, 56, 48, 3, 50, 56, 49, 3, 50, 56, 50, 3, 50, 56, 51, 3, 50, 56, 52, 3, 50, 56, 53, 3, 50, 56, 54, 3, 50, 56, 55, 3, 50, 56, 56, 3, 50, 56, 57, 3, 50, 57, 48, 3, 50, 57, 49, 3, 50, 57, 50, 3, 50, 57, 51, 3, 50, 57, 52, 3, 50, 57, 53, 3, 50, 57, 54, 3, 50, 57, 55, 3, 50, 57, 56, 3, 50, 57, 57, 3, 51, 48, 48, 3, 51, 48, 49, 3, 51, 48, 50, 3, 51, 48, 51, 3, 51, 48, 52, 3, 51, 48, 53, 3, 51, 48, 54, 3, 51, 48, 55, 3, 51, 48, 56, 3, 51, 48, 57, 3, 51, 49, 48, 3, 51, 49, 49, 3, 51, 49, 50, 3, 51, 49, 51, 3, 51, 49, 52, 3, 51, 49, 53, 3, 51, 49, 54, 3, 51, 49, 55, 3, 51, 49, 56, 3, 51, 49, 57, 3, 51, 50, 48, 3, 51, 50, 49, 3, 51, 50, 50, 3, 51, 50, 51, 3, 51, 50, 52, 3, 51, 50, 53, 3, 51, 50, 54, 3, 51, 50, 55, 3, 51, 50, 56, 3, 51, 50, 57, 3, 51, 51, 48, 3, 51, 51, 49, 3, 51, 51, 50, 3, 51, 51, 51, 3, 51, 51, 52, 3, 51, 51, 53, 3, 51, 51, 54, 3, 51, 51, 55, 3, 51, 51, 56, 3, 51, 51, 57, 3, 51, 52, 48, 3, 51, 52, 49, 3, 51, 52, 50, 3, 51, 52, 51, 3, 51, 52, 52, 3, 51, 52, 53, 3, 51, 52, 54, 3, 51, 52, 55, 3, 51, 52, 56, 3, 51, 52, 57, 3, 51, 53, 48, 3, 51, 53, 49, 3, 51, 53, 50, 3, 51, 53, 51, 3, 51, 53, 52, 3, 51, 53, 53, 3, 51, 53, 54, 3, 51, 53, 55, 3, 51, 53, 56, 3, 51, 53, 57, 3, 51, 54, 48, 3, 51, 54, 49, 3, 51, 54, 50, 3, 51, 54, 51, 3, 51, 54, 52, 3, 51, 54, 53, 3, 51, 54, 54, 3, 51, 54, 55, 3, 51, 54, 56, 3, 51, 54, 57, 3, 51, 55, 48, 3, 51, 55, 49, 3, 51, 55, 50, 3, 51, 55, 51, 3, 51, 55, 52, 3, 51, 55, 53, 3, 51, 55, 54, 3, 51, 55, 55, 3, 51, 55, 56, 3, 51, 55, 57, 3, 51, 56, 48, 3, 51, 56, 49, 3, 51, 56, 50, 3, 51, 56, 51, 3, 51, 56, 52, 3, 51, 56, 53, 3, 51, 56, 54, 3, 51, 56, 55, 3, 51, 56, 56, 3, 51, 56, 57, 3, 51, 57, 48, 3, 51, 57, 49, 3, 51, 57, 50, 3, 51, 57, 51, 3, 51, 57, 52, 3, 51, 57, 53, 3, 51, 57, 54, 3, 51, 57, 55, 3, 51, 57, 56, 3, 51, 57, 57, 3, 52, 48, 48, 3, 52, 48, 49, 3, 52, 48, 50, 3, 52, 48, 51, 3, 52, 48, 52, 3, 52, 48, 53, 3, 52, 48, 54, 3, 52, 48, 55, 3, 52, 48, 56, 3, 52, 48, 57, 3, 52, 49, 48, 3, 52, 49, 49, 3, 52, 49, 50, 3, 52, 49, 51, 3, 52, 49, 52, 3, 52, 49, 53, 3, 52, 49, 54, 3, 52, 49, 55, 3, 52, 49, 56, 3, 52, 49, 57, 3, 52, 50, 48, 3, 52, 50, 49, 3, 52, 50, 50, 3, 52, 50, 51, 3, 52, 50, 52, 3, 52, 50, 53, 3, 52, 50, 54, 3, 52, 50, 55, 3, 52, 50, 56, 3, 52, 50, 57, 3, 52, 51, 48, 3, 52, 51, 49, 3, 52, 51, 50, 3, 52, 51, 51, 3, 52, 51, 52, 3, 52, 51, 53, 3, 52, 51, 54, 3, 52, 51, 55, 3, 52, 51, 56, 3, 52, 51, 57, 3, 52, 52, 48, 3, 52, 52, 49, 3, 52, 52, 50, 3, 52, 52, 51, 3, 52, 52, 52, 3, 52, 52, 53, 3, 52, 52, 54, 3, 52, 52, 55, 3, 52, 52, 56, 3, 52, 52, 57, 3, 52, 53, 48, 3, 52, 53, 49, 3, 52, 53, 50, 3, 52, 53, 51, 3, 52, 53, 52, 3, 52, 53, 53, 3, 52, 53, 54, 3, 52, 53, 55, 3, 52, 53, 56, 3, 52, 53, 57, 3, 52, 54, 48, 3, 52, 54, 49, 3, 52, 54, 50, 3, 52, 54, 51, 3, 52, 54, 52, 3, 52, 54, 53, 3, 52, 54, 54, 3, 52, 54, 55, 3, 52, 54, 56, 3, 52, 54, 57, 3, 52, 55, 48, 3, 52, 55, 49, 3, 52, 55, 50, 3, 52, 55, 51, 3, 52, 55, 52, 3, 52, 55, 53, 3, 52, 55, 54, 3, 52, 55, 55, 3, 52, 55, 56, 3, 52, 55, 57, 3, 52, 56, 48, 3, 52, 56, 49, 3, 52, 56, 50, 3, 52, 56, 51, 3, 52, 56, 52, 3, 52, 56, 53, 3, 52, 56, 54, 3, 52, 56, 55, 3, 52, 56, 56, 3, 52, 56, 57, 3, 52, 57, 48, 3, 52, 57, 49, 3, 52, 57, 50, 3, 52, 57, 51, 3, 52, 57, 52, 3, 52, 57, 53, 3, 52, 57, 54, 3, 52, 57, 55, 3, 52, 57, 56, 3, 52, 57, 57, 3, 53, 48, 48}; inline void putints(int X) { auto n = c + 4 * X; for (auto itr = n + 1; itr != n + *n + 1; itr++) { *di++ = *itr; } *di++ = ' '; } inline void putint(int X) { auto n = c + 4 * X; for (auto itr = n + 1; itr != n + *n + 1; itr++) { *di++ = *itr; } *di++ = '\n'; } inline void putk(int X) { if (X == 0) putchar('0'); int keta = 0; char C[10]; while (X) { *(C + keta) = '0' + X % 10; X /= 10; keta++; } for (int i = keta - 1; i >= 0; i--) putchar(*(C + i)); putchar('\n'); } int main() { fread(cn, 1, cm, stdin); ci = cn; int H, W; bool a = 0, b = 0; H = getint(); W = getint(); int k = 0; rep1(i, H) { rep1(ii, W - 1) { a ^= getA(); if (a) { k++; putints(i); putints(ii); putints(i); putint(ii + 1); } } if (i != H) { b ^= a ^ getA(); if (b) { k++; putints(i); putints(W); putints(i + 1); putint(W); } } a = false; } putk(k); fwrite(dn, 1, di - dn, stdout); Would you please return 0; }
replace
16
17
16
17
0
p03263
C++
Runtime Error
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <string> #include <vector> using namespace std; int main() { int h, w, bor[510][510], cnt = 0, v[26000][4]; cin >> h >> w; for (int i = 1; i <= h; i++) { for (int j = 1; j <= w; j++) cin >> bor[i][j]; } for (int i = 1; i <= h; i++) { for (int j = 1; j <= w; j++) { if (bor[i][j] % 2 == 1) { if (j != w) { cnt++; v[cnt][0] = i; v[cnt][1] = j; v[cnt][2] = i; v[cnt][3] = j + 1; // cout<<i<<' '<<j<<' '<<i<<' '<<j+1<<'\n'; bor[i][j]--; bor[i][j + 1]++; } else if (i != h) { cnt++; v[cnt][0] = i; v[cnt][1] = j; v[cnt][2] = i + 1; v[cnt][3] = j; // cout<<i<<' '<<j<<' '<<i+1<<' '<<j<<'\n'; bor[i][j]--; bor[i + 1][j]++; } } } } cout << cnt << '\n'; for (int i = 1; i <= cnt; i++) { cout << v[i][0] << ' ' << v[i][1] << ' ' << v[i][2] << ' ' << v[i][3] << '\n'; } return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <string> #include <vector> using namespace std; int main() { int h, w, bor[510][510], cnt = 0, v[260000][4]; cin >> h >> w; for (int i = 1; i <= h; i++) { for (int j = 1; j <= w; j++) cin >> bor[i][j]; } for (int i = 1; i <= h; i++) { for (int j = 1; j <= w; j++) { if (bor[i][j] % 2 == 1) { if (j != w) { cnt++; v[cnt][0] = i; v[cnt][1] = j; v[cnt][2] = i; v[cnt][3] = j + 1; // cout<<i<<' '<<j<<' '<<i<<' '<<j+1<<'\n'; bor[i][j]--; bor[i][j + 1]++; } else if (i != h) { cnt++; v[cnt][0] = i; v[cnt][1] = j; v[cnt][2] = i + 1; v[cnt][3] = j; // cout<<i<<' '<<j<<' '<<i+1<<' '<<j<<'\n'; bor[i][j]--; bor[i + 1][j]++; } } } } cout << cnt << '\n'; for (int i = 1; i <= cnt; i++) { cout << v[i][0] << ' ' << v[i][1] << ' ' << v[i][2] << ' ' << v[i][3] << '\n'; } return 0; }
replace
11
12
11
12
0
p03263
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; int MOD = 1e9 + 7; ll INF = 1e18; int dx[] = {1, -1, 0, 0}; int dy[] = {0, 0, 1, -1}; int main() { int h, w; cin >> h >> w; int a[510][510]; bool visited[510][510]; for (int i = 1; i <= h; i++) { for (int j = 1; j <= w; j++) { cin >> a[i][j]; visited[i][j] = false; } } for (int i = 0; i <= w; i++) a[0][i] = MOD; for (int i = 0; i <= h; i++) a[i][0] = MOD; for (int i = 0; i <= w; i++) a[h + 1][i] = MOD; for (int i = 0; i <= h; i++) a[i][w + 1] = MOD; int ans = 0; vector<int> ans1(100000), ans2(100000), ans3(100000), ans4(100000); for (int i = 1; i <= h; i++) { for (int j = 1; j <= w; j++) { visited[i][j] = true; if (a[i][j] % 2 == 0) continue; bool flag = true; for (int k = 0; k < 4; k++) { int ny = dy[k], nx = dx[k]; if (a[i + ny][j + nx] != MOD && visited[i + ny][j + nx] == false) { if (a[i + ny][j + nx] % 2 == 1) { flag = false; a[i][j]--; a[i + ny][j + nx]++; ans++; ans1[ans] = i, ans2[ans] = j, ans3[ans] = i + ny, ans4[ans] = j + nx; break; } } } if (flag) { if (j != w) { a[i][j]--; a[i][j + 1]++; ans++; ans1[ans] = i, ans2[ans] = j, ans3[ans] = i, ans4[ans] = j + 1; } else if (i != h) { a[i][j]--; a[i + 1][j]++; ans++; ans1[ans] = i, ans2[ans] = j, ans3[ans] = i + 1, ans4[ans] = j; } } } } cout << ans << endl; for (int i = 1; i <= ans; i++) { cout << ans1[i] << " " << ans2[i] << " " << ans3[i] << " " << ans4[i] << endl; } }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; int MOD = 1e9 + 7; ll INF = 1e18; int dx[] = {1, -1, 0, 0}; int dy[] = {0, 0, 1, -1}; int main() { int h, w; cin >> h >> w; int a[510][510]; bool visited[510][510]; for (int i = 1; i <= h; i++) { for (int j = 1; j <= w; j++) { cin >> a[i][j]; visited[i][j] = false; } } for (int i = 0; i <= w; i++) a[0][i] = MOD; for (int i = 0; i <= h; i++) a[i][0] = MOD; for (int i = 0; i <= w; i++) a[h + 1][i] = MOD; for (int i = 0; i <= h; i++) a[i][w + 1] = MOD; int ans = 0; vector<int> ans1(260000), ans2(260000), ans3(260000), ans4(260000); for (int i = 1; i <= h; i++) { for (int j = 1; j <= w; j++) { visited[i][j] = true; if (a[i][j] % 2 == 0) continue; bool flag = true; for (int k = 0; k < 4; k++) { int ny = dy[k], nx = dx[k]; if (a[i + ny][j + nx] != MOD && visited[i + ny][j + nx] == false) { if (a[i + ny][j + nx] % 2 == 1) { flag = false; a[i][j]--; a[i + ny][j + nx]++; ans++; ans1[ans] = i, ans2[ans] = j, ans3[ans] = i + ny, ans4[ans] = j + nx; break; } } } if (flag) { if (j != w) { a[i][j]--; a[i][j + 1]++; ans++; ans1[ans] = i, ans2[ans] = j, ans3[ans] = i, ans4[ans] = j + 1; } else if (i != h) { a[i][j]--; a[i + 1][j]++; ans++; ans1[ans] = i, ans2[ans] = j, ans3[ans] = i + 1, ans4[ans] = j; } } } } cout << ans << endl; for (int i = 1; i <= ans; i++) { cout << ans1[i] << " " << ans2[i] << " " << ans3[i] << " " << ans4[i] << endl; } }
replace
34
35
34
35
0
p03263
C++
Runtime Error
#include <bits/stdc++.h> #include <cinttypes> #include <limits.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> using namespace std; #define countof(a) (sizeof(a) / sizeof(*a)) #define vi vector<int> #define vvi vector<vector<int>> #define vpi vector<pi> #define pi pair<int, int> #define fi first #define se second #define all(n) n.begin(), n.end() #define FOR(var, to) for (register s64 var = 0; var < (s64)to; var++) #define FROMTO(var, from, to) \ for (register s64 var = from; var <= (s64)to; var++) #define INIT(var) FOR(i, countof(var)) var[i] = 0 #define INPUT(var) FOR(i, countof(var)) var[i] = ri() #define SORT(v) qsort(v, countof(v), sizeof(*v), int_less) #define SORTT(v) qsort(v, countof(v), sizeof(*v), int_greater) #define QSORT(v, b) qsort(v, countof(v), sizeof(*v), b) #define MOD 1000000007 #define INF (1 << 30) typedef uint8_t u8; typedef uint16_t u16; typedef uint32_t u32; typedef uint64_t u64; typedef int8_t s8; typedef int16_t s16; typedef int32_t s32; typedef int64_t s64; template <int mod> struct ModInt { int x; ModInt() : x(0) {} ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {} ModInt &operator+=(const ModInt &p) { if ((x += p.x) >= mod) x -= mod; return *this; } ModInt &operator-=(const ModInt &p) { if ((x += mod - p.x) >= mod) x -= mod; return *this; } ModInt &operator*=(const ModInt &p) { x = (int)(1LL * x * p.x % mod); return *this; } ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; } ModInt operator-() const { return ModInt(-x); } ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; } ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; } ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; } ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; } bool operator==(const ModInt &p) const { return x == p.x; } bool operator!=(const ModInt &p) const { return x != p.x; } ModInt inverse() const { int a = x, b = mod, u = 1, v = 0, t; while (b > 0) { t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } return ModInt(u); } friend ostream &operator<<(ostream &os, const ModInt<mod> &p) { return os << p.x; } friend istream &operator>>(istream &is, ModInt<mod> &a) { long long x; is >> x; a = ModInt<mod>(x); return (is); } }; typedef ModInt<MOD> mint; struct UnionFind { vi data; UnionFind(int size) : data(size, -1) {} bool unite(int x, int y) { x = root(x); y = root(y); if (x != y) { if (data[y] < data[x]) swap(x, y); data[x] += data[y]; data[y] = x; } return x != y; } bool find(int x, int y) { return root(x) == root(y); } int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); } int size(int x) { return -data[root(x)]; } bool united() { int comroot = -1; FOR(i, data.size()) { if (comroot != -1 && root(i) != comroot) return false; comroot = root(i); } return true; } }; static inline int ri() { int a; scanf("%d", &a); return a; } static inline s64 rs64() { s64 a; scanf("%" SCNd64, &a); return a; } static inline void wi(int a) { printf("%d", a); } static inline void wu64(u64 a) { printf("%" PRIu64, a); } static inline void ws64(s64 a) { printf("%" PRId64, a); } int int_less(const void *a, const void *b) { return (*((const int *)a) - *((const int *)b)); } int int_greater(const void *a, const void *b) { return (*((const int *)b) - *((const int *)a)); } int main() { int h, w; cin >> h >> w; int a[h][w]; FOR(j, h) INPUT(a[j]); /* FOR(i,h) { FOR(j,w) cout << a[i][j] << " "; cout << endl; }*/ int res1[h * w]; int res2[h * w]; int res3[h * w]; int res4[h * w]; int res = 0; FOR(i, h) { FOR(j, w) { if (a[i][j] % 2) { res1[res] = i + 1; res2[res] = j + 1; a[i][j]--; if (j == w - 1) { res3[res] = i + 2; res4[res] = j + 1; a[i + 1][j]++; } else { res3[res] = i + 1; res4[res] = j + 2; a[i][j + 1]++; } res++; } } } cout << res << endl; FOR(i, res) printf("%d %d %d %d\n", res1[i], res2[i], res3[i], res4[i]); return 0; }
#include <bits/stdc++.h> #include <cinttypes> #include <limits.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> using namespace std; #define countof(a) (sizeof(a) / sizeof(*a)) #define vi vector<int> #define vvi vector<vector<int>> #define vpi vector<pi> #define pi pair<int, int> #define fi first #define se second #define all(n) n.begin(), n.end() #define FOR(var, to) for (register s64 var = 0; var < (s64)to; var++) #define FROMTO(var, from, to) \ for (register s64 var = from; var <= (s64)to; var++) #define INIT(var) FOR(i, countof(var)) var[i] = 0 #define INPUT(var) FOR(i, countof(var)) var[i] = ri() #define SORT(v) qsort(v, countof(v), sizeof(*v), int_less) #define SORTT(v) qsort(v, countof(v), sizeof(*v), int_greater) #define QSORT(v, b) qsort(v, countof(v), sizeof(*v), b) #define MOD 1000000007 #define INF (1 << 30) typedef uint8_t u8; typedef uint16_t u16; typedef uint32_t u32; typedef uint64_t u64; typedef int8_t s8; typedef int16_t s16; typedef int32_t s32; typedef int64_t s64; template <int mod> struct ModInt { int x; ModInt() : x(0) {} ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {} ModInt &operator+=(const ModInt &p) { if ((x += p.x) >= mod) x -= mod; return *this; } ModInt &operator-=(const ModInt &p) { if ((x += mod - p.x) >= mod) x -= mod; return *this; } ModInt &operator*=(const ModInt &p) { x = (int)(1LL * x * p.x % mod); return *this; } ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; } ModInt operator-() const { return ModInt(-x); } ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; } ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; } ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; } ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; } bool operator==(const ModInt &p) const { return x == p.x; } bool operator!=(const ModInt &p) const { return x != p.x; } ModInt inverse() const { int a = x, b = mod, u = 1, v = 0, t; while (b > 0) { t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } return ModInt(u); } friend ostream &operator<<(ostream &os, const ModInt<mod> &p) { return os << p.x; } friend istream &operator>>(istream &is, ModInt<mod> &a) { long long x; is >> x; a = ModInt<mod>(x); return (is); } }; typedef ModInt<MOD> mint; struct UnionFind { vi data; UnionFind(int size) : data(size, -1) {} bool unite(int x, int y) { x = root(x); y = root(y); if (x != y) { if (data[y] < data[x]) swap(x, y); data[x] += data[y]; data[y] = x; } return x != y; } bool find(int x, int y) { return root(x) == root(y); } int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); } int size(int x) { return -data[root(x)]; } bool united() { int comroot = -1; FOR(i, data.size()) { if (comroot != -1 && root(i) != comroot) return false; comroot = root(i); } return true; } }; static inline int ri() { int a; scanf("%d", &a); return a; } static inline s64 rs64() { s64 a; scanf("%" SCNd64, &a); return a; } static inline void wi(int a) { printf("%d", a); } static inline void wu64(u64 a) { printf("%" PRIu64, a); } static inline void ws64(s64 a) { printf("%" PRId64, a); } int int_less(const void *a, const void *b) { return (*((const int *)a) - *((const int *)b)); } int int_greater(const void *a, const void *b) { return (*((const int *)b) - *((const int *)a)); } int main() { int h, w; cin >> h >> w; int a[h][w]; FOR(j, h) INPUT(a[j]); /* FOR(i,h) { FOR(j,w) cout << a[i][j] << " "; cout << endl; }*/ int res1[h * w]; int res2[h * w]; int res3[h * w]; int res4[h * w]; int res = 0; FOR(i, h) { FOR(j, w) { if (i == h - 1 && j == w - 1) continue; if (a[i][j] % 2) { res1[res] = i + 1; res2[res] = j + 1; a[i][j]--; if (j == w - 1) { res3[res] = i + 2; res4[res] = j + 1; a[i + 1][j]++; } else { res3[res] = i + 1; res4[res] = j + 2; a[i][j + 1]++; } res++; } } } cout << res << endl; FOR(i, res) printf("%d %d %d %d\n", res1[i], res2[i], res3[i], res4[i]); return 0; }
insert
166
166
166
168
0
p03263
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)(n); i++) /* */ ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } ll func2(ll n) { ll res = 0; while (n % 2 == 0) { n /= 2; res++; } return res; } ll zyou(ll a, ll b) { // a^b ll res = 1; for (int i = 1; i <= b; i++) { res *= a; } return res; } struct Edge { int to; int weight; Edge(int t, int w) : to(t), weight(w) {} }; typedef pair<int, int> P; using Graph = vector<vector<Edge>>; ll calc(ll a, ll b, ll p) { // aのb乗をpで割った余り if (b == 0) return 1; else if (b % 2 == 0) { ll d = calc(a, b / 2, p); return (d * d) % p; } else if (b % 2 == 1) { return (a * calc(a, b - 1, p)) % p; } } bool is_prime(int n) { // nが素数であるかどうか判定 iで割り切れると素数でない if (n == 1) return false; // 1は例外 for (int i = 2; i * i <= n; i++) { if (n % i == 0) return false; } return true; } int dfs(int x, int y, int H, int W, vector<vector<char>> &masu) { if (masu[x][y] == '#') { } } bool palin(string S) { int n = S.size(); bool flag = true; if (n % 2 == 0) { for (int i = 0; i <= n / 2 - 1; i++) { if (S[i] != S[n - i - 1]) { flag = false; break; } } } else if (n % 2 == 1) { for (int i = 0; i <= n / 2 - 1; i++) { if (S[i] != S[n - i - 1]) { flag = false; break; } } } return flag; } int main() { int H, W; cin >> H >> W; vector<vector<int>> masu(H, vector<int>(W)); rep(i, H) { rep(j, W) { cin >> masu[i][j]; } } vector<vector<int>> ans(250000); int c = 0; rep(i, H) { rep(j, W) { if (i != H - 1) { if (masu[i][j] % 2) { masu[i + 1][j]++; ans[c].push_back(i + 1); ans[c].push_back(j + 1); ans[c].push_back(i + 2); ans[c].push_back(j + 1); c++; } } else if (i == H - 1) { if (masu[i][j] % 2) { masu[i][j + 1]++; ans[c].push_back(i + 1); ans[c].push_back(j + 1); ans[c].push_back(i + 1); ans[c].push_back(j + 2); c++; } } } } cout << c << endl; rep(i, c) { rep(j, 4) { if (j < 3) { cout << ans[i][j] << " "; } else cout << ans[i][j] << endl; } } }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)(n); i++) /* */ ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } ll func2(ll n) { ll res = 0; while (n % 2 == 0) { n /= 2; res++; } return res; } ll zyou(ll a, ll b) { // a^b ll res = 1; for (int i = 1; i <= b; i++) { res *= a; } return res; } struct Edge { int to; int weight; Edge(int t, int w) : to(t), weight(w) {} }; typedef pair<int, int> P; using Graph = vector<vector<Edge>>; ll calc(ll a, ll b, ll p) { // aのb乗をpで割った余り if (b == 0) return 1; else if (b % 2 == 0) { ll d = calc(a, b / 2, p); return (d * d) % p; } else if (b % 2 == 1) { return (a * calc(a, b - 1, p)) % p; } } bool is_prime(int n) { // nが素数であるかどうか判定 iで割り切れると素数でない if (n == 1) return false; // 1は例外 for (int i = 2; i * i <= n; i++) { if (n % i == 0) return false; } return true; } int dfs(int x, int y, int H, int W, vector<vector<char>> &masu) { if (masu[x][y] == '#') { } } bool palin(string S) { int n = S.size(); bool flag = true; if (n % 2 == 0) { for (int i = 0; i <= n / 2 - 1; i++) { if (S[i] != S[n - i - 1]) { flag = false; break; } } } else if (n % 2 == 1) { for (int i = 0; i <= n / 2 - 1; i++) { if (S[i] != S[n - i - 1]) { flag = false; break; } } } return flag; } int main() { int H, W; cin >> H >> W; vector<vector<int>> masu(H, vector<int>(W)); rep(i, H) { rep(j, W) { cin >> masu[i][j]; } } vector<vector<int>> ans(250000); int c = 0; rep(i, H) { rep(j, W) { if (i != H - 1) { if (masu[i][j] % 2) { masu[i + 1][j]++; ans[c].push_back(i + 1); ans[c].push_back(j + 1); ans[c].push_back(i + 2); ans[c].push_back(j + 1); c++; } } else if (i == H - 1) { if (j == W - 1) break; else if (masu[i][j] % 2) { masu[i][j + 1]++; ans[c].push_back(i + 1); ans[c].push_back(j + 1); ans[c].push_back(i + 1); ans[c].push_back(j + 2); c++; } } } } cout << c << endl; rep(i, c) { rep(j, 4) { if (j < 3) { cout << ans[i][j] << " "; } else cout << ans[i][j] << endl; } } }
replace
107
108
107
111
0
p03263
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll mod = 1000000007; int main() { int h, w; cin >> h >> w; vector<vector<int>> a(h, vector<int>(w)); vector<vector<int>> b(h, vector<int>(w)); for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { int x; cin >> x; a[i][j] = x % 2; b[i][j] = a[i][j]; } } int count = 0; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { a[i][j] %= 2; if (a[i][j] == 0) continue; if (i == h - 1 && j == w - 1) break; if (i == h - 1) { a[i][j + 1]++; count++; } else if (a[i][j + 1] % 2 == 0 || i == h - 1) { a[i + 1][j]++; count++; } else { a[i][j + 1]++; count++; } } } cout << count << endl; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { b[i][j] %= 2; if (b[i][j] == 0) continue; if (i == h - 1 && j == w - 1) break; if (i == h - 1) { b[i][j + 1]++; count++; cout << i + 1 << " " << j + 1 << " " << i + 1 << " " << j + 2 << endl; } else if (b[i][j + 1] % 2 == 0 || i == h - 1) { b[i + 1][j]++; count++; cout << i + 1 << " " << j + 1 << " " << i + 2 << " " << j + 1 << endl; } else { b[i][j + 1]++; count++; cout << i + 1 << " " << j + 1 << " " << i + 1 << " " << j + 2 << endl; } } } }
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll mod = 1000000007; int main() { int h, w; cin >> h >> w; vector<vector<int>> a(h + 1, vector<int>(w + 1)); vector<vector<int>> b(h + 1, vector<int>(w + 1)); for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { int x; cin >> x; a[i][j] = x % 2; b[i][j] = a[i][j]; } } int count = 0; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { a[i][j] %= 2; if (a[i][j] == 0) continue; if (i == h - 1 && j == w - 1) break; if (i == h - 1) { a[i][j + 1]++; count++; } else if (a[i][j + 1] % 2 == 0 || i == h - 1) { a[i + 1][j]++; count++; } else { a[i][j + 1]++; count++; } } } cout << count << endl; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { b[i][j] %= 2; if (b[i][j] == 0) continue; if (i == h - 1 && j == w - 1) break; if (i == h - 1) { b[i][j + 1]++; count++; cout << i + 1 << " " << j + 1 << " " << i + 1 << " " << j + 2 << endl; } else if (b[i][j + 1] % 2 == 0 || i == h - 1) { b[i + 1][j]++; count++; cout << i + 1 << " " << j + 1 << " " << i + 2 << " " << j + 1 << endl; } else { b[i][j + 1]++; count++; cout << i + 1 << " " << j + 1 << " " << i + 1 << " " << j + 2 << endl; } } } }
replace
8
10
8
10
0
p03263
C++
Runtime Error
#include <iostream> #include <string> #include <vector> using namespace std; int main() { int a[505][505]; int H, W; vector<string> ans; cin >> H >> W; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { cin >> a[i][j]; } } int x = 0, y = 0; int dx = 1; while (true) { int nx, ny; if (x + dx < 0 || W <= x + dx) { ny = y + 1; dx *= -1; } else { nx = x + dx; ny = y; } if (H <= ny) { break; } if (a[y][x] % 2 == 1) { a[y][x]--; a[ny][nx]++; ans.push_back(to_string(y + 1) + " " + to_string(x + 1) + " " + to_string(ny + 1) + " " + to_string(nx + 1)); } x = nx; y = ny; } cout << ans.size() << endl; for (auto i : ans) { cout << i << endl; } return 0; }
#include <iostream> #include <string> #include <vector> using namespace std; int main() { int a[505][505]; int H, W; vector<string> ans; cin >> H >> W; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { cin >> a[i][j]; } } int x = 0, y = 0; int dx = 1; while (true) { int nx, ny; if (x + dx < 0 || W <= x + dx) { nx = x; ny = y + 1; dx *= -1; } else { nx = x + dx; ny = y; } if (H <= ny) { break; } if (a[y][x] % 2 == 1) { a[y][x]--; a[ny][nx]++; ans.push_back(to_string(y + 1) + " " + to_string(x + 1) + " " + to_string(ny + 1) + " " + to_string(nx + 1)); } x = nx; y = ny; } cout << ans.size() << endl; for (auto i : ans) { cout << i << endl; } return 0; }
insert
25
25
25
26
0
p03263
C++
Runtime Error
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <cstdio> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <random> #include <set> #include <string> #include <unordered_map> #include <vector> using namespace std; //--------------------------------------------------- // ライブラリゾーン!!!! typedef long long ll; typedef long double ld; #define str string #define rep(i, j) for (ll i = 0; i < (long long)(j); i++) #define all(a) (a).begin(), (a).end() const ll Mod = 1000000007; const ll gosenchou = 5000000000000000; short gh[2][4] = {{0, 0, -1, 1}, {-1, 1, 0, 0}}; struct P { ll pos, cost; }; bool operator<(P a, P b) { return a.cost < b.cost; } bool operator>(P a, P b) { return a.cost > b.cost; } struct B { // 隣接リスト表現 ll to, cost; }; struct E { // 辺の情報を入れる変数 ll from, to, cost; }; bool operator<(E a, E b) { return a.cost < b.cost; } struct H { ll x, y; }; bool operator<(H a, H b) { if (a.x != b.x) return a.x < b.x; return a.y < b.y; } bool operator>(H a, H b) { if (a.x != b.x) return a.x > b.x; return a.y > b.y; } bool operator==(H a, H b) { return a.x == b.x && a.y == b.y; } bool operator!=(H a, H b) { return a.x != b.x || a.y != b.y; } ll gcm(ll i, ll j) { // 最大公約数 if (i > j) swap(i, j); if (i == 0) return j; return gcm(j % i, i); } ld rad(H a, H b) { return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0)); } // rad=座標上の2点間の距離 ll ari(ll a, ll b, ll c) { return (a + b) * c / 2; } // 等差数列の和 ll fact(ll x, ll k, ll p) { // 最大値、個数、あまり ll sum = 1; for (int i = 0; i < k; i++) { sum *= (x--); sum %= p; } return sum; } // 階乗(正) ll mod_pow(ll x, ll n, ll p) { ll res = 1; while (n > 0) { if (n & 1) res = res * x % p; x = x * x % p; n >>= 1; } return res; } // x^n%p short ctos(char a) { return (int)(a - '0'); } const long long Inf = 4523372036854775807; const int inf = 15000000000; //---------------------------------------------------- //++++++++++++++++++++++++++++++++++++++++++++++++++++ int a[500][500]; struct A { int a, b, c, d; }; A res[2500]; signed main() { int h, w; cin >> h >> w; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { cin >> a[i][j]; } } int ans = 0; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { if (i == h - 1 && j == w - 1) { break; } if (i == h - 1) { if (a[i][j] % 2 == 1) { a[i][j + 1]++; res[ans] = {i, j, i, j + 1}; ans++; } } else if (j == w - 1) { if (a[i][j] % 2 == 1) { a[i + 1][j]++; res[ans] = {i, j, i + 1, j}; ans++; } } else { if (a[i][j] % 2 == 1) { if (a[i][j] % 2 == 1) { a[i + 1][j]++; res[ans] = {i, j, i + 1, j}; ans++; } else { a[i][j + 1]++; res[ans] = {i, j, i, j + 1}; ans++; } } } } } cout << ans << endl; for (int i = 0; i < ans; i++) { cout << res[i].a + 1 << " " << res[i].b + 1 << " " << res[i].c + 1 << " " << res[i].d + 1 << endl; } }
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <cstdio> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <random> #include <set> #include <string> #include <unordered_map> #include <vector> using namespace std; //--------------------------------------------------- // ライブラリゾーン!!!! typedef long long ll; typedef long double ld; #define str string #define rep(i, j) for (ll i = 0; i < (long long)(j); i++) #define all(a) (a).begin(), (a).end() const ll Mod = 1000000007; const ll gosenchou = 5000000000000000; short gh[2][4] = {{0, 0, -1, 1}, {-1, 1, 0, 0}}; struct P { ll pos, cost; }; bool operator<(P a, P b) { return a.cost < b.cost; } bool operator>(P a, P b) { return a.cost > b.cost; } struct B { // 隣接リスト表現 ll to, cost; }; struct E { // 辺の情報を入れる変数 ll from, to, cost; }; bool operator<(E a, E b) { return a.cost < b.cost; } struct H { ll x, y; }; bool operator<(H a, H b) { if (a.x != b.x) return a.x < b.x; return a.y < b.y; } bool operator>(H a, H b) { if (a.x != b.x) return a.x > b.x; return a.y > b.y; } bool operator==(H a, H b) { return a.x == b.x && a.y == b.y; } bool operator!=(H a, H b) { return a.x != b.x || a.y != b.y; } ll gcm(ll i, ll j) { // 最大公約数 if (i > j) swap(i, j); if (i == 0) return j; return gcm(j % i, i); } ld rad(H a, H b) { return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0)); } // rad=座標上の2点間の距離 ll ari(ll a, ll b, ll c) { return (a + b) * c / 2; } // 等差数列の和 ll fact(ll x, ll k, ll p) { // 最大値、個数、あまり ll sum = 1; for (int i = 0; i < k; i++) { sum *= (x--); sum %= p; } return sum; } // 階乗(正) ll mod_pow(ll x, ll n, ll p) { ll res = 1; while (n > 0) { if (n & 1) res = res * x % p; x = x * x % p; n >>= 1; } return res; } // x^n%p short ctos(char a) { return (int)(a - '0'); } const long long Inf = 4523372036854775807; const int inf = 15000000000; //---------------------------------------------------- //++++++++++++++++++++++++++++++++++++++++++++++++++++ int a[500][500]; struct A { int a, b, c, d; }; A res[250000]; signed main() { int h, w; cin >> h >> w; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { cin >> a[i][j]; } } int ans = 0; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { if (i == h - 1 && j == w - 1) { break; } if (i == h - 1) { if (a[i][j] % 2 == 1) { a[i][j + 1]++; res[ans] = {i, j, i, j + 1}; ans++; } } else if (j == w - 1) { if (a[i][j] % 2 == 1) { a[i + 1][j]++; res[ans] = {i, j, i + 1, j}; ans++; } } else { if (a[i][j] % 2 == 1) { if (a[i][j] % 2 == 1) { a[i + 1][j]++; res[ans] = {i, j, i + 1, j}; ans++; } else { a[i][j + 1]++; res[ans] = {i, j, i, j + 1}; ans++; } } } } } cout << ans << endl; for (int i = 0; i < ans; i++) { cout << res[i].a + 1 << " " << res[i].b + 1 << " " << res[i].c + 1 << " " << res[i].d + 1 << endl; } }
replace
92
93
92
93
0
p03263
Python
Runtime Error
from functools import partial from itertools import islice def take(n, iterable): return list(islice(iterable, n)) def chunked(iterable, n): return iter(partial(take, n, iter(iterable)), []) def solve(s): h, w, *a = map(int, s.split()) (*a,) = chunked(a, w) ans = [] for i in range(h): for j in range(w - 1): if a[i][j] % 2 == 1: ans.append("{} {} {} {}".format(i + 1, j + 1, i + 1, j + 2)) a[i][j + 1] += 1 for i in range(h - 1): if a[i][w - 1] % 2 == 1: ans.append("{} {} {} {}".format(i + 1, w, i + 2, w)) a[i + 1][w - 1] += 1 ans += "{}\n".format(len(ans)) + ans return "\n".join(ans) n, m = map(int, input().split()) print(solve("{} {}\n".format(n, m) + "\n".join([input() for _ in range(n)])))
from functools import partial from itertools import islice def take(n, iterable): return list(islice(iterable, n)) def chunked(iterable, n): return iter(partial(take, n, iter(iterable)), []) def solve(s): h, w, *a = map(int, s.split()) (*a,) = chunked(a, w) ans = [] for i in range(h): for j in range(w - 1): if a[i][j] % 2 == 1: ans.append("{} {} {} {}".format(i + 1, j + 1, i + 1, j + 2)) a[i][j + 1] += 1 for i in range(h - 1): if a[i][w - 1] % 2 == 1: ans.append("{} {} {} {}".format(i + 1, w, i + 2, w)) a[i + 1][w - 1] += 1 return "{}\n".format(len(ans)) + "\n".join(ans) n, m = map(int, input().split()) print(solve("{} {}\n".format(n, m) + "\n".join([input() for _ in range(n)])))
replace
25
27
25
26
TypeError: can only concatenate str (not "list") to str
Traceback (most recent call last): File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03263/Python/s379988073.py", line 31, in <module> print(solve('{} {}\n'.format(n, m) + '\n'.join([input() for _ in range(n)]))) File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03263/Python/s379988073.py", line 26, in solve ans += "{}\n".format(len(ans)) + ans TypeError: can only concatenate str (not "list") to str
p03263
C++
Runtime Error
#define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ALL(v) v.begin(), v.end() typedef long long ll; #include <bits/stdc++.h> using namespace std; int A[510][510]; int B[25100][4]; int main() { int h, w; cin >> h >> w; int x; rep(i, h) { rep(j, w) { cin >> x; A[i + 1][j + 1] = x % 2; } } int k = 0; bool b = false; int tmph, tmpw; for (int i = 1; i <= h; i++) { if (i % 2 == 1) { for (int j = 1; j <= w; j++) { if (b == false && A[i][j] % 2 == 1) { tmph = i, tmpw = j; b = true; } else if (b == true) { B[k][0] = tmph, B[k][1] = tmpw, B[k][2] = i, B[k][3] = j; k++; if (A[i][j] % 2 == 1) b = false; else tmph = i, tmpw = j; } } } else { for (int j = w; j >= 1; j--) { if (b == false && A[i][j] % 2 == 1) { tmph = i, tmpw = j; b = true; } else if (b == true) { B[k][0] = tmph, B[k][1] = tmpw, B[k][2] = i, B[k][3] = j; k++; if (A[i][j] % 2 == 1) b = false; else tmph = i, tmpw = j; } } } } cout << k << endl; rep(i, k) cout << B[i][0] << " " << B[i][1] << " " << B[i][2] << " " << B[i][3] << endl; return 0; }
#define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ALL(v) v.begin(), v.end() typedef long long ll; #include <bits/stdc++.h> using namespace std; int A[510][510]; int B[251000][4]; int main() { int h, w; cin >> h >> w; int x; rep(i, h) { rep(j, w) { cin >> x; A[i + 1][j + 1] = x % 2; } } int k = 0; bool b = false; int tmph, tmpw; for (int i = 1; i <= h; i++) { if (i % 2 == 1) { for (int j = 1; j <= w; j++) { if (b == false && A[i][j] % 2 == 1) { tmph = i, tmpw = j; b = true; } else if (b == true) { B[k][0] = tmph, B[k][1] = tmpw, B[k][2] = i, B[k][3] = j; k++; if (A[i][j] % 2 == 1) b = false; else tmph = i, tmpw = j; } } } else { for (int j = w; j >= 1; j--) { if (b == false && A[i][j] % 2 == 1) { tmph = i, tmpw = j; b = true; } else if (b == true) { B[k][0] = tmph, B[k][1] = tmpw, B[k][2] = i, B[k][3] = j; k++; if (A[i][j] % 2 == 1) b = false; else tmph = i, tmpw = j; } } } } cout << k << endl; rep(i, k) cout << B[i][0] << " " << B[i][1] << " " << B[i][2] << " " << B[i][3] << endl; return 0; }
replace
8
9
8
9
0
p03263
C++
Runtime Error
#define _CRT_SECURE_NO_WARNINGS /* include ***********************/ #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> /* define *************************/ // for #define REP(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++) #define REPS(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++) #define RREP(i, n) for (int i = (int)(n)-1; i >= 0; i--) #define RREPS(i, n) for (int i = (int)(n); i > 0; i--) #define FOR(i, s, n) \ for (int i = (int)(s), i##_len = (int)(n); i < i##_len; i++) // printf #define PRINTD(d) printf("%d\n", (d)) #define PRINTL(d) printf("%lld\n", (d)) // memset #define m0(s) memset(s, 0, sizeof(s)) #define ml(s) memset(s, 63, sizeof(s)) #define fill(s, c) memset(s, c, sizeof(s)) #define INF 1e9 typedef long long ll; int cnt = 0; int ans[500][4]; int a[500][500]; int f[500] = {0}; int diff[4][2] = { {0, -1}, {-1, 0}, {1, 0}, {0, 1}, }; int Min(int a, int b) { return (a) < (b) ? (a) : (b); } ll Max(ll a, ll b) { return (a) > (b) ? (a) : (b); } void Swap(int *a, int *b) { int tmp = *a; *a = *b; *b = tmp; } void hSwap(int x[], int i, int j) { int temp; temp = x[i]; x[i] = x[j]; x[j] = temp; } void ShowData(int x[], int left, int right) { int i; for (i = left; i <= right; i++) printf("%d ", x[i]); printf("\n"); } void QSort(int x[], int left, int right, int n) { int i, j; // 左端,右端 int pivot; // 軸 i = left; j = right; pivot = x[(left + right) / 2]; while (1) { if (n > 0) { // n>0なら昇順、n<=0なら降順 while ((x[i] < pivot) && (i <= right)) i++; // 軸値より大きい要素 while ((pivot < x[j]) && (i <= right)) j--; // 軸値より小さい要素 } else { while ((x[i] > pivot) && (i <= right)) i++; // 軸値より小さい要素 while ((pivot > x[j]) && (i <= right)) j--; // 軸値より大きい要素 } if (i >= j) break; hSwap(x, i, j); i++; j--; } // ShowData(x, left, right); if (left < i - 1) QSort(x, left, i - 1, n); if (j + 1 < right) QSort(x, j + 1, right, n); } void doChangeH(int i, int j) { ans[cnt][0] = i; ans[cnt][1] = j; ans[cnt][2] = i + 1; ans[cnt++][3] = j; a[i][j]--; a[i + 1][j]++; f[i] == 0; f[i + 1] = 1 - f[i + 1]; } void doChangeW(int i, int j) { ans[cnt][0] = i; ans[cnt][1] = j; ans[cnt][2] = i; ans[cnt++][3] = j + 1; a[i][j]--; a[i][j + 1]++; } int main() { int h, w; scanf("%d%d", &h, &w); int sum; REP(i, h) { sum = 0; REP(j, w) { scanf("%d", &a[i][j]); sum += a[i][j]; } if (sum % 2 == 1) f[i] = 1; } REP(i, h) { if (f[i] == 1 && i != h - 1) { REP(j, w) { if (a[i][j] % 2 == 1) { doChangeH(i, j); } } } REP(j, w - 1) { if (a[i][j] % 2 == 1) { doChangeW(i, j); } } } PRINTD(cnt); REP(i, cnt) { printf("%d %d %d %d\n", ans[i][0] + 1, ans[i][1] + 1, ans[i][2] + 1, ans[i][3] + 1); } }
#define _CRT_SECURE_NO_WARNINGS /* include ***********************/ #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> /* define *************************/ // for #define REP(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++) #define REPS(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++) #define RREP(i, n) for (int i = (int)(n)-1; i >= 0; i--) #define RREPS(i, n) for (int i = (int)(n); i > 0; i--) #define FOR(i, s, n) \ for (int i = (int)(s), i##_len = (int)(n); i < i##_len; i++) // printf #define PRINTD(d) printf("%d\n", (d)) #define PRINTL(d) printf("%lld\n", (d)) // memset #define m0(s) memset(s, 0, sizeof(s)) #define ml(s) memset(s, 63, sizeof(s)) #define fill(s, c) memset(s, c, sizeof(s)) #define INF 1e9 typedef long long ll; int cnt = 0; int ans[300000][4]; int a[500][500]; int f[500] = {0}; int diff[4][2] = { {0, -1}, {-1, 0}, {1, 0}, {0, 1}, }; int Min(int a, int b) { return (a) < (b) ? (a) : (b); } ll Max(ll a, ll b) { return (a) > (b) ? (a) : (b); } void Swap(int *a, int *b) { int tmp = *a; *a = *b; *b = tmp; } void hSwap(int x[], int i, int j) { int temp; temp = x[i]; x[i] = x[j]; x[j] = temp; } void ShowData(int x[], int left, int right) { int i; for (i = left; i <= right; i++) printf("%d ", x[i]); printf("\n"); } void QSort(int x[], int left, int right, int n) { int i, j; // 左端,右端 int pivot; // 軸 i = left; j = right; pivot = x[(left + right) / 2]; while (1) { if (n > 0) { // n>0なら昇順、n<=0なら降順 while ((x[i] < pivot) && (i <= right)) i++; // 軸値より大きい要素 while ((pivot < x[j]) && (i <= right)) j--; // 軸値より小さい要素 } else { while ((x[i] > pivot) && (i <= right)) i++; // 軸値より小さい要素 while ((pivot > x[j]) && (i <= right)) j--; // 軸値より大きい要素 } if (i >= j) break; hSwap(x, i, j); i++; j--; } // ShowData(x, left, right); if (left < i - 1) QSort(x, left, i - 1, n); if (j + 1 < right) QSort(x, j + 1, right, n); } void doChangeH(int i, int j) { ans[cnt][0] = i; ans[cnt][1] = j; ans[cnt][2] = i + 1; ans[cnt++][3] = j; a[i][j]--; a[i + 1][j]++; f[i] == 0; f[i + 1] = 1 - f[i + 1]; } void doChangeW(int i, int j) { ans[cnt][0] = i; ans[cnt][1] = j; ans[cnt][2] = i; ans[cnt++][3] = j + 1; a[i][j]--; a[i][j + 1]++; } int main() { int h, w; scanf("%d%d", &h, &w); int sum; REP(i, h) { sum = 0; REP(j, w) { scanf("%d", &a[i][j]); sum += a[i][j]; } if (sum % 2 == 1) f[i] = 1; } REP(i, h) { if (f[i] == 1 && i != h - 1) { REP(j, w) { if (a[i][j] % 2 == 1) { doChangeH(i, j); } } } REP(j, w - 1) { if (a[i][j] % 2 == 1) { doChangeW(i, j); } } } PRINTD(cnt); REP(i, cnt) { printf("%d %d %d %d\n", ans[i][0] + 1, ans[i][1] + 1, ans[i][2] + 1, ans[i][3] + 1); } }
replace
30
31
30
31
0
p03263
C++
Runtime Error
#include <algorithm> #include <cmath> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #include <cstdio> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define repc(i, s, n) for (int i = (s); i <= (n); i++) #define rrep(i, n) for (int i = (n)-1; i >= 0; i--) #define rrepc(i, s, n) for (int i = (s); i >= (n); i--) #define swap(a, b, type) \ { \ type _tmp = a; \ a = b; \ b = _tmp; \ } typedef long long ll; typedef unsigned long long ull; struct operation { int y, x, yp, xp; }; int a[501][501]; operation op[250000]; int main() { int H, W, N = 0; cin >> H >> W; repc(i, 1, H) { repc(j, 1, W) { cin >> a[i][j]; } } repc(i, 1, H) { repc(j, 1, W) { if (a[i][j] % 2 != 0) { if (j != W) { op[N].y = i; op[N].x = j; op[N].yp = i; op[N].xp = j + 1; N++; a[i][j]--; a[i][j + 1]++; } else if (1 != H) { op[N].y = i; op[N].x = j; op[N].yp = i + 1; op[N].xp = j; N++; a[i][j]--; a[i + 1][j]++; } } } } cout << N << endl; rep(i, N) printf("%d %d %d %d\n", op[i].y, op[i].x, op[i].yp, op[i].xp); return 0; }
#include <algorithm> #include <cmath> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #include <cstdio> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define repc(i, s, n) for (int i = (s); i <= (n); i++) #define rrep(i, n) for (int i = (n)-1; i >= 0; i--) #define rrepc(i, s, n) for (int i = (s); i >= (n); i--) #define swap(a, b, type) \ { \ type _tmp = a; \ a = b; \ b = _tmp; \ } typedef long long ll; typedef unsigned long long ull; struct operation { int y, x, yp, xp; }; int a[501][501]; operation op[250000]; int main() { int H, W, N = 0; cin >> H >> W; repc(i, 1, H) { repc(j, 1, W) { cin >> a[i][j]; } } repc(i, 1, H) { repc(j, 1, W) { if (a[i][j] % 2 != 0) { if (j != W) { op[N].y = i; op[N].x = j; op[N].yp = i; op[N].xp = j + 1; N++; a[i][j]--; a[i][j + 1]++; } else if (i != H) { op[N].y = i; op[N].x = j; op[N].yp = i + 1; op[N].xp = j; N++; a[i][j]--; a[i + 1][j]++; } } } } cout << N << endl; rep(i, N) printf("%d %d %d %d\n", op[i].y, op[i].x, op[i].yp, op[i].xp); return 0; }
replace
54
55
54
55
0
p03263
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int Matriz[505][505]; int Resultados[505][4]; int main() { int H, W; int aux; scanf("%d %d", &H, &W); for (int i = 0; i < H; ++i) { for (int j = 0; j < W; ++j) { scanf("%d", &aux); Matriz[i][j] = aux; } } int contador = 0; for (int i = 0; i < H; ++i) { for (int j = 0; j < W; ++j) { aux = Matriz[i][j]; if (aux % 2 == 1) { if (j < W - 1) { Matriz[i][j + 1]++; Resultados[contador][0] = i + 1; Resultados[contador][1] = j + 1; Resultados[contador][2] = i + 1; Resultados[contador][3] = j + 2; contador++; } else { if (i < H - 1) { Matriz[i + 1][j]++; Resultados[contador][0] = i + 1; Resultados[contador][1] = j + 1; Resultados[contador][2] = i + 2; Resultados[contador][3] = j + 1; contador++; } } } } } cout << contador << endl; for (int i = 0; i < contador; ++i) { cout << Resultados[i][0] << " " << Resultados[i][1] << " " << Resultados[i][2] << " " << Resultados[i][3] << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int Matriz[505][505]; int Resultados[250005][4]; int main() { int H, W; int aux; scanf("%d %d", &H, &W); for (int i = 0; i < H; ++i) { for (int j = 0; j < W; ++j) { scanf("%d", &aux); Matriz[i][j] = aux; } } int contador = 0; for (int i = 0; i < H; ++i) { for (int j = 0; j < W; ++j) { aux = Matriz[i][j]; if (aux % 2 == 1) { if (j < W - 1) { Matriz[i][j + 1]++; Resultados[contador][0] = i + 1; Resultados[contador][1] = j + 1; Resultados[contador][2] = i + 1; Resultados[contador][3] = j + 2; contador++; } else { if (i < H - 1) { Matriz[i + 1][j]++; Resultados[contador][0] = i + 1; Resultados[contador][1] = j + 1; Resultados[contador][2] = i + 2; Resultados[contador][3] = j + 1; contador++; } } } } } cout << contador << endl; for (int i = 0; i < contador; ++i) { cout << Resultados[i][0] << " " << Resultados[i][1] << " " << Resultados[i][2] << " " << Resultados[i][3] << endl; } return 0; }
replace
4
5
4
5
0
p03263
C++
Runtime Error
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <functional> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <string> #include <unordered_map> #include <utility> #include <vector> using namespace std; #define REP(i, n, m) for (long long int i = (n); i < (m); i++) #define REV(v) for (auto itr = v.rbegin(); itr != v.rend(); itr++) #define ll long long #define ALL(a) (a).begin(), (a).end() #define SORT(v) sort(ALL(v)); #define LAST(v) v[v.size() - 1] #define ZERO(a) memset(a, 0, sizeof(a)); #define MINUS(a) memset(a, -1, sizeof(a)); #define EACH(i, c) \ for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i) #define EXIST(s, e) ((s).find(e) != (s).end()) #define pi pair<int, int> #define MP make_pair #define PB push_back #define EB emplace_back #define IIN(a) \ int a; \ cin >> a; #define LIN(a) \ ll a; \ cin >> a; #define SIN(a) \ string a; \ cin >> a; #define VL(v, n) vector<ll> v(n); #define Read_VL(v, n) \ vector<ll> v(n); \ REP(i, 0, n) cin >> v[i]; #define sumV(v, n) \ Vl(acm, n) REP(i, 0, n) acm[i] = v[i] + (i == 0 ? 0 : acm[i - 1]); #define EPS (1e-10) #define INF 1000000000000LL void YN(bool b) { cout << (b ? "YES" : "NO") << "\n"; } void Yn(bool b) { cout << (b ? "Yes" : "No") << "\n"; } void yn(bool b) { cout << (b ? "yes" : "no") << "\n"; } template <class S> S max(vector<S> &a) { return *max_element(all(a)); } template <class S> S min(vector<S> &a) { return *min_element(all(a)); } template <class T> void puta(T &&t) { cout << t << "\n"; } template <class H, class... T> void puta(H &&h, T &&...t) { cout << h << ' '; puta(t...); } template <class T = ll> struct Graph { int n; vector<vector<tuple<ll, T>>> edge; Graph(int N = 1) : n(N) { edge.resize(n); } void add(ll f, ll t, T c, bool d = false) { edge[f].emplace_back(t, c); if (!d) edge[t].emplace_back(f, c); } void view() { REP(i, 0, n) for (auto &e : edge[i]) puta(i, "=>", get<0>(e), ", cost :", get<1>(e)); } }; bool length_cmp(string &a, string &b) { return a.size() < b.size(); } ll StoLL(string s) { ll num = 0; REP(i, 0, s.size()) { num = num * 10 + (s[i] ^ 48); } return num; } ll CtoLL(char c) { if ('a' <= c && c <= 'z') { return (ll)(c ^ 96); } else if ('A' <= c && c <= 'Z') { return (ll)(c ^ 64); } return 0; } ll MOD = 1000000007; ll dx[4] = {1, 0, -1, 0}; ll dy[4] = {0, 1, 0, -1}; // I ASCII code: '0' = 48; 'A' = 65; 'a' = 97 // // // template <typename T> // class Grid // { // public: // virtual const ll get_width() = 0; // virtual const ll get_height() = 0; // virtual T get_item(const ll x, const ll y) = 0; // // }; // // class util // { // util() = default; // ~util() = default; // // public: // util(const util&) = delete; // util& operator=(const util&) = delete; // util(util&&) = delete; // util& operator=(util&&) = delete; // // template <typename T> // static void for_each(Grid<T> &src, std::function<void(ll, ll, T)> func) // { // for (ll y = 0; y < src.get_height(); y++) // { // for (ll x = 0; x < src.get_width(); x++) // { // T obj = src.get_item(x, y); // func(x, y, obj); // } // } // } // }; // // ll h,w; // class Test : public Grid<ll> // { // // public: // const ll get_width() override // { // return w; // } // // const ll get_height() override // { // return h; // } // // ll get_item(const ll w, const ll h) override // { // LIN(a); // return a; // } // }; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); // Test g; // util::for_each<ll>(g, [](ll x, ll y, ll obj) // { // std::cout << "(" << x << ", " << y << ") : " << obj << std::endl; // // }); // // deque<ll> dq; // REP( i, 0, 100 ){ // dq.push_back( rand() % 100 ); // } // puta( dq.front(), dq.back() ); // dq.pop_front(); // dq.pop_back(); // puta( dq.front(), dq.back() ); // LIN(a) LIN(b) // dq.push_front(a); // dq.push_back(b); // puta( dq.front(), dq.back() ); // deque<ll> dq2 = {1,3,4,5}; // dq.swap(dq2); // dq.shrink_to_fit(); // for( auto x :dq ){ // puta( x ); // } LIN(h) LIN(w) ll grid[w][h]; REP(x, 0, w) { REP(y, 0, h) { cin >> grid[x][y]; } } vector<tuple<ll, ll, ll, ll>> tt; for (ll i = h - 1; i >= 0; i--) { if (i % 2 == 0) { for (ll j = 0; j < w; j++) { if (grid[i][j] % 2 == 1) { grid[i][j]--; if (j + 1 == w) { if (i > 0) { tt.EB(i, j, i - 1, j); grid[i - 1][j]++; } } else { tt.EB(i, j, i, j + 1); grid[i][j + 1]++; } } } } else { for (ll j = w - 1; j >= 0; j--) { if (grid[i][j] % 2 == 1) { grid[i][j]--; if (j == 0) { if (i > 0) { tt.EB(i, j, i - 1, j); grid[i - 1][j]++; } } else { tt.EB(i, j, i, j - 1); grid[i][j - 1]++; } } } } } puta(tt.size()); for (auto &p : tt) { ll a, b, c, d; tie(a, b, c, d) = p; puta(a + 1, b + 1, c + 1, d + 1); } return 0; }
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <functional> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <string> #include <unordered_map> #include <utility> #include <vector> using namespace std; #define REP(i, n, m) for (long long int i = (n); i < (m); i++) #define REV(v) for (auto itr = v.rbegin(); itr != v.rend(); itr++) #define ll long long #define ALL(a) (a).begin(), (a).end() #define SORT(v) sort(ALL(v)); #define LAST(v) v[v.size() - 1] #define ZERO(a) memset(a, 0, sizeof(a)); #define MINUS(a) memset(a, -1, sizeof(a)); #define EACH(i, c) \ for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i) #define EXIST(s, e) ((s).find(e) != (s).end()) #define pi pair<int, int> #define MP make_pair #define PB push_back #define EB emplace_back #define IIN(a) \ int a; \ cin >> a; #define LIN(a) \ ll a; \ cin >> a; #define SIN(a) \ string a; \ cin >> a; #define VL(v, n) vector<ll> v(n); #define Read_VL(v, n) \ vector<ll> v(n); \ REP(i, 0, n) cin >> v[i]; #define sumV(v, n) \ Vl(acm, n) REP(i, 0, n) acm[i] = v[i] + (i == 0 ? 0 : acm[i - 1]); #define EPS (1e-10) #define INF 1000000000000LL void YN(bool b) { cout << (b ? "YES" : "NO") << "\n"; } void Yn(bool b) { cout << (b ? "Yes" : "No") << "\n"; } void yn(bool b) { cout << (b ? "yes" : "no") << "\n"; } template <class S> S max(vector<S> &a) { return *max_element(all(a)); } template <class S> S min(vector<S> &a) { return *min_element(all(a)); } template <class T> void puta(T &&t) { cout << t << "\n"; } template <class H, class... T> void puta(H &&h, T &&...t) { cout << h << ' '; puta(t...); } template <class T = ll> struct Graph { int n; vector<vector<tuple<ll, T>>> edge; Graph(int N = 1) : n(N) { edge.resize(n); } void add(ll f, ll t, T c, bool d = false) { edge[f].emplace_back(t, c); if (!d) edge[t].emplace_back(f, c); } void view() { REP(i, 0, n) for (auto &e : edge[i]) puta(i, "=>", get<0>(e), ", cost :", get<1>(e)); } }; bool length_cmp(string &a, string &b) { return a.size() < b.size(); } ll StoLL(string s) { ll num = 0; REP(i, 0, s.size()) { num = num * 10 + (s[i] ^ 48); } return num; } ll CtoLL(char c) { if ('a' <= c && c <= 'z') { return (ll)(c ^ 96); } else if ('A' <= c && c <= 'Z') { return (ll)(c ^ 64); } return 0; } ll MOD = 1000000007; ll dx[4] = {1, 0, -1, 0}; ll dy[4] = {0, 1, 0, -1}; // I ASCII code: '0' = 48; 'A' = 65; 'a' = 97 // // // template <typename T> // class Grid // { // public: // virtual const ll get_width() = 0; // virtual const ll get_height() = 0; // virtual T get_item(const ll x, const ll y) = 0; // // }; // // class util // { // util() = default; // ~util() = default; // // public: // util(const util&) = delete; // util& operator=(const util&) = delete; // util(util&&) = delete; // util& operator=(util&&) = delete; // // template <typename T> // static void for_each(Grid<T> &src, std::function<void(ll, ll, T)> func) // { // for (ll y = 0; y < src.get_height(); y++) // { // for (ll x = 0; x < src.get_width(); x++) // { // T obj = src.get_item(x, y); // func(x, y, obj); // } // } // } // }; // // ll h,w; // class Test : public Grid<ll> // { // // public: // const ll get_width() override // { // return w; // } // // const ll get_height() override // { // return h; // } // // ll get_item(const ll w, const ll h) override // { // LIN(a); // return a; // } // }; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); // Test g; // util::for_each<ll>(g, [](ll x, ll y, ll obj) // { // std::cout << "(" << x << ", " << y << ") : " << obj << std::endl; // // }); // // deque<ll> dq; // REP( i, 0, 100 ){ // dq.push_back( rand() % 100 ); // } // puta( dq.front(), dq.back() ); // dq.pop_front(); // dq.pop_back(); // puta( dq.front(), dq.back() ); // LIN(a) LIN(b) // dq.push_front(a); // dq.push_back(b); // puta( dq.front(), dq.back() ); // deque<ll> dq2 = {1,3,4,5}; // dq.swap(dq2); // dq.shrink_to_fit(); // for( auto x :dq ){ // puta( x ); // } LIN(h) LIN(w) ll grid[500][500]; REP(i, 0, h) { REP(j, 0, w) { cin >> grid[i][j]; } } vector<tuple<ll, ll, ll, ll>> tt; for (ll i = h - 1; i >= 0; i--) { if (i % 2 == 0) { for (ll j = 0; j < w; j++) { if (grid[i][j] % 2 == 1) { grid[i][j]--; if (j + 1 == w) { if (i > 0) { tt.EB(i, j, i - 1, j); grid[i - 1][j]++; } } else { tt.EB(i, j, i, j + 1); grid[i][j + 1]++; } } } } else { for (ll j = w - 1; j >= 0; j--) { if (grid[i][j] % 2 == 1) { grid[i][j]--; if (j == 0) { if (i > 0) { tt.EB(i, j, i - 1, j); grid[i - 1][j]++; } } else { tt.EB(i, j, i, j - 1); grid[i][j - 1]++; } } } } } puta(tt.size()); for (auto &p : tt) { ll a, b, c, d; tie(a, b, c, d) = p; puta(a + 1, b + 1, c + 1, d + 1); } return 0; }
replace
193
196
193
196
0
p03263
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; struct Edge { int to; // 辺の行き先 int weight; // 辺の重み Edge(int t, int w) : to(t), weight(w) {} }; using Graph = vector<vector<Edge>>; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define reprep(i, j, h, w) rep(i, h) rep(j, w) #define rrep(i, m, n) for (int i = m; i < (int)(n); i++) #define all(x) (x).begin(), (x).end() #define aall(x, n) (x).begin(), (x).begin() + (n) #define VEC(type, name, n) \ std::vector<type> a(n); \ rep(i, n) std::cin >> a[i]; #define pb push_back #define pf push_front #define lb lower_bound #define ub upper_bound #define fi first #define se second #define sum accumulate #define keta fixed << setprecision #define vvector(name, typ, m, n, a) \ vector<vector<typ>> name(m, vector<typ>(n, a)) #define vvvector(name, t, l, m, n, a) \ vector<vector<vector<t>>> name(l, vector<vector<t>>(m, vector<int>(n, a))); typedef long long ll; const int INF = 2000000000; const long INF64 = 1000000000000000ll; const ll MOD = 1000000007LL; typedef unsigned int uint; long ggd(long a, long b) { // 最小公倍数,最大公約数 if (a < b) swap(a, b); if (b == 0) { return a; } return ggd(b, a % b); } int main() { int h, w; std::cin >> h >> w; vvector(a, int, h, w, 0); reprep(i, j, h, w) std::cin >> a[i][j]; std::vector<int> q, ww, e, r; rep(i, h) { rep(j, w) { if (a[i][j] % 2 == 1) { a[i][j + 1]++; q.pb(i + 1); ww.pb(j + 1); e.pb(i + 1); r.pb(j + 2); } } } rep(i, h - 1) { if (a[i][w - 1] % 2 == 1) { a[i + 1][w - 1]++; q.pb(i + 1); ww.pb(w); e.pb(i + 2); r.pb(w); } } std::cout << q.size() << std::endl; rep(i, q.size()) { std::cout << q[i] << ' ' << ww[i] << ' ' << e[i] << ' ' << r[i] << std::endl; } }
#include <bits/stdc++.h> using namespace std; struct Edge { int to; // 辺の行き先 int weight; // 辺の重み Edge(int t, int w) : to(t), weight(w) {} }; using Graph = vector<vector<Edge>>; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define reprep(i, j, h, w) rep(i, h) rep(j, w) #define rrep(i, m, n) for (int i = m; i < (int)(n); i++) #define all(x) (x).begin(), (x).end() #define aall(x, n) (x).begin(), (x).begin() + (n) #define VEC(type, name, n) \ std::vector<type> a(n); \ rep(i, n) std::cin >> a[i]; #define pb push_back #define pf push_front #define lb lower_bound #define ub upper_bound #define fi first #define se second #define sum accumulate #define keta fixed << setprecision #define vvector(name, typ, m, n, a) \ vector<vector<typ>> name(m, vector<typ>(n, a)) #define vvvector(name, t, l, m, n, a) \ vector<vector<vector<t>>> name(l, vector<vector<t>>(m, vector<int>(n, a))); typedef long long ll; const int INF = 2000000000; const long INF64 = 1000000000000000ll; const ll MOD = 1000000007LL; typedef unsigned int uint; long ggd(long a, long b) { // 最小公倍数,最大公約数 if (a < b) swap(a, b); if (b == 0) { return a; } return ggd(b, a % b); } int main() { int h, w; std::cin >> h >> w; vvector(a, int, h, w, 0); reprep(i, j, h, w) std::cin >> a[i][j]; std::vector<int> q, ww, e, r; rep(i, h) { rep(j, w - 1) { if (a[i][j] % 2 == 1) { a[i][j + 1]++; q.pb(i + 1); ww.pb(j + 1); e.pb(i + 1); r.pb(j + 2); } } } rep(i, h - 1) { if (a[i][w - 1] % 2 == 1) { a[i + 1][w - 1]++; q.pb(i + 1); ww.pb(w); e.pb(i + 2); r.pb(w); } } std::cout << q.size() << std::endl; rep(i, q.size()) { std::cout << q[i] << ' ' << ww[i] << ' ' << e[i] << ' ' << r[i] << std::endl; } }
replace
48
49
48
49
0
p03263
C++
Runtime Error
#include <bits/stdc++.h> #define int long long #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; const int MOD = 1e9 + 7; signed main() { cin.tie(nullptr); ios::sync_with_stdio(false); int H, W; cin >> H >> W; int A[H][W]; rep(i, H) { rep(j, W) { cin >> A[i][j]; } } int ans = 0, M = 0; pair<int, int> P[100000]; for (int i = 0; i < H; i++) { for (int j = 0; j < W - 1; j++) { if (A[i][j] % 2 == 1) { P[M].first = i + 1, P[M].second = j + 1; M++; P[M].first = i + 1, P[M].second = j + 2; M++; A[i][j + 1] += A[i][j]; ans++; } } } for (int i = 0; i < H - 1; i++) { if (A[i][W - 1] % 2 == 1) { ans++; P[M].first = i + 1, P[M].second = W; M++; P[M].first = i + 2, P[M].second = W; M++; A[i + 1][W - 1] += A[i][W - 1]; } } cout << ans << endl; for (int i = 0; i < ans; i++) { cout << P[i * 2].first << ' ' << P[i * 2].second << ' '; cout << P[i * 2 + 1].first << ' ' << P[i * 2 + 1].second << endl; } }
#include <bits/stdc++.h> #define int long long #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; const int MOD = 1e9 + 7; signed main() { cin.tie(nullptr); ios::sync_with_stdio(false); int H, W; cin >> H >> W; int A[H][W]; rep(i, H) { rep(j, W) { cin >> A[i][j]; } } int ans = 0, M = 0; pair<int, int> P[300000]; for (int i = 0; i < H; i++) { for (int j = 0; j < W - 1; j++) { if (A[i][j] % 2 == 1) { P[M].first = i + 1, P[M].second = j + 1; M++; P[M].first = i + 1, P[M].second = j + 2; M++; A[i][j + 1] += A[i][j]; ans++; } } } for (int i = 0; i < H - 1; i++) { if (A[i][W - 1] % 2 == 1) { ans++; P[M].first = i + 1, P[M].second = W; M++; P[M].first = i + 2, P[M].second = W; M++; A[i + 1][W - 1] += A[i][W - 1]; } } cout << ans << endl; for (int i = 0; i < ans; i++) { cout << P[i * 2].first << ' ' << P[i * 2].second << ' '; cout << P[i * 2 + 1].first << ' ' << P[i * 2 + 1].second << endl; } }
replace
17
18
17
18
0
p03263
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; #define a first #define b second #define mp make_pair #define rep(i, n) for (ll i = 0; i < n; i++) #define rep1(i, n) for (ll i = 1; i <= n; i++) ll H, W; P change(ll x) { P p; if (((x + W - 1) / W) % 2 == 1) p = mp((x + W - 1) / W, x % (2 * W)); else p = mp((x + W - 1) / W, 2 * W + 1 - x % (2 * W)); return p; } int main() { cin >> H >> W; ll X[501][501]; ll cX[501][501]; rep1(i, H) rep1(j, W) { cin >> X[i][j]; cX[i][j] = X[i][j]; } ll cnt = 0; rep1(i, H * W - 1) { if (cX[change(i).a][change(i).b] % 2 == 1) { cX[change(i).a][change(i).b]--; cX[change(i + 1).a][change(i + 1).b]++; cnt++; } } cout << cnt << endl; rep1(i, H * W - 1) { if (X[change(i).a][change(i).b] % 2 == 1) { X[change(i).a][change(i).b]--; X[change(i + 1).a][change(i + 1).b]++; cout << change(i).a << " " << change(i).b << " " << change(i + 1).a << " " << change(i + 1).b << endl; } } }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; #define a first #define b second #define mp make_pair #define rep(i, n) for (ll i = 0; i < n; i++) #define rep1(i, n) for (ll i = 1; i <= n; i++) ll H, W; P change(ll x) { P p; if (((x + W - 1) / W) % 2 == 1) p = mp((x + W - 1) / W, x % (2 * W)); else p = mp((x + W - 1) / W, (2 * W) - (x - 1) % (2 * W)); return p; } int main() { cin >> H >> W; ll X[501][501]; ll cX[501][501]; rep1(i, H) rep1(j, W) { cin >> X[i][j]; cX[i][j] = X[i][j]; } ll cnt = 0; rep1(i, H * W - 1) { if (cX[change(i).a][change(i).b] % 2 == 1) { cX[change(i).a][change(i).b]--; cX[change(i + 1).a][change(i + 1).b]++; cnt++; } } cout << cnt << endl; rep1(i, H * W - 1) { if (X[change(i).a][change(i).b] % 2 == 1) { X[change(i).a][change(i).b]--; X[change(i + 1).a][change(i + 1).b]++; cout << change(i).a << " " << change(i).b << " " << change(i + 1).a << " " << change(i + 1).b << endl; } } }
replace
16
17
16
17
0
p03263
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define pb push_back using ll = long long; using P = pair<int, int>; int main() { int h, w; cin >> h >> w; vector<vector<int>> A(h, vector<int>(w)); vector<tuple<int, int, int, int>> ans; rep(i, h) rep(j, w) cin >> A[i][j]; for (int i = 0; i < h; ++i) { for (int j = 0; j < w - 1; ++j) { if (A[i][j] % 2 == 1) { A[i][j]--; A[i][j + 1]++; ans.push_back(make_tuple(i, j, i, j + 1)); } } } for (int i = 0; i < h; i++) { if (A[i][w - 1] % 2 == 1) { A[i][w - 1]--; A[i + 1][w - 1]++; ans.push_back(make_tuple(i, w - 1, i + 1, w - 1)); } } cout << ans.size() << endl; for (auto elem : ans) { cout << get<0>(elem) + 1 << " " << get<1>(elem) + 1 << " " << get<2>(elem) + 1 << " " << get<3>(elem) + 1 << endl; } }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define pb push_back using ll = long long; using P = pair<int, int>; int main() { int h, w; cin >> h >> w; vector<vector<int>> A(h, vector<int>(w)); vector<tuple<int, int, int, int>> ans; rep(i, h) rep(j, w) cin >> A[i][j]; for (int i = 0; i < h; ++i) { for (int j = 0; j < w - 1; ++j) { if (A[i][j] % 2 == 1) { A[i][j]--; A[i][j + 1]++; ans.push_back(make_tuple(i, j, i, j + 1)); } } } for (int i = 0; i < h - 1; i++) { if (A[i][w - 1] % 2 == 1) { A[i][w - 1]--; A[i + 1][w - 1]++; ans.push_back(make_tuple(i, w - 1, i + 1, w - 1)); } } cout << ans.size() << endl; for (auto elem : ans) { cout << get<0>(elem) + 1 << " " << get<1>(elem) + 1 << " " << get<2>(elem) + 1 << " " << get<3>(elem) + 1 << endl; } }
replace
24
25
24
25
0
p03263
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; int main() { int x1[maxn], x2[maxn]; int y1[maxn], y2[maxn]; int h, w, a[500][500], i, j, n = 0; scanf("%d%d", &h, &w); for (i = 1; i <= h; i++) { for (j = 1; j <= w; j++) scanf("%d", &a[i][j]); } for (i = 1; i <= h; i++) { for (j = 1; j < w; j++) { if (a[i][j] % 2 == 1) { y1[n] = i; y2[n] = i; x1[n] = j; x2[n] = j + 1; n++; a[i][j]--; a[i][j + 1]++; } } } for (i = 1; i < h; i++) { if (a[i][w] % 2 == 1) { y1[n] = i; y2[n] = i + 1; x1[n] = w; x2[n] = w; n++; a[i][w]--; a[i + 1][w]++; } } printf("%d\n", n); for (i = 0; i < n; i++) printf("%d %d %d %d\n", y1[i], x1[i], y2[i], x2[i]); return 0; }
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; int main() { int x1[maxn], x2[maxn]; int y1[maxn], y2[maxn]; int h, w, a[550][550], i, j, n = 0; scanf("%d%d", &h, &w); for (i = 1; i <= h; i++) { for (j = 1; j <= w; j++) scanf("%d", &a[i][j]); } for (i = 1; i <= h; i++) { for (j = 1; j < w; j++) { if (a[i][j] % 2 == 1) { y1[n] = i; y2[n] = i; x1[n] = j; x2[n] = j + 1; n++; a[i][j]--; a[i][j + 1]++; } } } for (i = 1; i < h; i++) { if (a[i][w] % 2 == 1) { y1[n] = i; y2[n] = i + 1; x1[n] = w; x2[n] = w; n++; a[i][w]--; a[i + 1][w]++; } } printf("%d\n", n); for (i = 0; i < n; i++) printf("%d %d %d %d\n", y1[i], x1[i], y2[i], x2[i]); return 0; }
replace
7
8
7
8
0
p03263
C++
Runtime Error
#include <bits/stdc++.h> #define dum(x) cout << #x << '=' << x << endl #define ll long long using namespace std; bool check(int x) { if (x % 2 == 0) { return true; } else { return false; } } int main() { int h, w; cin >> h >> w; int v[h][w]; for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) { cin >> v[i][j]; } } int rescnt = 0; vector<pair<int, int>> vpin(25000); vector<pair<int, int>> vpout(25000); // 縦判定 for (int i = 0; i < h - 1; ++i) { for (int j = 0; j < w; ++j) { if (check(v[i][j])) { continue; } else { vpin[rescnt] = make_pair(i + 1, j + 1); vpout[rescnt] = make_pair(i + 2, j + 1); rescnt++; v[i][j]--; v[i + 1][j]++; } } } // 横判定 for (int j = 0; j < w - 1; ++j) { if (check(v[h - 1][j])) { continue; } else { vpin[rescnt] = make_pair(h, j + 1); vpout[rescnt] = make_pair(h, j + 2); rescnt++; v[h - 1][j]--; v[h - 1][j + 1]++; } } cout << rescnt << endl; for (int i = 0; i < rescnt; ++i) { cout << vpin[i].first << " " << vpin[i].second << " " << vpout[i].first << " " << vpout[i].second << endl; } }
#include <bits/stdc++.h> #define dum(x) cout << #x << '=' << x << endl #define ll long long using namespace std; bool check(int x) { if (x % 2 == 0) { return true; } else { return false; } } int main() { int h, w; cin >> h >> w; int v[h][w]; for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) { cin >> v[i][j]; } } int rescnt = 0; vector<pair<int, int>> vpin(250000); vector<pair<int, int>> vpout(250000); // 縦判定 for (int i = 0; i < h - 1; ++i) { for (int j = 0; j < w; ++j) { if (check(v[i][j])) { continue; } else { vpin[rescnt] = make_pair(i + 1, j + 1); vpout[rescnt] = make_pair(i + 2, j + 1); rescnt++; v[i][j]--; v[i + 1][j]++; } } } // 横判定 for (int j = 0; j < w - 1; ++j) { if (check(v[h - 1][j])) { continue; } else { vpin[rescnt] = make_pair(h, j + 1); vpout[rescnt] = make_pair(h, j + 2); rescnt++; v[h - 1][j]--; v[h - 1][j + 1]++; } } cout << rescnt << endl; for (int i = 0; i < rescnt; ++i) { cout << vpin[i].first << " " << vpin[i].second << " " << vpout[i].first << " " << vpout[i].second << endl; } }
replace
25
27
25
27
0
p03263
C++
Runtime Error
#pragma GCC optimize("O3") #include <iostream> #include <stdio.h> #include <stdlib.h> #include <string.h> using namespace std; using QWORD = unsigned long long; using SQWORD = long long; using DWORD = unsigned int; using SDWORD = int; using WORD = unsigned short; using SWORD = short; using DOUBLE = double; using FLOAT = float; #define MIN_SDWORD (-2147483648) #define MAX_SDWORD (2147483647) #define ArrayLength(a) (sizeof(a) / sizeof(a[0])) static inline QWORD MAX(QWORD a, QWORD b) { return a > b ? a : b; } static inline DWORD MAX(DWORD a, DWORD b) { return a > b ? a : b; } static inline SDWORD MAX(SDWORD a, SDWORD b) { return a > b ? a : b; } static inline QWORD MIN(QWORD a, QWORD b) { return a < b ? a : b; } static inline DWORD MIN(DWORD a, DWORD b) { return a < b ? a : b; } static inline SDWORD MIN(SDWORD a, SDWORD b) { return a < b ? a : b; } #define BYTE_BITS (8) #define WORD_BITS (16) #define DWORD_BITS (32) #define QWORD_BITS (64) using M_BOOL = bool; #define M_TRUE (true) #define M_FALSE (false) static void printMatrix(DWORD *p, DWORD dwRowNum, DWORD dwColNum) { printf("---\n"); for (DWORD i = 0; i < dwRowNum; i++) { for (DWORD j = 0; j < dwColNum; j++) { printf("%5d", p[i * dwColNum + j]); } cout << endl; } printf("---\n"); } static inline SDWORD inputSDWORD(void) { SDWORD lNumber = 0; M_BOOL bRead = M_FALSE; for (;;) { char c = getchar(); if (('0' <= c) && (c <= '9')) { lNumber *= 10; lNumber += (c - '0'); bRead = M_TRUE; } else { if (bRead) { return lNumber; } } } } int main() { DWORD dwInput_H, dwInput_W; dwInput_H = inputSDWORD(); dwInput_W = inputSDWORD(); /* input coins */ DWORD aadwCoinCount[dwInput_H][dwInput_W]; for (DWORD dwRow = 0; dwRow < dwInput_H; dwRow++) { for (DWORD dwCol = 0; dwCol < dwInput_W; dwCol++) { aadwCoinCount[dwRow][dwCol] = inputSDWORD(); } } DWORD aadwProcedure[dwInput_H * dwInput_W][4]; DWORD dwProcCnt = 0; for (DWORD dwRow = 0; dwRow < dwInput_H; dwRow++) { for (DWORD dwCol = 0; dwCol < dwInput_W - 1; dwCol++) { if (0 != (aadwCoinCount[dwRow][dwCol] % 2)) { aadwProcedure[dwProcCnt][0] = dwRow; aadwProcedure[dwProcCnt][1] = dwCol; aadwProcedure[dwProcCnt][2] = dwRow; aadwProcedure[dwProcCnt][3] = dwCol + 1; dwProcCnt++; aadwCoinCount[dwRow][dwCol]--; aadwCoinCount[dwRow][dwCol + 1]++; } } if (0 != (aadwCoinCount[dwRow][dwInput_W - 1] % 2)) { aadwProcedure[dwProcCnt][0] = dwRow; aadwProcedure[dwProcCnt][1] = dwInput_W - 1; aadwProcedure[dwProcCnt][2] = dwRow + 1; aadwProcedure[dwProcCnt][3] = dwInput_W - 1; dwProcCnt++; aadwCoinCount[dwRow][dwInput_W - 1]--; aadwCoinCount[dwRow + 1][dwInput_W - 1]++; } } printf("%d\n", dwProcCnt); for (DWORD dwIdx = 0; dwIdx < dwProcCnt; dwIdx++) { printf("%d %d %d %d\n", aadwProcedure[dwIdx][0] + 1, aadwProcedure[dwIdx][1] + 1, aadwProcedure[dwIdx][2] + 1, aadwProcedure[dwIdx][3] + 1); } // printMatrix((DWORD*)aadwCoinCount, dwInput_H, dwInput_W); return 0; }
#pragma GCC optimize("O3") #include <iostream> #include <stdio.h> #include <stdlib.h> #include <string.h> using namespace std; using QWORD = unsigned long long; using SQWORD = long long; using DWORD = unsigned int; using SDWORD = int; using WORD = unsigned short; using SWORD = short; using DOUBLE = double; using FLOAT = float; #define MIN_SDWORD (-2147483648) #define MAX_SDWORD (2147483647) #define ArrayLength(a) (sizeof(a) / sizeof(a[0])) static inline QWORD MAX(QWORD a, QWORD b) { return a > b ? a : b; } static inline DWORD MAX(DWORD a, DWORD b) { return a > b ? a : b; } static inline SDWORD MAX(SDWORD a, SDWORD b) { return a > b ? a : b; } static inline QWORD MIN(QWORD a, QWORD b) { return a < b ? a : b; } static inline DWORD MIN(DWORD a, DWORD b) { return a < b ? a : b; } static inline SDWORD MIN(SDWORD a, SDWORD b) { return a < b ? a : b; } #define BYTE_BITS (8) #define WORD_BITS (16) #define DWORD_BITS (32) #define QWORD_BITS (64) using M_BOOL = bool; #define M_TRUE (true) #define M_FALSE (false) static void printMatrix(DWORD *p, DWORD dwRowNum, DWORD dwColNum) { printf("---\n"); for (DWORD i = 0; i < dwRowNum; i++) { for (DWORD j = 0; j < dwColNum; j++) { printf("%5d", p[i * dwColNum + j]); } cout << endl; } printf("---\n"); } static inline SDWORD inputSDWORD(void) { SDWORD lNumber = 0; M_BOOL bRead = M_FALSE; for (;;) { char c = getchar(); if (('0' <= c) && (c <= '9')) { lNumber *= 10; lNumber += (c - '0'); bRead = M_TRUE; } else { if (bRead) { return lNumber; } } } } int main() { DWORD dwInput_H, dwInput_W; dwInput_H = inputSDWORD(); dwInput_W = inputSDWORD(); /* input coins */ DWORD aadwCoinCount[dwInput_H][dwInput_W]; for (DWORD dwRow = 0; dwRow < dwInput_H; dwRow++) { for (DWORD dwCol = 0; dwCol < dwInput_W; dwCol++) { aadwCoinCount[dwRow][dwCol] = inputSDWORD(); } } DWORD aadwProcedure[dwInput_H * dwInput_W][4]; DWORD dwProcCnt = 0; for (DWORD dwRow = 0; dwRow < dwInput_H; dwRow++) { for (DWORD dwCol = 0; dwCol < dwInput_W - 1; dwCol++) { if (0 != (aadwCoinCount[dwRow][dwCol] % 2)) { aadwProcedure[dwProcCnt][0] = dwRow; aadwProcedure[dwProcCnt][1] = dwCol; aadwProcedure[dwProcCnt][2] = dwRow; aadwProcedure[dwProcCnt][3] = dwCol + 1; dwProcCnt++; aadwCoinCount[dwRow][dwCol]--; aadwCoinCount[dwRow][dwCol + 1]++; } } if (dwRow != dwInput_H - 1) { if (0 != (aadwCoinCount[dwRow][dwInput_W - 1] % 2)) { aadwProcedure[dwProcCnt][0] = dwRow; aadwProcedure[dwProcCnt][1] = dwInput_W - 1; aadwProcedure[dwProcCnt][2] = dwRow + 1; aadwProcedure[dwProcCnt][3] = dwInput_W - 1; dwProcCnt++; aadwCoinCount[dwRow][dwInput_W - 1]--; aadwCoinCount[dwRow + 1][dwInput_W - 1]++; } } } printf("%d\n", dwProcCnt); for (DWORD dwIdx = 0; dwIdx < dwProcCnt; dwIdx++) { printf("%d %d %d %d\n", aadwProcedure[dwIdx][0] + 1, aadwProcedure[dwIdx][1] + 1, aadwProcedure[dwIdx][2] + 1, aadwProcedure[dwIdx][3] + 1); } // printMatrix((DWORD*)aadwCoinCount, dwInput_H, dwInput_W); return 0; }
replace
93
101
93
103
0
p03263
C++
Runtime Error
#include <iostream> #include <stdio.h> // #include <bits/stdc++.h> #include <algorithm> #include <cassert> #include <cmath> #include <cstdint> #include <cstring> #include <float.h> #include <iomanip> #include <map> #include <math.h> #include <queue> #include <set> #include <sstream> #include <string> #include <vector> #define INF 1e9 #define LINF 1e19 #define rep(i, n) for (int i = 0; (i) < (int)(n); i++) #define REP(i, a, b) for (int i = (int)(a); (i) <= (int)(b); i++) #define VEC(type, c, n) \ std::vector<type> c(n); \ for (auto &i : c) \ std::cin >> i; #define vec(type, n) vector<type>(n) #define vvec(m, n) vector<vector<int>>(int(m), vector<int>(n)) #define ALL(a) (a).begin(), (a).end() #define chmin(a, b) a = min(a, b) #define chmax(a, b) a = max(a, b) using namespace std; using ll = long long; using Graph = vector<vector<int>>; using P = pair<ll, ll>; using PP = pair<P, P>; const ll MOD = 1e9 + 7; const ll ZER = 0; int main() { int h, w; cin >> h >> w; vector<vector<int>> fld(h, vector<int>(w)); rep(i, h) rep(j, w) cin >> fld[i][j]; queue<PP> que; rep(i, h) { rep(j, w) { if (fld[i][j] % 2 == 0) continue; if (j != w - 1) { que.push(PP(P(i, j), P(i, j + 1))); fld[i][j + 1]++; } else { que.push(PP(P(i, j), P(i + 1, j))); fld[i + 1][j]++; } } } cout << que.size() << endl; while (!que.empty()) { P p = que.front().first, q = que.front().second; int y = p.first, x = p.second, yy = q.first, xx = q.second; que.pop(); y++; x++; yy++; xx++; cout << y << " " << x << " " << yy << " " << xx << endl; } }
#include <iostream> #include <stdio.h> // #include <bits/stdc++.h> #include <algorithm> #include <cassert> #include <cmath> #include <cstdint> #include <cstring> #include <float.h> #include <iomanip> #include <map> #include <math.h> #include <queue> #include <set> #include <sstream> #include <string> #include <vector> #define INF 1e9 #define LINF 1e19 #define rep(i, n) for (int i = 0; (i) < (int)(n); i++) #define REP(i, a, b) for (int i = (int)(a); (i) <= (int)(b); i++) #define VEC(type, c, n) \ std::vector<type> c(n); \ for (auto &i : c) \ std::cin >> i; #define vec(type, n) vector<type>(n) #define vvec(m, n) vector<vector<int>>(int(m), vector<int>(n)) #define ALL(a) (a).begin(), (a).end() #define chmin(a, b) a = min(a, b) #define chmax(a, b) a = max(a, b) using namespace std; using ll = long long; using Graph = vector<vector<int>>; using P = pair<ll, ll>; using PP = pair<P, P>; const ll MOD = 1e9 + 7; const ll ZER = 0; int main() { int h, w; cin >> h >> w; vector<vector<int>> fld(h, vector<int>(w)); rep(i, h) rep(j, w) cin >> fld[i][j]; queue<PP> que; rep(i, h) { rep(j, w) { if (fld[i][j] % 2 == 0) continue; if (j != w - 1) { que.push(PP(P(i, j), P(i, j + 1))); fld[i][j + 1]++; } else if (i != h - 1) { que.push(PP(P(i, j), P(i + 1, j))); fld[i + 1][j]++; } } } cout << que.size() << endl; while (!que.empty()) { P p = que.front().first, q = que.front().second; int y = p.first, x = p.second, yy = q.first, xx = q.second; que.pop(); y++; x++; yy++; xx++; cout << y << " " << x << " " << yy << " " << xx << endl; } }
replace
54
55
54
55
0
p03263
C++
Runtime Error
#include "bits/stdc++.h" using namespace std; using ll = long long; using ld = long double; using pii = pair<int, int>; using vi = vector<int>; using vl = vector<ll>; ld EPS = 1e-12; int INF = numeric_limits<int>::max() / 2; int MOD = 1e9 + 7; #define rep(i, n) for (int i = 0; i < n; i++) #define all(obj) (obj).begin(), (obj).end() #define debug(x) cerr << #x << ": " << x << '\n' int main() { cin.tie(0); ios::sync_with_stdio(false); int h, w; cin >> h >> w; int area[h][w]; rep(i, h) { rep(j, w) { cin >> area[i][j]; } } vector<vi> result(2500, vector<int>(5, 0)); int count = 0; rep(i, h) { rep(j, w) { if (area[i][j] % 2 == 1) { if (j != w - 1) { area[i][j]--; area[i][j + 1]++; result[count][0] = i; result[count][1] = j; result[count][2] = i; result[count][3] = j + 1; count++; } else if (i != h - 1) { area[i][j]--; area[i + 1][j]++; result[count][0] = i; result[count][1] = j; result[count][2] = i + 1; result[count][3] = j; count++; } } } } cout << count << endl; rep(i, count) { cout << result[i][0] + 1 << " " << result[i][1] + 1 << " " << result[i][2] + 1 << " " << result[i][3] + 1 << endl; } return 0; }
#include "bits/stdc++.h" using namespace std; using ll = long long; using ld = long double; using pii = pair<int, int>; using vi = vector<int>; using vl = vector<ll>; ld EPS = 1e-12; int INF = numeric_limits<int>::max() / 2; int MOD = 1e9 + 7; #define rep(i, n) for (int i = 0; i < n; i++) #define all(obj) (obj).begin(), (obj).end() #define debug(x) cerr << #x << ": " << x << '\n' int main() { cin.tie(0); ios::sync_with_stdio(false); int h, w; cin >> h >> w; int area[h][w]; rep(i, h) { rep(j, w) { cin >> area[i][j]; } } vector<vi> result(250010, vector<int>(5, 0)); int count = 0; rep(i, h) { rep(j, w) { if (area[i][j] % 2 == 1) { if (j != w - 1) { area[i][j]--; area[i][j + 1]++; result[count][0] = i; result[count][1] = j; result[count][2] = i; result[count][3] = j + 1; count++; } else if (i != h - 1) { area[i][j]--; area[i + 1][j]++; result[count][0] = i; result[count][1] = j; result[count][2] = i + 1; result[count][3] = j; count++; } } } } cout << count << endl; rep(i, count) { cout << result[i][0] + 1 << " " << result[i][1] + 1 << " " << result[i][2] + 1 << " " << result[i][3] + 1 << endl; } return 0; }
replace
26
27
26
27
0