buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
#include <iostream> #include <map> #include <string> #include <vector> using namespace std; int main() { int H, W, K; cin >> H >> W >> K; vector<string> S(H); for (int i = 0; i < H; ++i) { cin >> S[i]; } map<int, int> group; map<int, int> white; vector<int> bitS; int ans = 10000000; int tmpans...
#include <iostream> #include <map> #include <string> #include <vector> using namespace std; int main() { int H, W, K; cin >> H >> W >> K; vector<string> S(H); for (int i = 0; i < H; ++i) { cin >> S[i]; } map<int, int> group; map<int, int> white; vector<int> bitS; int ans = 10000000; int tmpans...
[["+", 0, 57, 15, 339, 51, 16, 31, 23, 0, 24], ["+", 0, 16, 12, 16, 12, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 67], ["+", 0, 57, 15, 339, 51, 16, 12, 91, 17, 111], ["+", 0, 57, 15, 339, 51, 16, 12, 91, 28, 22]]
1
484
#include <bits/stdc++.h> using namespace std; const int Max = 1e9 + 100; int ara[12][1100]; int n, m, k; int fun(int id, int mask, int mark[], int el) { if (id > m) return 0; int temp[el]; memset(temp, 0, sizeof temp); int last = 1, ct = 0; while (last <= n) { if (ara[last][id] == 1) ++temp[...
#include <bits/stdc++.h> using namespace std; const int Max = 1e9 + 100; int ara[12][1100]; int n, m, k; int fun(int id, int mask, int mark[], int el) { if (id > m) return 0; int temp[el]; memset(temp, 0, sizeof temp); int last = 1, ct = 0; while (last <= n) { if (ara[last][id] == 1) ++temp...
[["-", 12, 23, 0, 16, 12, 23, 0, 16, 12, 13], ["+", 12, 23, 0, 16, 12, 23, 0, 16, 12, 13], ["-", 0, 52, 15, 339, 51, 16, 12, 16, 12, 13], ["+", 0, 52, 15, 339, 51, 16, 12, 16, 12, 147]]
1
533
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; const int INF = 1e9; int c[10][1005]; int main() { int h, w, k; cin >> h >> w >> k; vector<string> s(h); rep(i, h) cin >> s[i]; int ans = INF; rep(div, 1 << (h - 1)) { int g = 0; ve...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; const int INF = 1e9; int c[10][1005]; int main() { int h, w, k; cin >> h >> w >> k; vector<string> s(h); rep(i, h) cin >> s[i]; int ans = INF; rep(div, 1 << (h - 1)) { int g = 0; ve...
[["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 22]]
1
335
#include <bits/stdc++.h> #define ll long long #define double long double #define rep(i, n) for (int i = 0; i < (n); i++) #define REP(i, n) for (int i = 1; i <= (n); i++) #define mod (ll)(1e9 + 7) #define inf (ll)(3e18 + 7) #define pi (double)acos(-1) #define P pair<int, int> #define PiP pair<int, pair<int, int>> #defin...
#include <bits/stdc++.h> #define ll long long #define double long double #define rep(i, n) for (int i = 0; i < (n); i++) #define REP(i, n) for (int i = 1; i <= (n); i++) #define mod (ll)(1e9 + 7) #define inf (ll)(3e18 + 7) #define pi (double)acos(-1) #define P pair<int, int> #define PiP pair<int, pair<int, int>> #defin...
[["-", 15, 16, 12, 23, 0, 16, 12, 23, 0, 24], ["-", 12, 23, 0, 16, 12, 23, 0, 16, 17, 33], ["-", 12, 23, 0, 16, 12, 23, 0, 16, 12, 13], ["-", 15, 16, 12, 23, 0, 16, 12, 23, 0, 25]]
1
542
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <tuple> #include <vector> using namespace std; typedef long long ll; #define rep(i, n) for (...
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <tuple> #include <vector> using namespace std; typedef long long ll; #define rep(i, n) for (...
[["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 147], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 146], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 146], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 147]]
1
625
#include <bits/stdc++.h> using namespace std; int main() { int h, w, kk; cin >> h >> w >> kk; vector<string> arr(h); for (int i = 0; i < h; i++) cin >> arr[i]; int res = INT_MAX; for (int x = 0; x < (1 << (h - 1)); x++) { int g = 0; vector<int> gr(h); for (int i = 0; i < h - 1; i++) { ...
#include <bits/stdc++.h> using namespace std; int main() { int h, w, kk; cin >> h >> w >> kk; vector<string> arr(h); for (int i = 0; i < h; i++) cin >> arr[i]; int res = INT_MAX; for (int x = 0; x < (1 << (h - 1)); x++) { int g = 0; vector<int> gr(h); for (int i = 0; i < h - 1; i++) { ...
[["-", 8, 9, 0, 57, 64, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 57, 64, 1, 0, 11, 12, 13]]
1
365
#include <algorithm> #include <bits/stdc++.h> #include <bitset> #include <cassert> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <stack> #include <stdio.h> #include <tuple> #include <vector> using namespace std; #define rep(i,...
#include <algorithm> #include <bits/stdc++.h> #include <bitset> #include <cassert> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <stack> #include <stdio.h> #include <tuple> #include <vector> using namespace std; #define rep(i,...
[["+", 0, 14, 8, 9, 0, 9, 0, 57, 0, 121], ["+", 8, 9, 0, 9, 0, 57, 15, 339, 0, 24], ["+", 0, 9, 0, 57, 15, 339, 51, 91, 17, 111], ["+", 0, 9, 0, 57, 15, 339, 51, 91, 28, 22], ["+", 8, 9, 0, 9, 0, 57, 15, 339, 0, 25]]
1
672
#include <bits/stdc++.h> using namespace std; using ll = long long; using vin = vector<int>; using vll = vector<long long>; using vvin = vector<vector<int>>; using vvll = vector<vector<long long>>; using vstr = vector<string>; using vvstr = vector<vector<string>>; using vch = vector<char>; using vvch = vector<vector<ch...
#include <bits/stdc++.h> using namespace std; using ll = long long; using vin = vector<int>; using vll = vector<long long>; using vvin = vector<vector<int>>; using vvll = vector<vector<long long>>; using vstr = vector<string>; using vvstr = vector<vector<string>>; using vch = vector<char>; using vvch = vector<vector<ch...
[["+", 0, 14, 8, 9, 0, 9, 0, 57, 0, 121], ["+", 8, 9, 0, 9, 0, 57, 15, 339, 0, 24], ["+", 8, 9, 0, 9, 0, 57, 15, 339, 51, 22], ["+", 8, 9, 0, 9, 0, 57, 15, 339, 0, 25]]
1
481
#include <algorithm> #include <bits/stdc++.h> #include <cassert> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <string> #includ...
#include <algorithm> #include <bits/stdc++.h> #include <cassert> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <string> #includ...
[["+", 15, 339, 51, 16, 31, 16, 31, 16, 17, 72], ["+", 15, 339, 51, 16, 31, 16, 31, 16, 12, 13]]
1
9,068
#include <bits/stdc++.h> #define F first #define S second #define PB push_back using namespace std; typedef long long LL; typedef pair<int, int> PII; typedef priority_queue<int> HEAP; typedef priority_queue<int, vector<int>, greater<int>> RHEAP; const int N = 15, M = 1010; int n, m, k; int g[N][M]; char s[N][M], f...
#include <bits/stdc++.h> #define F first #define S second #define PB push_back using namespace std; typedef long long LL; typedef pair<int, int> PII; typedef priority_queue<int> HEAP; typedef priority_queue<int, vector<int>, greater<int>> RHEAP; const int N = 15, M = 1010; int n, m, k; int g[N][M]; char s[N][M], f...
[["+", 51, 16, 31, 23, 0, 16, 12, 23, 0, 24], ["+", 31, 23, 0, 16, 12, 23, 0, 16, 17, 33], ["+", 31, 23, 0, 16, 12, 23, 0, 16, 12, 13], ["+", 51, 16, 31, 23, 0, 16, 12, 23, 0, 25]]
1
461
#include <bits/stdc++.h> #define pb push_back #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define db(x) (cerr << #x << ": " << (x) << '\n') #define cps CLOCKS_PER_SEC #define tests(t) \ int t; ...
#include <bits/stdc++.h> #define pb push_back #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define db(x) (cerr << #x << ": " << (x) << '\n') #define cps CLOCKS_PER_SEC #define tests(t) \ int t; ...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
649
#!/usr/bin/env python3 import sys # import math # import re # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s) # from collections import deque # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popl...
#!/usr/bin/env python3 import sys # import math # import re # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s) # from collections import deque # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popl...
[["-", 0, 7, 12, 652, 3, 4, 0, 206, 206, 22], ["+", 0, 7, 12, 652, 3, 4, 0, 206, 206, 22]]
5
537
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back #define eb emplace_back #define mkp make_pair #define SZ(x) ((int)(x).size()) #define MEM(x, a) memset(x, a, sizeof(x)) #define rep(i, a, n) for (int i = a; i < n; i++) #define per(i, a, n) for (int i = n - 1; i >= a; ...
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back #define eb emplace_back #define mkp make_pair #define SZ(x) ((int)(x).size()) #define MEM(x, a) memset(x, a, sizeof(x)) #define rep(i, a, n) for (int i = a; i < n; i++) #define per(i, a, n) for (int i = n - 1; i >= a; ...
[["+", 0, 9, 0, 57, 64, 9, 0, 93, 0, 94], ["+", 0, 9, 0, 57, 64, 9, 0, 93, 0, 35]]
1
517
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<ll> vll; typedef vector<vector<ll>> vvll; typedef vector<vector<vector<ll>>> vvvll; typedef vector<bool> vb; typedef vector<vector<bool>> vvb; typedef vector<vector<vector<bool>>> vvvb; typedef pair<ll, ll> pll; typedef vector<pll> vpll...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<ll> vll; typedef vector<vector<ll>> vvll; typedef vector<vector<vector<ll>>> vvvll; typedef vector<bool> vb; typedef vector<vector<bool>> vvb; typedef vector<vector<vector<bool>>> vvvb; typedef pair<ll, ll> pll; typedef vector<pll> vpll...
[["-", 0, 9, 0, 9, 0, 57, 75, 76, 0, 95]]
1
1,075
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define repr(i, n) for (int i = n - 1; i >= 0; i--) #define MAX(a, b) a = a > b ? a : b #define MIN(a, b) a = a < b ? a : b #define REP(i, x, n) for (int i = x; i < n; i++) #define REPR(i, x, n) for (int i = n - 1; i >= x; i--) #define pb push_back ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define repr(i, n) for (int i = n - 1; i >= 0; i--) #define MAX(a, b) a = a > b ? a : b #define MIN(a, b) a = a < b ? a : b #define REP(i, x, n) for (int i = x; i < n; i++) #define REPR(i, x, n) for (int i = n - 1; i >= x; i--) #define pb push_back ...
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 31, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 151], ["+", 0, 2, 3, 4, 0, 16, 12, 23, 0, 24], ["+", 0, 2, 3, 4, 0, 16, 12, 23, 0, 25]]
1
380
#include <algorithm> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <fstream> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespac...
#include <algorithm> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <fstream> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespac...
[["-", 8, 9, 0, 43, 49, 50, 51, 16, 12, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 22]]
1
464
#include <bits/stdc++.h> #define re register using namespace std; inline int read() { re int t = 0; re char v = getchar(); while (v < '0') v = getchar(); while (v >= '0') t = (t << 3) + (t << 1) + v - 48, v = getchar(); return t; } int n, m, k, mp[12][1002], pos[12], cnt, ans, cut[1002]; char s[12][10...
#include <bits/stdc++.h> #define re register using namespace std; inline int read() { re int t = 0; re char v = getchar(); while (v < '0') v = getchar(); while (v >= '0') t = (t << 3) + (t << 1) + v - 48, v = getchar(); return t; } int n, m, k, mp[12][1002], pos[12], cnt, ans, cut[1002]; char s[12][10...
[["+", 8, 9, 0, 43, 49, 50, 51, 16, 17, 72], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13], ["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13]]
1
579
#include <bits/stdc++.h> #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define REP(i, n) FOR(i, 0, n) #define all(x) (x).begin(), (x).end() #define bit(x) (1L << (x)) using ll = long long; using namespace std; template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); } template <typenam...
#include <bits/stdc++.h> #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define REP(i, n) FOR(i, 0, n) #define all(x) (x).begin(), (x).end() #define bit(x) (1L << (x)) using ll = long long; using namespace std; template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); } template <typenam...
[["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 94], ["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 35]]
1
446
#include <bits/stdc++.h> #define all(vec) vec.begin(), vec.end() #define eb emplace_back using namespace std; using ll = long long; using P = pair<ll, ll>; constexpr ll INF = (1LL << 30) - 1LL; constexpr ll MOD = 1e9 + 7; template <class T> void chmin(T &a, T b) { a = min(a, b); } template <class T> void chmax(T &a, T ...
#include <bits/stdc++.h> #define all(vec) vec.begin(), vec.end() #define eb emplace_back using namespace std; using ll = long long; using P = pair<ll, ll>; constexpr ll INF = (1LL << 30) - 1LL; constexpr ll MOD = 1e9 + 7; template <class T> void chmin(T &a, T b) { a = min(a, b); } template <class T> void chmax(T &a, T ...
[["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35]]
1
448
from collections import defaultdict, deque, Counter from heapq import heappush, heappop, heapify from bisect import bisect_right, bisect_left import random from itertools import permutations, accumulate, combinations, product from re import split import sys import string from bisect import bisect_left, bisect_right fro...
from collections import defaultdict, deque, Counter from heapq import heappush, heappop, heapify from bisect import bisect_right, bisect_left import random from itertools import permutations, accumulate, combinations, product from re import split import sys import string from bisect import bisect_left, bisect_right fro...
[["+", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 12, 22]]
5
488
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll z = 0; int main() { int H, W, K; int ans = 1020; cin >> H >> W >> K; vector<string> s(H); for (int i = 0; i < H; i++) { cin >> s[i]; } for (int div = 0; div < (1 << H - 1); div++) { int group = 0; vector<int> id(H);...
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll z = 0; int main() { int H, W, K; int ans = 1020; cin >> H >> W >> K; vector<string> s(H); for (int i = 0; i < H; i++) { cin >> s[i]; } for (int div = 0; div < (1 << H - 1); div++) { int group = 0; vector<int> id(H);...
[["+", 0, 7, 8, 9, 0, 7, 8, 9, 0, 46], ["-", 0, 7, 8, 9, 0, 7, 8, 9, 0, 46]]
1
395
#include "bits/stdc++.h" using namespace std; #define sim template <class c #define ris return *this #define dor > debug &operator<< #define eni(x) \ sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<( \ c i) { sim > ...
#include "bits/stdc++.h" using namespace std; #define sim template <class c #define ris return *this #define dor > debug &operator<< #define eni(x) \ sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<( \ c i) { sim > ...
[["-", 0, 9, 0, 57, 15, 339, 51, 16, 17, 98], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 17, 67], ["-", 0, 11, 12, 16, 31, 69, 341, 342, 0, 22], ["+", 0, 11, 12, 16, 31, 69, 341, 342, 0, 22], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
1
849
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <sstream> #include <stdio.h> #include <string> #include <vector> #define forn(i, n) for (int(i) = 0; i < (n); i++) #define pb push_b...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <sstream> #include <stdio.h> #include <string> #include <vector> #define forn(i, n) for (int(i) = 0; i < (n); i++) #define pb push_b...
[["-", 15, 339, 51, 16, 31, 69, 341, 342, 0, 22], ["+", 15, 339, 51, 16, 31, 69, 341, 342, 0, 22]]
1
458
#include <algorithm> #include <bits/stdc++.h> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #includ...
#include <algorithm> #include <bits/stdc++.h> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #includ...
[["+", 0, 57, 64, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 27, 17, 29], ["+", 0, 9, 0, 57, 64, 9, 0, 1, 0, 35]]
1
1,643
import sys from itertools import product read = sys.stdin.read readline = sys.stdin.readline H, W, K = map(int, readline().split()) S = [list(map(int, list(readline().rstrip()))) for _ in range(H)] answer = 10 ** 10 for i in product((0, 1), repeat=H - 1): cnt = sum(i) if cnt >= answer: continue c...
import sys from itertools import product read = sys.stdin.read readline = sys.stdin.readline H, W, K = map(int, readline().split()) S = [list(map(int, list(readline().rstrip()))) for _ in range(H)] answer = 10 ** 10 for i in product((0, 1), repeat=H - 1): cnt = sum(i) if cnt >= answer: continue c...
[["-", 8, 196, 0, 57, 64, 196, 0, 116, 0, 117], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 0, 7, 8, 196, 0, 7, 75, 76, 0, 95], ["+", 0, 7, 8, 196, 0, 7, 75, 76, 0, 102]]
5
289
#include <bits/stdc++.h> using namespace std; using llong = long long int; #define rep(i, n) for (int i = 0; i < n; ++i) #define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr) #define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr) #define all(x) x.begin(), x.end() #define allr...
#include <bits/stdc++.h> using namespace std; using llong = long long int; #define rep(i, n) for (int i = 0; i < n; ++i) #define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr) #define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr) #define all(x) x.begin(), x.end() #define allr...
[["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 72], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33]]
1
1,266
#include <bits/stdc++.h> #define rep(i, c) for (int i = 0; i < (int)c; ++i) using llint = long long int; using namespace std; int main() { int H, W, K; cin >> H >> W >> K; string S[11]; rep(i, H) cin >> S[i]; int ans = 10000000; for (int bit = 0; bit < (1 << (H - 1)); bit++) { int group = 0; vect...
#include <bits/stdc++.h> #define rep(i, c) for (int i = 0; i < (int)c; ++i) using llint = long long int; using namespace std; int main() { int H, W, K; cin >> H >> W >> K; string S[11]; rep(i, H) cin >> S[i]; int ans = 10000000; for (int bit = 0; bit < (1 << (H - 1)); bit++) { int group = 0; vect...
[["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 94], ["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 35]]
1
325
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <queue> #include <vector> using namespace std; using ll = long long; using pii = pair<int, int>; using vi = vector<int>; using vvi = vector<vi>; // #define rep(i,n) for(int i=0;i<(n);++i) #define all(f, c, ...) ...
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <queue> #include <vector> using namespace std; using ll = long long; using pii = pair<int, int>; using vi = vector<int>; using vvi = vector<vi>; // #define rep(i,n) for(int i=0;i<(n);++i) #define all(f, c, ...) ...
[["-", 0, 57, 64, 9, 0, 1, 0, 27, 17, 29], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13]]
1
838
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (long long i = 0; i < (long long)(n); i++) #define REP(i, k, n) for (long long i = k; i < (long long)(n); i++) #define all(a) a.begin(), a.end() #define pb push_back #define eb emplace_back #define lb(v, k) (lower_bound(all(v), k) - v.begin()) #define ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (long long i = 0; i < (long long)(n); i++) #define REP(i, k, n) for (long long i = k; i < (long long)(n); i++) #define all(a) a.begin(), a.end() #define pb push_back #define eb emplace_back #define lb(v, k) (lower_bound(all(v), k) - v.begin()) #define ...
[["-", 0, 11, 12, 69, 28, 69, 341, 342, 0, 22], ["+", 0, 11, 12, 69, 28, 69, 341, 342, 0, 22]]
1
839
#include <bits/stdc++.h> using namespace std; int main() { int H, W, K; cin >> H >> W >> K; string s[H]; int ans = 123123123; for (int i = 0; i < H; i++) { cin >> s[i]; } for (int i = 0; i < (1 << (H - 1)); i++) { int popCount = __builtin_popcount(i); int blockCount[popCount + 1]; fill(b...
#include <bits/stdc++.h> using namespace std; int main() { int H, W, K; cin >> H >> W >> K; string s[H]; int ans = 123123123; for (int i = 0; i < H; i++) { cin >> s[i]; } for (int i = 0; i < (1 << (H - 1)); i++) { int popCount = __builtin_popcount(i); int blockCount[popCount + 1]; fill(b...
[["+", 8, 9, 0, 7, 8, 9, 0, 57, 0, 121], ["+", 0, 7, 8, 9, 0, 57, 15, 339, 0, 24], ["+", 8, 9, 0, 57, 15, 339, 51, 91, 17, 111], ["+", 8, 9, 0, 57, 15, 339, 51, 91, 28, 22], ["+", 0, 7, 8, 9, 0, 57, 15, 339, 0, 25]]
1
314
import sys sys.setrecursionlimit(10 ** 8) input = sys.stdin.readline def main(): H, W, K = [int(x) for x in input().split()] S = [list(input().strip()) for _ in range(H)] ans = float("inf") for n in range(2 ** (H - 1)): tmp = 0 wn = [0] * 10 for i in range(H): ...
import sys sys.setrecursionlimit(10 ** 8) input = sys.stdin.readline def main(): H, W, K = [int(x) for x in input().split()] S = [list(input().strip()) for _ in range(H)] ans = float("inf") for n in range(2 ** (H - 1)): tmp = 0 wn = [0] * 10 for i in range(H): ...
[["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94]]
5
293
#include <iostream> #include <map> #include <stdio.h> #include <string.h> #include <vector> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef long long ll; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin...
#include <iostream> #include <map> #include <stdio.h> #include <string.h> #include <vector> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef long long ll; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin...
[["-", 0, 7, 8, 9, 0, 57, 64, 37, 0, 38], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 94], ["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 35], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46]]
1
424
#include <bits/stdc++.h> #define ll long long #define ull unsigned long long #define REP(a, b) for (int a = 0; a < (b); ++a) #define REP1(i, n) for (int i = 1; i <= (n); ++i) #define debug(x) cerr << #x << ": " << x << '\n' #define all(x) (x).begin(), (x).end() #define YES() printf("YES\n") #define NO() printf("NO\n") ...
#include <bits/stdc++.h> #define ll long long #define ull unsigned long long #define REP(a, b) for (int a = 0; a < (b); ++a) #define REP1(i, n) for (int i = 1; i <= (n); ++i) #define debug(x) cerr << #x << ": " << x << '\n' #define all(x) (x).begin(), (x).end() #define YES() printf("YES\n") #define NO() printf("NO\n") ...
[["+", 0, 9, 0, 57, 15, 339, 51, 16, 17, 106], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 47], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]]
1
1,166
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define PI 3.14159265358979323846 #define int long long constexpr long long INF = numeric_limits<long long>::max() / 2; constexpr int MOD = 1000000007; using Graph = vector<vector<int>>; int max = 100000; signed main() ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define PI 3.14159265358979323846 #define int long long constexpr long long INF = numeric_limits<long long>::max() / 2; constexpr int MOD = 1000000007; using Graph = vector<vector<int>>; int max = 100000; signed main() ...
[["-", 0, 7, 8, 9, 0, 57, 64, 93, 0, 94], ["+", 0, 7, 8, 9, 0, 57, 64, 116, 0, 117]]
1
453
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ll long long #define ld long double int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; } //最大公約数 ll lcm(ll x, ll y) { return x / gcd(x, y) * y; } //最小公倍数 using Graph = vector<vector<ll>>; ll ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ll long long #define ld long double int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; } //最大公約数 ll lcm(ll x, ll y) { return x / gcd(x, y) * y; } //最小公倍数 using Graph = vector<vector<ll>>; ll ...
[["-", 0, 11, 31, 2, 3, 4, 0, 16, 17, 33], ["-", 0, 11, 31, 2, 3, 4, 0, 16, 12, 13]]
1
406
#include <bits/stdc++.h> #define rep2(x, fr, to) for (int(x) = (fr); (x) < (to); (x)++) #define rep(x, to) for (int(x) = 0; (x) < (to); (x)++) #define repr(x, fr, to) for (int(x) = (fr); (x) >= (to); (x)--) #define all(c) (c).begin(), (c).end() #define sz(v) (int)(v).size() using namespace std; typedef long long ll; ...
#include <bits/stdc++.h> #define rep2(x, fr, to) for (int(x) = (fr); (x) < (to); (x)++) #define rep(x, to) for (int(x) = 0; (x) < (to); (x)++) #define repr(x, fr, to) for (int(x) = (fr); (x) >= (to); (x)--) #define all(c) (c).begin(), (c).end() #define sz(v) (int)(v).size() using namespace std; typedef long long ll; ...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 27, 17, 68]]
1
505
#include <bits/stdc++.h> #include <cassert> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; using P = pair<int, int>; struct Edge { int to; int weight; Edge(int t, int w) : to(t), weight(w) {} }; using Graph = vector<vector<Edge>>; // using Graph = vector<vector<int>>; ...
#include <bits/stdc++.h> #include <cassert> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; using P = pair<int, int>; struct Edge { int to; int weight; Edge(int t, int w) : to(t), weight(w) {} }; using Graph = vector<vector<Edge>>; // using Graph = vector<vector<int>>; ...
[["+", 8, 9, 0, 57, 15, 339, 51, 91, 17, 111]]
1
463
#include <bits/stdc++.h> #define long long long int using namespace std; // @author: pashka int main() { ios::sync_with_stdio(false); int n, m, k; cin >> n >> m >> k; vector<string> a(n); for (int i = 0; i < n; i++) cin >> a[i]; int res = INT_MAX; for (int x = 0; x < (1 << (n - 1)); x++) { vect...
#include <bits/stdc++.h> #define long long long int using namespace std; // @author: pashka int main() { ios::sync_with_stdio(false); int n, m, k; cin >> n >> m >> k; vector<string> a(n); for (int i = 0; i < n; i++) cin >> a[i]; int res = INT_MAX; for (int x = 0; x < (1 << (n - 1)); x++) { vect...
[["+", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
376
#include <bits/stdc++.h> using namespace std; char str[11][1003]; int main() { int r, c, k; scanf("%d %d %d", &r, &c, &k); for (int i = 1; i <= r; i++) scanf("%s", str[i] + 1); int res = r + c - 2; bool f = 1; for (int j = 1; j <= c && f; j++) { int sum = 0; for (int i = 1; i <= r; i++) su...
#include <bits/stdc++.h> using namespace std; char str[11][1003]; int main() { int r, c, k; scanf("%d %d %d", &r, &c, &k); for (int i = 1; i <= r; i++) scanf("%s", str[i] + 1); int res = r + c - 2; bool f = 1; for (int j = 1; j <= c && f; j++) { int sum = 0; for (int i = 1; i <= r; i++) su...
[["-", 0, 57, 64, 9, 0, 7, 15, 16, 17, 98], ["-", 0, 57, 64, 9, 0, 7, 15, 16, 12, 22]]
1
618
#include <algorithm> #include <array> #include <assert.h> #include <bitset> #include <cmath> #include <complex> #include <cstdlib> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <st...
#include <algorithm> #include <array> #include <assert.h> #include <bitset> #include <cmath> #include <complex> #include <cstdlib> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <st...
[["+", 51, 16, 31, 69, 341, 342, 0, 69, 28, 22], ["+", 31, 69, 341, 342, 0, 69, 341, 342, 0, 70], ["+", 31, 69, 341, 342, 0, 69, 341, 342, 0, 73]]
1
447
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/detail/standard_policies.hpp> #include <ext/pb_ds/tree_policy.hpp> #define ll long long #define int long long #define pb push_back #define ins insert #define rs resize #define br break; #define cont continue; #define vi vector<int> #d...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/detail/standard_policies.hpp> #include <ext/pb_ds/tree_policy.hpp> #define ll long long #define int long long #define pb push_back #define ins insert #define rs resize #define br break; #define cont continue; #define vi vector<int> #d...
[["-", 12, 23, 0, 16, 31, 69, 341, 342, 0, 22], ["+", 12, 23, 0, 16, 31, 69, 341, 342, 0, 22]]
1
675
package main import ( "bufio" "fmt" "math" "os" "strconv" ) const ( initialBufSize = 10000 maxBufSize = 10000000 ) var ( sc = func() *bufio.Scanner { sc := bufio.NewScanner(os.Stdin) buf := make([]byte, initialBufSize) sc.Buffer(buf, maxBufSize) sc.Split(bufio.ScanWords) return sc }() ) func ...
package main import ( "bufio" "fmt" "math" "os" "strconv" ) const ( initialBufSize = 10000 maxBufSize = 10000000 ) var ( sc = func() *bufio.Scanner { sc := bufio.NewScanner(os.Stdin) buf := make([]byte, initialBufSize) sc.Buffer(buf, maxBufSize) sc.Split(bufio.ScanWords) return sc }() ) func ...
[["-", 0, 7, 0, 430, 10, 431, 12, 432, 0, 433], ["+", 0, 7, 0, 430, 10, 431, 12, 432, 0, 433], ["+", 0, 16, 12, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 16, 12, 2, 3, 4, 0, 16, 12, 433]]
7
695
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; 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 tr...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; 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 tr...
[["+", 31, 69, 28, 2, 3, 4, 0, 16, 17, 72], ["+", 31, 69, 28, 2, 3, 4, 0, 16, 12, 13]]
1
477
#include <bits/stdc++.h> #define rep(i, a, b) for (int i = a; i < (b); i++) #define rrep(i, a, b) for (int i = a; i >= (b); i--) #define all(x) (x).begin(), (x).end() using namespace std; using ll = long long; using P = pair<int, int>; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; retu...
#include <bits/stdc++.h> #define rep(i, a, b) for (int i = a; i < (b); i++) #define rrep(i, a, b) for (int i = a; i >= (b); i--) #define all(x) (x).begin(), (x).end() using namespace std; using ll = long long; using P = pair<int, int>; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; retu...
[["-", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22]]
1
484
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) using ll = long long; using P = pair<int, int>; int main() { int h, w, k; cin >> h >> w >> k; vector<string> s(h); rep(i, h) cin >> s[i]; int ans = 1001001001; int cnt[10][1005]; rep(div, 1 << (h - 1)) { int...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) using ll = long long; using P = pair<int, int>; int main() { int h, w, k; cin >> h >> w >> k; vector<string> s(h); rep(i, h) cin >> s[i]; int ans = 1001001001; int cnt[10][1005]; rep(div, 1 << (h - 1)) { int...
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
370
import sys input = sys.stdin.readline h, w, K = map(int, input().split()) s = [] for i in range(h): s.append(input().rstrip()) ans = float('inf') for i in range(2 ** (h-1)): # 仕切り 1, 2, ... sep = [0] for j in range(h-1): if i & (1 << j): sep.append(j+1) memo = [0 for _ in ran...
import sys input = sys.stdin.readline h, w, K = map(int, input().split()) s = [] for i in range(h): s.append(input().rstrip()) ans = float('inf') for i in range(2 ** (h-1)): # 仕切り 1, 2, ... sep = [0] for j in range(h-1): if i & (1 << j): sep.append(j+1) memo = [0 for _ in ran...
[["-", 8, 196, 0, 57, 15, 679, 12, 666, 667, 18], ["+", 8, 196, 0, 57, 15, 679, 12, 666, 667, 19]]
5
285
#include <bits/stdc++.h> using namespace std; int main() { int H, W, K; cin >> H >> W >> K; vector<string> S(H); for (auto &e : S) cin >> e; auto f = [&](auto &&f, int bit, int pos) -> int { if (pos == H - 1) { int res = __builtin_popcount(bit); int N = res + 1; vector<int> cnt(N); ...
#include <bits/stdc++.h> using namespace std; int main() { int H, W, K; cin >> H >> W >> K; vector<string> S(H); for (auto &e : S) cin >> e; auto f = [&](auto &&f, int bit, int pos) -> int { if (pos == H - 1) { int res = __builtin_popcount(bit); int N = res + 1; vector<int> cnt(N); ...
[["+", 8, 9, 0, 57, 64, 1, 0, 34, 0, 21], ["+", 0, 57, 64, 1, 0, 34, 12, 11, 31, 22], ["+", 0, 57, 64, 1, 0, 34, 12, 11, 17, 32], ["+", 0, 57, 64, 1, 0, 34, 12, 11, 12, 13]]
1
293
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; int main() { int H, W, K; cin >> H >> W >> K; vector<string> S(H); for (auto &e : S) cin >> e; auto f = [&](auto &&f, int bit, int pos) -> int { if (pos == H - 1) { int res = __builtin_popcount(bit); ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; int main() { int H, W, K; cin >> H >> W >> K; vector<string> S(H); for (auto &e : S) cin >> e; auto f = [&](auto &&f, int bit, int pos) -> int { if (pos == H - 1) { int res = __builtin_popcount(bit); ...
[["+", 8, 9, 0, 57, 64, 1, 0, 34, 0, 21], ["+", 0, 57, 64, 1, 0, 34, 12, 11, 31, 22], ["+", 0, 57, 64, 1, 0, 34, 12, 11, 17, 32], ["+", 0, 57, 64, 1, 0, 34, 12, 11, 12, 13]]
1
282
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define rrep(i, n) for (int i = n - 1; i >= 0; i--) using namespace std; using Graph = vector<vector<int>>; #define MOD 1000000007 #define MOD2 998244353 #define INF ((1 << 30) - 1) #define LINF (1LL << 60) #define EPS (1e-10) typedef long long ll; ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define rrep(i, n) for (int i = n - 1; i >= 0; i--) using namespace std; using Graph = vector<vector<int>>; #define MOD 1000000007 #define MOD2 998244353 #define INF ((1 << 30) - 1) #define LINF (1LL << 60) #define EPS (1e-10) typedef long long ll; ...
[["+", 0, 14, 8, 9, 0, 57, 64, 93, 0, 94], ["+", 0, 14, 8, 9, 0, 57, 64, 93, 0, 35]]
1
385
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define rrep(i, n) for (int i = n - 1; i >= 0; i--) using namespace std; using Graph = vector<vector<int>>; #define MOD 1000000007 #define MOD2 998244353 #define INF ((1 << 30) - 1) #define LINF (1LL << 60) #define EPS (1e-10) typedef long long ll; ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define rrep(i, n) for (int i = n - 1; i >= 0; i--) using namespace std; using Graph = vector<vector<int>>; #define MOD 1000000007 #define MOD2 998244353 #define INF ((1 << 30) - 1) #define LINF (1LL << 60) #define EPS (1e-10) typedef long long ll; ...
[["-", 12, 23, 0, 16, 12, 23, 0, 16, 17, 72], ["-", 12, 23, 0, 16, 12, 23, 0, 16, 12, 13]]
1
405
import sys def input(): return sys.stdin.readline().rstrip() def main(): H, W, K = map(int, input().split()) S = [input() for _ in range(H)] ans = 10 ** 9 for bit in range(1 << (H-1)): canSolve = True ord = [0] * (H + 1) N = 0 for i in range(H): if bit & 1 ...
import sys def input(): return sys.stdin.readline().rstrip() def main(): H, W, K = map(int, input().split()) S = [input() for _ in range(H)] ans = 10 ** 9 for bit in range(1 << (H-1)): canSolve = True ord = [0] * (H + 1) N = 0 for i in range(H): if bit & 1 ...
[["-", 75, 76, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
283
#include <bits/stdc++.h> using namespace std; const int N = 1e3 + 10, mod = 1e9 + 7; int n, m; char s[11][N]; int dp[N][1 << 9], pref[11][N]; void build() { for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { pref[i][j] = pref[i][j - 1] + (s[i - 1][j - 1] == '1'); } } for (int j = 1; j ...
#include <bits/stdc++.h> using namespace std; const int N = 1e3 + 10, mod = 1e9 + 7; int n, m; char s[11][N]; int dp[N][1 << 9], pref[11][N]; void build() { for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { pref[i][j] = pref[i][j - 1] + (s[i - 1][j - 1] == '1'); } } for (int j = 1; j ...
[["-", 8, 9, 0, 43, 49, 50, 51, 16, 17, 33], ["-", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13]]
1
766
from collections import Counter N = int(input()) A = list(map(int, input().split())) counter = Counter(A) ans = 0 for k, v in counter.items(): if 2 <= v: ans += v * (v - 1) // 2 for a in A: if a in counter and 2 <= counter[a]: v = counter[a] diff = v * (v - 1) // 2 - ((v- 1) * (v - 2) //...
from collections import Counter N = int(input()) A = list(map(int, input().split())) counter = Counter(A) ans = 0 for k, v in counter.items(): if 2 <= v: ans += v * (v - 1) // 2 for a in A: if a in counter and 2 <= counter[a]: v = counter[a] diff = v * (v - 1) // 2 - ((v- 1) * (v - 2) //...
[["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 612], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22]]
5
127
N = int(input()) A = list(map(int, input().split())) d = {} for a in A: if a in d: d[a] += 1 else: d[a] = 1 ans = 0 for a in d: n = d[a] ans += n * (n-1) // 2 print(ans) for a in A: n = d[a] if n >= 2: print(ans - n + 1) else: print(ans)
N = int(input()) A = list(map(int, input().split())) d = {} for a in A: if a in d: d[a] += 1 else: d[a] = 1 ans = 0 for a in d: n = d[a] ans += n * (n-1) // 2 for a in A: n = d[a] if n >= 2: print(ans - n + 1) else: print(ans)
[["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]]
5
112
#include <bits/stdc++.h> using namespace std; typedef long long LL; typedef unsigned long long UL; typedef pair<int, int> P; typedef pair<int, P> PPI; typedef pair<LL, LL> PL; typedef long long LL; // LLONG_MIN, INT_MIN #define xx first #define yy second const LL INF = 1000000000; struct edge { LL to, cost; edge(i...
#include <bits/stdc++.h> using namespace std; typedef long long LL; typedef unsigned long long UL; typedef pair<int, int> P; typedef pair<int, P> PPI; typedef pair<LL, LL> PL; typedef long long LL; // LLONG_MIN, INT_MIN #define xx first #define yy second const LL INF = 1000000000; struct edge { LL to, cost; edge(i...
[["-", 0, 7, 8, 57, 64, 9, 0, 57, 0, 121], ["+", 0, 7, 8, 57, 64, 9, 0, 52, 0, 89]]
1
541
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <vector> #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) #define rep2(i, a, b) for (int(i) ...
#include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <vector> #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) #define rep2(i, a, b) for (int(i) ...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
613
import sys def input(): return sys.stdin.readline().strip() def STR(): return input() def MAP(): return map(int, input().split()) inf = sys.maxsize h, w, k = MAP() s = [[int(i) for i in STR()] for _ in range(h)] ans = inf for i in range(2 ** (h - 1)): #縦方向の割り方を全探索 O(500) hdiv = [1 for _ in range(h)] for j in ...
import sys def input(): return sys.stdin.readline().strip() def STR(): return input() def MAP(): return map(int, input().split()) inf = sys.maxsize h, w, k = MAP() s = [[int(i) for i in STR()] for _ in range(h)] ans = inf for i in range(2 ** (h - 1)): #縦方向の割り方を全探索 O(500) hdiv = [1 for _ in range(h)] for j in ...
[["-", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22]]
5
309
#include <bits/stdc++.h> #define FASTIO using namespace std; using ll = long long; using Vi = vector<int>; using Vl = vector<ll>; using Pii = pair<int, int>; using Pll = pair<ll, ll>; constexpr int I_INF = numeric_limits<int>::max(); constexpr ll L_INF = numeric_limits<ll>::max(); //=================================...
#include <bits/stdc++.h> #define FASTIO using namespace std; using ll = long long; using Vi = vector<int>; using Vl = vector<ll>; using Pii = pair<int, int>; using Pll = pair<ll, ll>; constexpr int I_INF = numeric_limits<int>::max(); constexpr ll L_INF = numeric_limits<ll>::max(); //=================================...
[["-", 12, 23, 0, 16, 12, 23, 0, 16, 12, 13], ["+", 12, 23, 0, 16, 12, 23, 0, 16, 12, 13]]
1
573
/* confirm 0LL and 1LL confirm cornercases such as 0 confirm times of cin < 10^6 */ #include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using P = pair<ll, ll>; using Pld = pair<ld, ld>; using Vec = vector<ll>; using VecP = vector<P>; using VecB = vector<bool>; using VecC = vector...
/* confirm 0LL and 1LL confirm cornercases such as 0 confirm times of cin < 10^6 */ #include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using P = pair<ll, ll>; using Pld = pair<ld, ld>; using Vec = vector<ll>; using VecP = vector<P>; using VecB = vector<bool>; using VecC = vector...
[["-", 0, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 17, 47]]
1
876
#include <bits/stdc++.h> using namespace std; typedef long long ll; // int/long: -2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31) // long/long long: -9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 // (-2^63 <= long < 2^63) // lower_bound(A.begin(), A.end(), N) // upper_bound(... // A.erase(unique(A.begin...
#include <bits/stdc++.h> using namespace std; typedef long long ll; // int/long: -2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31) // long/long long: -9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 // (-2^63 <= long < 2^63) // lower_bound(A.begin(), A.end(), N) // upper_bound(... // A.erase(unique(A.begin...
[["-", 0, 52, 8, 9, 0, 1, 0, 11, 17, 108], ["-", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 52, 8, 9, 0, 1, 0, 27, 17, 29]]
1
725
#include <bits/stdc++.h> using namespace std; //#include<boost/multiprecision/cpp_int.hpp> // using boost::multiprecision::cpp_int; #define int long long #define cint cpp_int #define endl "\n" #define REP(i, a, n) for (int i = a; i < n; ++i) #define REPR(i, a, n) for (int i = a; i > n; --i) #define RUP(a, b) (((a) + (...
#include <bits/stdc++.h> using namespace std; //#include<boost/multiprecision/cpp_int.hpp> // using boost::multiprecision::cpp_int; #define int long long #define cint cpp_int #define endl "\n" #define REP(i, a, n) for (int i = a; i < n; ++i) #define REPR(i, a, n) for (int i = a; i > n; --i) #define RUP(a, b) (((a) + (...
[["-", 0, 11, 12, 69, 28, 69, 341, 342, 0, 22], ["+", 0, 11, 12, 69, 28, 69, 341, 342, 0, 22]]
1
1,284
from collections import * from heapq import * from itertools import * from math import gcd import sys from decimal import * import copy input=lambda :sys.stdin.readline().rstrip() H,W,K=map(int,input().split()) S=[input() for i in range(H)] value=H+W-1 if H==1: count=0 countL=0 w=0 while w<W: ...
from collections import * from heapq import * from itertools import * from math import gcd import sys from decimal import * import copy input=lambda :sys.stdin.readline().rstrip() H,W,K=map(int,input().split()) S=[input() for i in range(H)] value=H+W-1 if H==1: count=0 countL=0 w=0 while w<W: ...
[["-", 64, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 64, 196, 0, 57, 64, 196, 0, 93, 0, 94]]
5
341
#include <iostream> #include <vector> using namespace std; int group[20]; int n; int m, k; string mt[20]; int rsglobal = 1e9; void check(int j, int i, vector<int> &white, int &rs) { if (mt[j][i] == '1') white[group[j]]++; if (white[group[j]] > k) { for (int l = 1; l <= n; l++) white[l] = 0; for (...
#include <iostream> #include <vector> using namespace std; int group[20]; int n; int m, k; string mt[20]; int rsglobal = 1e9; void check(int j, int i, vector<int> &white, int &rs) { if (mt[j][i] == '1') white[group[j]]++; if (white[group[j]] > k) { for (int l = 1; l <= n; l++) white[l] = 0; for (...
[["-", 0, 57, 64, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 57, 64, 9, 0, 7, 15, 16, 12, 22]]
1
361
#include <bits/stdc++.h> using namespace std; /** ******************************************************************** ******************* Author:Bisnu sarkar **************************** ******************************************************************** **/ #define ull unsigned long long #define ll long long #defin...
#include <bits/stdc++.h> using namespace std; /** ******************************************************************** ******************* Author:Bisnu sarkar **************************** ******************************************************************** **/ #define ull unsigned long long #define ll long long #defin...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 49, 22], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 49, 22], ["-", 8, 9, 0, 7, 15, 16, 31, 16, 31, 22], ["+", 8, 9, 0, 7, 15, 16, 31, 16, 31, 22], ["-", 0, 7, 8, 9, 0, 7, 26, 27, 28, 22], ["+", 0, 7, 8, 9, 0, 7, 26, 27, 28, 22], ["-", 12, 16, 31, 69, 28, 69, 341, 342, 0, 22], ["+", 12, 16, 31,...
1
826
#define _USE_MATH_DEFINES #include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> //#include <tuple> #define INF INT_MAX >> 1...
#define _USE_MATH_DEFINES #include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> //#include <tuple> #define INF INT_MAX >> 1...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19]]
1
507
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> P; typedef pair<ll, ll> l_l; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vl; typedef vector<P> vp; #define fi first #define se second #define rep(i, n) for (int i = 0; i < (n); ++i) ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> P; typedef pair<ll, ll> l_l; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vl; typedef vector<P> vp; #define fi first #define se second #define rep(i, n) for (int i = 0; i < (n); ++i) ...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["-", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35]]
1
489
#pragma region #include <algorithm> #include <cmath> #include <cstdlib> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; //#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i)) #define ...
#pragma region #include <algorithm> #include <cmath> #include <cstdlib> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; //#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i)) #define ...
[["-", 0, 52, 15, 339, 51, 16, 12, 16, 12, 22], ["+", 0, 52, 15, 339, 51, 16, 12, 16, 12, 22]]
1
441
package main import ( "bufio" _ "container/heap" "fmt" "os" _ "sort" "strconv" ) // I/O type Scanner struct { sc *bufio.Scanner } func NewScanner() *Scanner { sc := bufio.NewScanner(os.Stdin) sc.Split(bufio.ScanWords) sc.Buffer(make([]byte, 1024), int(1e+9)) return &Scanner{sc} } func (s *Scanner) nextSt...
package main import ( "bufio" _ "container/heap" "fmt" "os" _ "sort" "strconv" ) // I/O type Scanner struct { sc *bufio.Scanner } func NewScanner() *Scanner { sc := bufio.NewScanner(os.Stdin) sc.Split(bufio.ScanWords) sc.Buffer(make([]byte, 1024), int(1e+9)) return &Scanner{sc} } func (s *Scanner) nextSt...
[["-", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 8, 196, 0, 57, 64, 196, 0, 116, 0, 117]]
7
1,189
#include <bits/stdc++.h> using namespace std; #define ll long long #define ar array const int mxH = 10, mxW = 1e3; int h, w, k, ans = 1e9; string g[mxH]; vector<int> v[mxW]; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> h >> w >> k; for (int i = 0; i < h; ++i) cin >> g[i]; for (int i = 0; i...
#include <bits/stdc++.h> using namespace std; #define ll long long #define ar array const int mxH = 10, mxW = 1e3; int h, w, k, ans = 1e9; string g[mxH]; vector<int> v[mxW]; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> h >> w >> k; for (int i = 0; i < h; ++i) cin >> g[i]; for (int i = 0; i...
[["-", 8, 9, 0, 7, 8, 9, 0, 57, 0, 121], ["-", 0, 7, 8, 9, 0, 57, 15, 339, 0, 24], ["-", 0, 7, 8, 9, 0, 57, 15, 339, 51, 22], ["-", 0, 7, 8, 9, 0, 57, 15, 339, 0, 25], ["-", 0, 7, 8, 9, 0, 57, 64, 116, 0, 117], ["-", 0, 7, 8, 9, 0, 57, 64, 116, 0, 35]]
1
396
#include <cstdio> #include <cstring> #include <iostream> using namespace std; int h, w, k, z, ans = 1e9, c[15]; string a[15]; bool f(int j) { int i, id = 0, fl = 0; for (i = 0; i < h; i++) { c[id] += a[i][j] == '1'; if (c[id] > k) fl = 1; if (z >> i & 1) id++; } return fl; } int main(...
#include <cstdio> #include <cstring> #include <iostream> using namespace std; int h, w, k, z, ans = 1e9, c[15]; string a[15]; bool f(int j) { int i, id = 0, fl = 0; for (i = 0; i < h; i++) { c[id] += a[i][j] == '1'; if (c[id] > k) fl = 1; if (z >> i & 1) id++; } return fl; } int main(...
[["-", 0, 57, 64, 9, 0, 1, 0, 2, 63, 22], ["-", 64, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["-", 64, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["-", 64, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["-", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35]]
1
269
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define PI 3.14159265359 #define INF 1000100100 #define all(x) (x).begin(), (x).end() using namespace std; typedef long long ll; int main() { int h, w, k; cin >> h >> w >> k; vector<string> cho(h); rep(i, h) cin >> cho[i]; int tans = INF;...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define PI 3.14159265359 #define INF 1000100100 #define all(x) (x).begin(), (x).end() using namespace std; typedef long long ll; int main() { int h, w, k; cin >> h >> w >> k; vector<string> cho(h); rep(i, h) cin >> cho[i]; int tans = INF;...
[["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35]]
1
353
#include <bits/stdc++.h> using namespace std; int n, m, K, cnt[15]; char s[15][1005]; int main() { scanf("%d%d%d", &n, &m, &K); for (int i = 0; i < n; ++i) scanf("%s", s[i]); int res = 1000000000; for (int i = 0; i < 1 << (n - 1); ++i) { int tmp = __builtin_popcount(i); vector<int> vec; vec.push...
#include <bits/stdc++.h> using namespace std; int n, m, K, cnt[15]; char s[15][1005]; int main() { scanf("%d%d%d", &n, &m, &K); for (int i = 0; i < n; ++i) scanf("%s", s[i]); int res = 1000000000; for (int i = 0; i < 1 << (n - 1); ++i) { int tmp = __builtin_popcount(i); vector<int> vec; vec.push...
[["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 94], ["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 35]]
1
337
#include <bits/stdc++.h> using namespace std; int main() { string s[12]; int h, w, k; cin >> h >> w >> k; for (int i = 0; i < h; i++) cin >> s[i]; int ans = 1e9; for (int u = 0; u < (1 << (h - 1)); u++) { //枚举横向切割的所有情况 int x = __builtin_popcount(u); //横向切割的刀数 int r[x + 1] = {0}; ...
#include <bits/stdc++.h> using namespace std; int main() { string s[12]; int h, w, k; cin >> h >> w >> k; for (int i = 0; i < h; i++) cin >> s[i]; int ans = 1e9; for (int u = 0; u < (1 << (h - 1)); u++) { //枚举横向切割的所有情况 int x = __builtin_popcount(u); //横向切割的刀数 int r[x + 1] = {0}; ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["-", 15, 339, 51, 16, 12, 23, 0, 16, 12, 22], ["+", 15, 339, 51, 16, 12, 23, 0, 16, 12, 22]]
1
342
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; int S[10][1000]; int cum[11][1001]; int res = 10000; int count_num(int x, int y, int w, int z) { return cum[x][y] + cum[w][z] - cum[x][z] - cum[w][y]; } int debug_point = 0;...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; int S[10][1000]; int cum[11][1001]; int res = 10000; int count_num(int x, int y, int w, int z) { return cum[x][y] + cum[w][z] - cum[x][z] - cum[w][y]; } int debug_point = 0;...
[["-", 0, 9, 0, 57, 64, 9, 0, 93, 0, 94], ["-", 0, 9, 0, 57, 64, 9, 0, 93, 0, 35], ["+", 0, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["+", 0, 9, 0, 57, 64, 9, 0, 93, 0, 94]]
1
503
#include <bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define re register #define pb push_back #define fi first #define se second #define mp make_pair #define lb long double const int N = 2e6 + 10; const int mod1 = 998244353; const int mod2 = 19260811; void read(int &a) { a...
#include <bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define re register #define pb push_back #define fi first #define se second #define mp make_pair #define lb long double const int N = 2e6 + 10; const int mod1 = 998244353; const int mod2 = 19260811; void read(int &a) { a...
[["-", 15, 339, 51, 16, 31, 69, 341, 342, 0, 22], ["+", 15, 339, 51, 16, 31, 69, 341, 342, 0, 22]]
1
577
#include <bits/stdc++.h> #define int long long int #define pb push_back #define mp make_pair #define mem(a, b) memset(a, b, sizeof(a)) using namespace std; int32_t main() { int n, i; cin >> n; if (n <= 12) { cout << n; return 0; } priority_queue<int, vector<int>, greater<int>> p; for (i = 1; i <= 9;...
#include <bits/stdc++.h> #define int long long int #define pb push_back #define mp make_pair #define mem(a, b) memset(a, b, sizeof(a)) using namespace std; int32_t main() { int n, i; cin >> n; if (n <= 12) { cout << n; return 0; } priority_queue<int, vector<int>, greater<int>> p; for (i = 1; i <= 9;...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22]]
1
210
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> pi; typedef vector<pi> vp; #define pb push_back #define mp make_pair #define fora(i, a, n) for (int i = a; i < n; i++) #define forb(i, a, n) for (int i = a; i >= (n); --i) #define...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> pi; typedef vector<pi> vp; #define pb push_back #define mp make_pair #define fora(i, a, n) for (int i = a; i < n; i++) #define forb(i, a, n) for (int i = a; i >= (n); --i) #define...
[["-", 0, 43, 39, 344, 3, 347, 0, 77, 39, 40], ["+", 0, 43, 39, 344, 3, 347, 0, 77, 39, 78], ["-", 8, 9, 0, 52, 8, 9, 0, 43, 39, 40], ["+", 8, 9, 0, 52, 8, 9, 0, 43, 39, 78]]
1
215
#include <bits/stdc++.h> using namespace std; int main(void) { int K; cin >> K; queue<int> q; for (int i = 1; i < 10; i++) { q.push(i); } int x = 0; for (int i = 0; i < K; i++) { x = q.front(); q.pop(); if (x % 10 != 0) { q.push(10 * x + x % 10 - 1); } q.push(10 * x + x %...
#include <bits/stdc++.h> using namespace std; int main(void) { int K; cin >> K; queue<long int> q; for (int i = 1; i < 10; i++) { q.push(i); } long int x = 0; for (int i = 0; i < K; i++) { x = q.front(); q.pop(); if (x % 10 != 0) { q.push(10 * x + x % 10 - 1); } q.push(10...
[["+", 39, 344, 3, 347, 0, 77, 39, 86, 0, 96], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
156
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; vector<int> a = {1, 2, 3, 4, 5, 6, 7, 8, 9}; for (int i = 0; a.size() < k; i++) { for (int j : vector<int>({-1, 0, 1})) { int d = a.at(i) % 10 + j; if (0 <= d && d <= 9) { a.push_back(a.at(i) * 10 + d); } ...
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; vector<long long> a = {1, 2, 3, 4, 5, 6, 7, 8, 9}; for (long long i = 0; a.size() < k; i++) { for (int j : vector<int>({-1, 0, 1})) { int d = a.at(i) % 10 + j; if (0 <= d && d <= 9) { a.push_back(a.at(i) * 10 + ...
[["-", 0, 43, 39, 344, 3, 347, 0, 77, 39, 40], ["+", 39, 344, 3, 347, 0, 77, 39, 86, 0, 96], ["-", 0, 14, 8, 9, 0, 7, 10, 43, 39, 40], ["+", 8, 9, 0, 7, 10, 43, 39, 86, 0, 96]]
1
141
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> ii; typedef pair<ll, ll> pll; int main(int argc, char *argv[]) { ios_base::sync_with_stdio(false); cin.tie(NULL); queue<ll> lun; for (int i = 1; i < 10; i++) { lun.push(i); } l...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> ii; typedef pair<ll, ll> pll; int main(int argc, char *argv[]) { ios_base::sync_with_stdio(false); cin.tie(NULL); queue<ll> lun; for (int i = 1; i < 10; i++) { lun.push(i); } l...
[["-", 64, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 64, 1, 0, 2, 3, 4, 0, 16, 17, 72]]
1
194
#include <bits/stdc++.h> using namespace std; #define ll long long int typedef unsigned long long int ull; typedef long double ldb; #define B 1000000007 #define rep(i, a, b) for (ll i = a; i < b; i++) #define repi(i, a, b) for (ll i = b - 1; i >= a; i--) #define MT make_tuple #define G(a, b) get<a>(b) #define VI vector...
#include <bits/stdc++.h> using namespace std; #define ll long long int typedef unsigned long long int ull; typedef long double ldb; #define B 1000000007 #define rep(i, a, b) for (ll i = a; i < b; i++) #define repi(i, a, b) for (ll i = b - 1; i >= a; i--) #define MT make_tuple #define G(a, b) get<a>(b) #define VI vector...
[["-", 0, 43, 39, 344, 3, 347, 0, 77, 39, 40], ["+", 0, 43, 39, 344, 3, 347, 0, 77, 39, 78], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]]
1
1,280
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; ++i) #include <string> #include <vector> using namespace std; typedef long long ll; typedef pair<int, int> P; 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...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; ++i) #include <string> #include <vector> using namespace std; typedef long long ll; typedef pair<int, int> P; 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...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["-", 0, 43, 39, 344, 3, 347, 0, 77, 39, 40], ["+", 0, 43, 39, 344, 3, 347, 0, 77, 39, 78], ["-", 8, 9, 0, 7, 8, 9, 0, 43, 39, 40], ["+", 8, 9, 0, 7, 8, 9, 0, 43, 39, 78]]
1
514
n = gets.to_i queue = Queue.new queue << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 for i in 1..n do x = queue.pop if x % 10 != 0 queue << 10 * x + x % 10 - 1 end queue << 10 * x + x % 10 if queue << 10 * x + x % 10 + 1 end end puts x
n = gets.to_i queue = Queue.new queue << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 for i in 1..n do x = queue.pop if x % 10 != 0 queue << 10 * x + x % 10 - 1 end queue << 10 * x + x % 10 if x % 10 != 9 queue << 10 * x + x % 10 + 1 end end puts x
[["+", 8, 170, 0, 121, 15, 738, 31, 738, 31, 22], ["+", 8, 170, 0, 121, 15, 738, 31, 738, 17, 109], ["+", 8, 170, 0, 121, 15, 738, 31, 738, 12, 612], ["+", 0, 88, 8, 170, 0, 121, 15, 738, 17, 79], ["+", 0, 88, 8, 170, 0, 121, 15, 738, 12, 612]]
4
84
from collections import deque k = int(input()) q = deque() if k > 9: for i in range(1, 10): q.append(i) for _ in range(k): temp = q.popleft() if temp % 10 != 0: q.append(temp*10+int(str(temp)[-1])-1) q.append(temp*10+int(str(temp)[-1])) if temp % 10 != 9: q.append(t...
from collections import deque k = int(input()) q = deque() for i in range(1, 10): q.append(i) for _ in range(k): temp = q.popleft() if temp % 10 != 0: q.append(temp*10+int(str(temp)[-1])-1) q.append(temp*10+int(str(temp)[-1])) if temp % 10 != 9: q.append(temp*10+int(str(tem...
[["-", 36, 36, 36, 36, 0, 656, 0, 57, 0, 121], ["-", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22], ["-", 36, 36, 0, 656, 0, 57, 15, 666, 667, 47], ["-", 36, 36, 0, 656, 0, 57, 15, 666, 0, 612], ["-", 36, 36, 36, 36, 0, 656, 0, 57, 0, 102]]
5
135
k = int(input()) dp = [[[] for j in range(11)] for i in range(11)] for i in range(10): dp[1][i].append(i) dp[0][i].append(0) if k<=9: print(k) exit() k-=9 for i in range(2, 11): for j in range(1, 10): if j==1: for z in range(i): for x in dp[i-z-1][j]: ...
k = int(input()) dp = [[[] for j in range(11)] for i in range(11)] for i in range(10): dp[1][i].append(i) dp[0][i].append(0) if k<=9: print(k) exit() k-=9 for i in range(2, 11): for j in range(1, 10): if j==1: for z in range(i): for x in dp[z][j]: ...
[["-", 12, 206, 51, 206, 206, 657, 31, 657, 31, 22], ["-", 12, 206, 51, 206, 206, 657, 31, 657, 17, 33], ["-", 0, 7, 12, 206, 51, 206, 206, 657, 17, 33], ["-", 0, 7, 12, 206, 51, 206, 206, 657, 12, 612]]
5
420
k = int(input()) x = [1,2,3,4,5,6,7,8,9] i = 0 xa = x.append while len(x) < k: if x[i]%10 == 0: xa(10*x[i]) xa(10*x[i]+1) elif x[i]%10 == 9: xa(10*x[i]+8) xa(10*x[i]+9) else: j = x[i]%10 xa(10*x[i]+j-1) xa(10*x[i]+j) xa(10*x[i]+j+1) print(x[k-1])
k = int(input()) x = [1,2,3,4,5,6,7,8,9] i = 0 xa = x.append while len(x) < k: if x[i]%10 == 0: xa(10*x[i]) xa(10*x[i]+1) elif x[i]%10 == 9: xa(10*x[i]+8) xa(10*x[i]+9) else: j = x[i]%10 xa(10*x[i]+j-1) xa(10*x[i]+j) xa(10*x[i]+j+1) i += 1 print(x[k-1])
[["+", 0, 52, 8, 196, 0, 1, 0, 677, 31, 22], ["+", 0, 52, 8, 196, 0, 1, 0, 677, 17, 107], ["+", 0, 52, 8, 196, 0, 1, 0, 677, 12, 612]]
5
163
#include <bits/stdc++.h> #include <sys/time.h> using namespace std; 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; } #define COUT(x) cout << #x << " = "...
#include <bits/stdc++.h> #include <sys/time.h> using namespace std; 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; } #define COUT(x) cout << #x << " = "...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
863
#include <algorithm> #include <functional> #include <iostream> #include <queue> #include <stdio.h> #include <vector> using namespace std; int main() { int K; cin >> K; queue<int> q; for (int i = 1; i < 10; i++) { q.push(i); } int ans = 0; for (int i = 1; i <= K; i++) { ans = q.front(); q....
#include <algorithm> #include <functional> #include <iostream> #include <queue> #include <stdio.h> #include <vector> using namespace std; int main() { int K; cin >> K; queue<long> q; for (long i = 1; i < 10; i++) { q.push(i); } long ans = 0; for (long i = 1; i <= K; i++) { ans = q.front(); ...
[["-", 0, 43, 39, 344, 3, 347, 0, 77, 39, 40], ["+", 39, 344, 3, 347, 0, 77, 39, 86, 0, 96], ["-", 0, 14, 8, 9, 0, 7, 10, 43, 39, 40], ["+", 8, 9, 0, 7, 10, 43, 39, 86, 0, 96], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
165
K = int(input()) queue = [1, 2, 3, 4, 5, 6, 7, 8, 9] def get_lunlun(K): for num in queue: if len(queue) >= K: return queue[-1] for i in range(-1, 2): last = num % 10 + i if last < 0 or last > 9: continue queue.append(num * 10 + last)...
K = int(input()) queue = [1, 2, 3, 4, 5, 6, 7, 8, 9] def get_lunlun(K): for num in queue: if len(queue) >= K: return queue[K - 1] for i in range(-1, 2): last = num % 10 + i if last < 0 or last > 9: continue queue.append(num * 10 + la...
[["+", 64, 196, 0, 37, 0, 206, 206, 657, 31, 22]]
5
99
def count_lunlun(num): num = list(map(int, str(num))) d = len(num) dp = [[[[0] * 10 for _ in range(2)] for _ in range(2)] for _ in range(d + 1)] dp[0][0][0][0] = 1 for i in range(d): for j in range(2): for k in range(10): for z in range(2): for...
def count_lunlun(num): num = list(map(int, str(num))) d = len(num) dp = [[[[0] * 10 for _ in range(2)] for _ in range(2)] for _ in range(d + 1)] dp[0][0][0][0] = 1 for i in range(d): for j in range(2): for k in range(10): for z in range(2): for...
[["+", 0, 677, 31, 206, 51, 206, 206, 679, 17, 354], ["+", 0, 677, 31, 206, 51, 206, 206, 679, 12, 22]]
5
332
import queue k = int(input()) q = queue.Queue() x = -1 for i in range(1,10): q.put(i) for i in range(1,k+1): x = q.get() if x % 10 != 0: q.put(10 * x + (x % 10) - 1) q.put(10 * x + (x % 10)) if x % 9 != 0: q.put(10 * x + (x % 10) + 1) print(x)
import queue k = int(input()) q = queue.Queue() x = -1 for i in range(1,10): q.put(i) for i in range(1,k+1): x = q.get() if x % 10 != 0: q.put(10 * x + (x % 10) - 1) q.put(10 * x + (x % 10)) if x % 10 != 9: q.put(10 * x + (x % 10) + 1) print(x)
[["-", 8, 196, 0, 57, 15, 666, 0, 657, 12, 612], ["+", 8, 196, 0, 57, 15, 666, 0, 657, 12, 612], ["-", 0, 7, 8, 196, 0, 57, 15, 666, 0, 612], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 612]]
5
120
import queue K = int(input()) count = 0 q = queue.Queue() for i in range(1, 10): count += 1 q.put(i) if count == K: print(i) break result = 0 while count != K: tmp = q.get() # 先頭のキューを取り出す keta1 = tmp % 10 # 1の位を取得 for i in range(-1, 2): if keta1 == 0 and i == -1: ...
import queue K = int(input()) count = 0 q = queue.Queue() for i in range(1, 10): count += 1 q.put(i) if count == K: print(i) break result = 0 while count != K: tmp = q.get() # 先頭のキューを取り出す keta1 = tmp % 10 # 1の位を取得 for i in range(-1, 2): if keta1 == 0 and i == -1: # ...
[["-", 8, 196, 0, 57, 15, 679, 12, 666, 0, 612], ["+", 8, 196, 0, 57, 15, 679, 12, 666, 0, 612], ["+", 0, 1, 0, 662, 12, 657, 12, 23, 0, 24], ["+", 0, 1, 0, 662, 12, 657, 12, 23, 0, 25], ["-", 8, 196, 0, 7, 8, 196, 0, 93, 0, 94]]
5
135
a=[] def dfs(x): if x>3234566667: return a.append(x) for i in range(10): if abs(x%10-i) <= 1: dfs(x%10+i) for i in range(1,10): dfs(i) a =sorted(a) k=int(input()) print(a[k-1])
a = [] def dfs(x): if x > 3234566667: return a.append(x) for i in range(10): if abs(x%10-i) <= 1: dfs(x*10+i) for i in range(1, 10): dfs(i) a = sorted(a) k = int(input()) print(a[k-1])
[["-", 0, 652, 3, 4, 0, 657, 31, 657, 17, 109], ["+", 0, 652, 3, 4, 0, 657, 31, 657, 17, 48]]
5
87
#include <bits/stdc++.h> using namespace std; const int maxn = 1e2 + 10; typedef long long ll; ll n, k, dp[maxn][10], sum[maxn][10], tot, sum2[maxn][10]; char t[maxn]; int main() { for (int j = 0; j <= 9; j++) dp[1][j] = 1; for (int i = 2; i <= 18; i++) { for (int j = 0; j <= 9; j++) { dp[i][j] += dp[...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e2 + 10; typedef long long ll; ll n, k, dp[maxn][10], sum[maxn][10], tot, sum2[maxn][10]; char t[maxn]; int main() { for (int j = 0; j <= 9; j++) dp[1][j] = 1; for (int i = 2; i <= 18; i++) { for (int j = 0; j <= 9; j++) { dp[i][j] += dp[...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]]
1
621
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; using ll = long long; int main() { ll k; cin >> k; vector<ll> vec(k); for (int i = 1; i <= 9; i++) vec.push_back(i); while (1) { if (k <= vec.size()) { cout << vec[k - 1] << endl; return 0; ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; using ll = long long; int main() { ll k; cin >> k; vector<ll> vec; for (int i = 1; i <= 9; i++) vec.push_back(i); while (1) { if (k <= vec.size()) { cout << vec[k - 1] << endl; return 0; ...
[["-", 8, 9, 0, 43, 49, 53, 54, 55, 0, 24], ["-", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78], ["-", 8, 9, 0, 43, 49, 53, 54, 55, 0, 25]]
1
184
from collections import deque def lunlun(): k = int(input()) q = deque(list(range(1, 10))) while k > 0: k -= 1 n = q.popleft() # print('====== popleft:', n) if n % 10 != 0: n0 = int(str(n) + str(n % 10 - 1)) q.append(n0) # print('=== ap...
from collections import deque def lunlun(): k = int(input()) q = deque(list(range(1, 10))) while k > 0: k -= 1 n = q.popleft() # print('====== popleft:', n) if n % 10 != 0: n0 = int(str(n) + str(n % 10 - 1)) q.append(n0) # print('=== ap...
[["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 654], ["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 655], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 21]]
5
153
K = gets.to_i lunluns = [1, 2, 3, 4, 5, 6, 7, 8, 9] K.times do |i| break if lunluns.length > K if lunluns[i] % 10 == 0 lunluns << lunluns[i] * 10 lunluns << lunluns[i] * 10 + 1 elsif lunluns[i] % 10 == 9 lunluns << lunluns[i] * 10 + 8 lunluns << lunluns[i] * 10 + 9 else lunluns << lunluns[i]...
K = gets.to_i lunluns = [1, 2, 3, 4, 5, 6, 7, 8, 9] K.times do |i| break if lunluns.length > K if lunluns[i] % 10 == 0 lunluns << lunluns[i] * 10 lunluns << lunluns[i] * 10 + 1 elsif lunluns[i] % 10 == 9 lunluns << lunluns[i] * 10 + 8 lunluns << lunluns[i] * 10 + 9 else lunluns << lunluns[i]...
[["-", 0, 493, 0, 652, 3, 4, 0, 742, 500, 22], ["+", 0, 493, 0, 652, 3, 4, 0, 742, 500, 22]]
4
155
n = int(input()) lunlun = [[1,2,3,4,5,6,7,8,9]] for _ in range(2): tmp = [] for i in lunlun[-1]: if i % 10 == 0 : tmp.append(10 * i + i % 10) tmp.append(10 * i + i % 10 + 1) elif i % 10 == 9: tmp.append(10 * i + i % 10 - 1) tmp.append(10 * i + i %...
n = int(input()) lunlun = [[1,2,3,4,5,6,7,8,9]] for _ in range(9): tmp = [] for i in lunlun[-1]: if i % 10 == 0 : tmp.append(10 * i + i % 10) tmp.append(10 * i + i % 10 + 1) elif i % 10 == 9: tmp.append(10 * i + i % 10 - 1) tmp.append(10 * i + i %...
[["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612]]
5
195
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <map> #include <numeric> #include <set> #include <string> #include <vector> #define rep(i, x, n) for (int i = x; i < n; i++) using namespace std; const long long INF = 1LL << 60; int main() { int ...
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <map> #include <numeric> #include <set> #include <string> #include <vector> #define rep(i, x, n) for (int i = x; i < n; i++) using namespace std; const long long INF = 1LL << 60; int main() { int ...
[["-", 0, 57, 64, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 27, 28, 22]]
1
446
#include <cassert> #include <iostream> #include <vector> using namespace std; int H, W, K; vector<string> s; template <typename T> void print_vec(vector<T> &v) { for (auto i : v) cout << i << " "; cout << "\n"; } vector<int> cnt_whi(vector<int> &a, int w, int I) { int idx = 0; vector<int> res(__builtin_po...
#include <cassert> #include <iostream> #include <vector> using namespace std; int H, W, K; vector<string> s; template <typename T> void print_vec(vector<T> &v) { for (auto i : v) cout << i << " "; cout << "\n"; } vector<int> cnt_whi(vector<int> &a, int w, int I) { int idx = 0; vector<int> res(__builtin_po...
[["-", 0, 338, 8, 57, 15, 339, 51, 16, 17, 20], ["+", 0, 338, 8, 57, 15, 339, 51, 16, 17, 47]]
1
392