Datasets:

problem_id
stringlengths
6
6
buggy_code
stringlengths
8
526k
fixed_code
stringlengths
12
526k
labels
listlengths
0
15
buggy_submission_id
int64
1
1.54M
fixed_submission_id
int64
2
1.54M
user_id
stringlengths
10
10
language
stringclasses
9 values
p03089
#include <bits/stdc++.h> using namespace std; typedef long long ll; static const int MAX = 1e6; static const int NIL = -1; static const ll INF = 1 << 21; static const ll MOD = 1e9 + 7; bool compPair(const pair<int, int> &arg1, const pair<int, int> &arg2) { return arg1.first > arg2.first; } int main(void) { int N; cin >> N; list<int> L; vector<int> ans(N); int b; for (int i = 0; i < N; i++) { cin >> b; L.push_back(b); } int now_val, j; auto now_itr = L.begin(); for (int i = 0; i < N; i++) { j = 1; now_val = 0; now_itr = L.begin(); for (auto itr = L.begin(); itr != L.end(); itr++) { if (*itr == j) { now_val++; now_itr = itr; } j++; } if (now_val) { ans.at(i) = now_val; L.erase(now_itr); } else { cout << -1 << endl; return 0; } } for (int i = N - 1; i >= 0; i--) { cout << ans.at(i) << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; static const int MAX = 1e6; static const int NIL = -1; static const ll INF = 1 << 21; static const ll MOD = 1e9 + 7; bool compPair(const pair<int, int> &arg1, const pair<int, int> &arg2) { return arg1.first > arg2.first; } int main(void) { int N; cin >> N; list<int> L; vector<int> ans(N); int b; for (int i = 0; i < N; i++) { cin >> b; L.push_back(b); } int now_val, j; auto now_itr = L.begin(); for (int i = 0; i < N; i++) { j = 1; now_val = 0; now_itr = L.begin(); for (auto itr = L.begin(); itr != L.end(); ++itr) { if (*itr == j) { now_val = *itr; now_itr = itr; } j++; } if (now_val) { ans.at(i) = now_val; L.erase(now_itr); } else { cout << -1 << endl; return 0; } } for (int i = N - 1; i >= 0; i--) { cout << ans.at(i) << endl; } return 0; }
[]
904,073
904,074
u616090453
cpp
p03089
#include <bits/stdc++.h> using namespace std; #define pb push_back #define fi first #define se second #define mp make_pair #define all(x) (x).begin(), (x).end() #define rep(i, n) for (int i = 0; i < (n); ++i) #define repp(i, a, b) for (int i = a; i <= (b); ++i) #define repr(i, a, b) for (int i = a; i >= (b); --i) #define bit(n) (1LL << (n)) #define len(x) ((ll)(x).size()) #define debug(var) cout << "[" << #var << "]\n" << var << "\n\n" typedef long long ll; const int INF = 1001001001; const ll LINF = 1001001001001001001ll; const int MOD = 1000000007; const double EPS = 1e-9; template <typename T> ostream &operator<<(ostream &s, const vector<T> &v) { int len = v.size(); for (int i = 0; i < len; ++i) { s << v[i]; if (i < len - 1) s << ' '; } return s; } template <typename T> ostream &operator<<(ostream &s, const vector<vector<T>> &vv) { int len = vv.size(); for (int i = 0; i < len; ++i) { s << vv[i]; if (i != len - 1) cout << '\n'; } return s; } 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; } __attribute__((constructor)) void initial() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } signed main() { int N; cin >> N; vector<int> b(N); rep(i, N) { cin >> b[i]; b[i]--; } vector<int> ans(N); rep(i, N) { int pos = -1; rep(j, N - i) { if (j == b[j]) { pos = j; } else break; } if (pos == -1) { cout << -1 << '\n'; return 0; } ans[i] = pos + 1; b.erase(b.begin() + pos); } reverse(all(ans)); rep(i, len(ans)) { cout << ans[i] << "\n"; } }
#include <bits/stdc++.h> using namespace std; #define pb push_back #define fi first #define se second #define mp make_pair #define all(x) (x).begin(), (x).end() #define rep(i, n) for (int i = 0; i < (n); ++i) #define repp(i, a, b) for (int i = a; i <= (b); ++i) #define repr(i, a, b) for (int i = a; i >= (b); --i) #define bit(n) (1LL << (n)) #define len(x) ((ll)(x).size()) #define debug(var) cout << "[" << #var << "]\n" << var << "\n\n" typedef long long ll; const int INF = 1001001001; const ll LINF = 1001001001001001001ll; const int MOD = 1000000007; const double EPS = 1e-9; template <typename T> ostream &operator<<(ostream &s, const vector<T> &v) { int len = v.size(); for (int i = 0; i < len; ++i) { s << v[i]; if (i < len - 1) s << ' '; } return s; } template <typename T> ostream &operator<<(ostream &s, const vector<vector<T>> &vv) { int len = vv.size(); for (int i = 0; i < len; ++i) { s << vv[i]; if (i != len - 1) cout << '\n'; } return s; } 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; } __attribute__((constructor)) void initial() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } signed main() { int N; cin >> N; vector<int> b(N); rep(i, N) { cin >> b[i]; b[i]--; } vector<int> ans(N); rep(i, N) { int pos = -1; rep(j, N - i) { if (j == b[j]) { pos = j; } } if (pos == -1) { cout << -1 << '\n'; return 0; } ans[i] = pos + 1; b.erase(b.begin() + pos); } reverse(all(ans)); rep(i, len(ans)) { cout << ans[i] << "\n"; } }
[ "control_flow.branch.else.remove" ]
904,075
904,076
u995725911
cpp
p03089
#include <bits/stdc++.h> #define REP(i, n) for (ll i = 0; i < (ll)n; i++) #define FOR(i, a, b) for (ll i = (a); i < (ll)b; i++) #define ALL(obj) (obj).begin(), (obj).end() #define INF (1ll << 60) #define sz(x) int(x.size()) using namespace std; typedef long long ll; using vl = vector<ll>; using vvl = vector<vl>; typedef double db; typedef string str; typedef pair<ll, ll> p; constexpr int MOD = 1000000007; using ll = long long; 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; } void print(const std::vector<int> &v) { std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; }); std::cout << std::endl; } // http://drken1215.hatenablog.com/entry/2019/03/24/091900 int main() { int N; cin >> N; vector<int> b(N); REP(i, N) { cin >> b[i]; b[i]--; } print(b); vector<int> res; for (int i = 0; i < N; i++) { //文字数分 int pivot = -1; for (int j = (int)b.size() - 1; j >= 0; j--) { // stringを逆順に走査する if (b[j] == j) { pivot = j; break; } } if (pivot == -1) { cout << -1 << endl; return 0; } res.push_back(pivot + 1); b.erase(b.begin() + pivot); } reverse(res.begin(), res.end()); for (auto v : res) { cout << v << endl; } return 0; }
#include <bits/stdc++.h> #define REP(i, n) for (ll i = 0; i < (ll)n; i++) #define FOR(i, a, b) for (ll i = (a); i < (ll)b; i++) #define ALL(obj) (obj).begin(), (obj).end() #define INF (1ll << 60) #define sz(x) int(x.size()) using namespace std; typedef long long ll; using vl = vector<ll>; using vvl = vector<vl>; typedef double db; typedef string str; typedef pair<ll, ll> p; constexpr int MOD = 1000000007; using ll = long long; 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; } void print(const std::vector<int> &v) { std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; }); std::cout << std::endl; } // http://drken1215.hatenablog.com/entry/2019/03/24/091900 int main() { int N; cin >> N; vector<int> b(N); REP(i, N) { cin >> b[i]; b[i]--; } // print(b); vector<int> res; for (int i = 0; i < N; i++) { //文字数分 int pivot = -1; for (int j = (int)b.size() - 1; j >= 0; j--) { // stringを逆順に走査する if (b[j] == j) { pivot = j; break; } } if (pivot == -1) { cout << -1 << endl; return 0; } res.push_back(pivot + 1); b.erase(b.begin() + pivot); } reverse(res.begin(), res.end()); for (auto v : res) { cout << v << endl; } return 0; }
[ "call.remove" ]
904,079
904,080
u824337972
cpp
p03089
#include <bits/stdc++.h> #define REP(i, n) for (ll i = 0; i < (ll)n; i++) #define FOR(i, a, b) for (ll i = (a); i < (ll)b; i++) #define ALL(obj) (obj).begin(), (obj).end() #define INF (1ll << 60) #define sz(x) int(x.size()) using namespace std; typedef long long ll; using vl = vector<ll>; using vvl = vector<vl>; typedef double db; typedef string str; typedef pair<ll, ll> p; constexpr int MOD = 1000000007; using ll = long long; 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; } void print(const std::vector<ll> &v) { std::for_each(v.begin(), v.end(), [](ll x) { std::cout << x << " "; }); std::cout << std::endl; } // http://drken1215.hatenablog.com/entry/2019/03/24/091900 int main() { int N; cin >> N; vector<int> b(N); REP(i, N) { cin >> b[i]; b[i]--; } vector<int> res; for (int i = 0; i < N; i++) { //文字数分 int pivot = -1; for (int j = (int)b.size() - 1; j >= 0; j--) { // stringを逆順に走査する if (b[j] == j) { pivot = j; break; } if (pivot == -1) { cout << -1 << endl; return 0; } res.push_back(pivot + 1); b.erase(b.begin() + pivot); } } reverse(res.begin(), res.end()); for (auto v : res) { cout << v << endl; } return 0; }
#include <bits/stdc++.h> #define REP(i, n) for (ll i = 0; i < (ll)n; i++) #define FOR(i, a, b) for (ll i = (a); i < (ll)b; i++) #define ALL(obj) (obj).begin(), (obj).end() #define INF (1ll << 60) #define sz(x) int(x.size()) using namespace std; typedef long long ll; using vl = vector<ll>; using vvl = vector<vl>; typedef double db; typedef string str; typedef pair<ll, ll> p; constexpr int MOD = 1000000007; using ll = long long; 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; } void print(const std::vector<int> &v) { std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; }); std::cout << std::endl; } // http://drken1215.hatenablog.com/entry/2019/03/24/091900 int main() { int N; cin >> N; vector<int> b(N); REP(i, N) { cin >> b[i]; b[i]--; } // print(b); vector<int> res; for (int i = 0; i < N; i++) { //文字数分 int pivot = -1; for (int j = (int)b.size() - 1; j >= 0; j--) { // stringを逆順に走査する if (b[j] == j) { pivot = j; break; } } if (pivot == -1) { cout << -1 << endl; return 0; } res.push_back(pivot + 1); b.erase(b.begin() + pivot); } reverse(res.begin(), res.end()); for (auto v : res) { cout << v << endl; } return 0; }
[ "call.arguments.change" ]
904,081
904,080
u824337972
cpp
p03089
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> v(N); for (int i = 0; i < N; i++) cin >> v[i]; vector<int> r(N); for (int i = N - 1; i >= 0; i--) { int p = -1; for (int j = 0; j < N; j++) { if (v[j] == j + 1) p = j; } if (p == -1) { cout << -1 << endl; return 0; } r[i] = p + 1; v.erase(v.begin() + p); } for (int i = 0; i < N; i++) cout << r[i] << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> v(N); for (int i = 0; i < N; i++) cin >> v[i]; vector<int> r(N); for (int i = N - 1; i >= 0; i--) { int p = -1; for (int j = 0; j < v.size(); j++) { if (v[j] == j + 1) p = j; } if (p == -1) { cout << -1 << endl; return 0; } r[i] = p + 1; v.erase(v.begin() + p); } for (int i = 0; i < N; i++) cout << r[i] << endl; }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.change", "call.add" ]
904,082
904,083
u946322619
cpp
p03089
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000000 + 7; //マクロ //型エイリアス using ll = long long; using P = pair<long long, long long>; using vl = vector<long long>; //ショートカット #define rep(i, n) for (int i = 0; i < n; i++) #define rep2(i, k, n) for (int i = k; i < n; i++) #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define pb push_back //入力 #define vin(v, N) \ for (long long i = 0; i < N; i++) \ cin >> v.at(i) #define lin(n) \ long long n; \ cin >> n #define vlin(v, N) \ vector<long long> v(N); \ for (long long i = 0; i < N; i++) \ cin >> v.at(i) //関数 //最大公約数 long long gcd(long long m, long long n) { long long a = max(m, n); long long b = min(m, n); long long r = a % b; while (r != 0) { a = b; b = r; r = a % b; } return b; } // 最小公倍数 long long lcd(long long m, long long n) { return m * n / gcd(m, n); } // xのn乗 long long power(long long x, long long N) { long long ret = 1; for (long long i = 0; i < N; i++) ret *= x; return ret; } //素因数分解(mapで返す) map<long long, long long> factor(long long p) { ll p1 = p; map<long long, long long> ret; for (long long i = 2; i * i <= p1; i++) { while (p % i == 0) { ret[i]++; p /= i; } } if (p != 1) ret[p]++; return ret; } //素数判定 bool is_prime(long long N) { for (long long i = 2; i * i <= N; i++) { if (N % i == 0) return false; } return true; } //最大値更新 void chmax(long long &a, long long b) { a = max(a, b); } //最小値更新 void chmin(long long &a, long long b) { a = min(a, b); } //メイン関数 int main() { // doubleの桁数 cout << fixed << setprecision(10); lin(N); vector<P> b(N); rep(i, N) { cin >> b[i].first; b[i].second = i + 1 - b[i].first; } vl a(N); bool NG = false; int count = N - 1; for (int i = 0; i < N; i++) { for (int j = N - 1; j >= 0; j--) { if (b[j].second == 0) { a[count] = b[j].first; count--; for (int k = j; k < N; k++) b[k].second--; break; } if (j == 0) NG = false; } } // a.reverse(all(a)); if (NG) cout << -1; else { rep(i, N) cout << a[i] << endl; } }
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000000 + 7; //マクロ //型エイリアス using ll = long long; using P = pair<long long, long long>; using vl = vector<long long>; //ショートカット #define rep(i, n) for (int i = 0; i < n; i++) #define rep2(i, k, n) for (int i = k; i < n; i++) #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define pb push_back //入力 #define vin(v, N) \ for (long long i = 0; i < N; i++) \ cin >> v.at(i) #define lin(n) \ long long n; \ cin >> n #define vlin(v, N) \ vector<long long> v(N); \ for (long long i = 0; i < N; i++) \ cin >> v.at(i) //関数 //最大公約数 long long gcd(long long m, long long n) { long long a = max(m, n); long long b = min(m, n); long long r = a % b; while (r != 0) { a = b; b = r; r = a % b; } return b; } // 最小公倍数 long long lcd(long long m, long long n) { return m * n / gcd(m, n); } // xのn乗 long long power(long long x, long long N) { long long ret = 1; for (long long i = 0; i < N; i++) ret *= x; return ret; } //素因数分解(mapで返す) map<long long, long long> factor(long long p) { ll p1 = p; map<long long, long long> ret; for (long long i = 2; i * i <= p1; i++) { while (p % i == 0) { ret[i]++; p /= i; } } if (p != 1) ret[p]++; return ret; } //素数判定 bool is_prime(long long N) { for (long long i = 2; i * i <= N; i++) { if (N % i == 0) return false; } return true; } //最大値更新 void chmax(long long &a, long long b) { a = max(a, b); } //最小値更新 void chmin(long long &a, long long b) { a = min(a, b); } //メイン関数 int main() { // doubleの桁数 cout << fixed << setprecision(10); lin(N); vector<P> b(N); rep(i, N) { cin >> b[i].first; b[i].second = i + 1 - b[i].first; } vl a(N); bool NG = false; int count = N - 1; for (int i = 0; i < N; i++) { for (int j = N - 1; j >= 0; j--) { if (b[j].second == 0) { a[count] = b[j].first; count--; for (int k = j; k < N; k++) b[k].second--; break; } if (j == 0) NG = true; } } // a.reverse(all(a)); if (NG) cout << -1; else { rep(i, N) cout << a[i] << endl; } }
[ "misc.opposites", "assignment.value.change" ]
904,086
904,087
u652009496
cpp
p03089
#include <bits/stdc++.h> using namespace std; int main() { // int num; cin >> num; vector<int> vec(num); vector<int> vec2; for (int i = 0; i < num; i++) cin >> vec.at(i), vec.at(i)--; for (int i = 0; i < num; i++) { int ans = -1; for (int j = vec.size() - 1; j >= 0; j--) { if (vec.at(j) == j) { ans = j; break; } } if (ans == -1) { cout << ans; return 0; } vec2.push_back(ans + 1); vec.erase(vec.begin() + ans); } reverse(vec2.begin(), vec2.end()); for (int i = 0; i < vec2.size() - 1; i++) cout << vec2.at(i) + 1 << endl; // }
#include <bits/stdc++.h> using namespace std; int main() { // int num; cin >> num; vector<int> vec(num); vector<int> vec2; for (int i = 0; i < num; i++) cin >> vec.at(i), vec.at(i)--; for (int i = 0; i < num; i++) { int ans = -1; for (int j = vec.size() - 1; j >= 0; j--) { if (vec.at(j) == j) { ans = j; break; } } if (ans == -1) { cout << ans; return 0; } vec2.push_back(ans + 1); vec.erase(vec.begin() + ans); } reverse(vec2.begin(), vec2.end()); for (int i = 0; i < vec2.size(); i++) cout << vec2.at(i) << endl; // }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
904,102
904,101
u367131219
cpp
p03089
#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 main() { int n; cin >> n; vector<int> b(n); vector<int> ans; rep(i, n) { cin >> b[i]; } int k, k2 = 0; rep(i, n) { k = n - i; rep(j, n) { if (b[n - j - 1] == k) { // cout << k << n-j-1 << endl; b[n - j - 1] = 0; ans.push_back(k); break; } if (b[n - j - 1] != 0) { --k; } if (j == n - 1) { // cout << i << endl; k2 = 1; } } } if (k2 == 0) { rep(i, n) { cout << ans[n - i - 1] << endl; } } else { cout << -1 << endl; } return 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 main() { int n; cin >> n; vector<int> b(n); vector<int> ans; rep(i, n) { cin >> b[i]; } int k, k2 = 0; rep(i, n) { k = n - i; rep(j, n) { // cout << k << endl; if (b[n - j - 1] == k) { // cout << k << n-j-1 << endl; b[n - j - 1] = -10; ans.push_back(k); break; } if (b[n - j - 1] != -10) { --k; } if (j == n - 1) { // cout << i << endl; k2 = 1; } } } if (k2 == 0) { rep(i, n) { cout << ans[n - i - 1] << endl; } } else { cout << -1 << endl; } return 0; }
[ "literal.number.change", "assignment.value.change", "control_flow.branch.if.condition.change" ]
904,110
904,111
u992471673
cpp
p03089
#include <bits/stdc++.h> #ifdef __DEBUG__ #define DBG(X) cout << #X << " = " << (X) << endl; #define SAY(X) cout << (X) << endl; #else #define DBG(X) #define SAY(X) #endif using namespace std; using ll = long long int; using ull = unsigned long long int; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; int dx[] = {1, 0, -1, 0, 1, -1, 1, -1}; int dy[] = {0, 1, 0, -1, 1, 1, -1, -1}; const int INT_INF = (int)(2e9); const ll LL_INF = (ll)(2e18); inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }; template <typename T, typename S> inline ostream &operator<<(ostream &os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; } template <typename T, typename S> inline ostream &operator<<(ostream &os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; } template <typename T> inline ostream &operator<<(ostream &os, const vector<T> &v) { for (auto el : v) cout << el << " "; return os; } template <typename T> inline ostream &operator<<(ostream &os, const deque<T> &v) { for (auto el : v) cout << el << " "; return os; } template <typename T> inline ostream &operator<<(ostream &os, const set<T> &v) { for (auto el : v) cout << el << " "; return os; } template <typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto &elem : ret) cin >> elem; return ret; } int N; vector<int> B; void input() { fast_io(); cin >> N; B = fetch_vec<int>(N); } bool solve() { for (int i = 0; i < N; i++) { if (B[i] > i + 1) return false; } vector<int> ans; while (!B.empty()) { for (int i = B.size() - 1; i >= 0; i--) { if (B[i] == i + 1) { ans.push_back(i + 1); B.erase(B.begin() + i); break; } } } sort(ans.begin(), ans.end()); for (auto a : ans) cout << a << endl; return true; } int main() { input(); if (!solve()) cout << -1 << endl; return 0; }
#include <bits/stdc++.h> #ifdef __DEBUG__ #define DBG(X) cout << #X << " = " << (X) << endl; #define SAY(X) cout << (X) << endl; #else #define DBG(X) #define SAY(X) #endif using namespace std; using ll = long long int; using ull = unsigned long long int; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; int dx[] = {1, 0, -1, 0, 1, -1, 1, -1}; int dy[] = {0, 1, 0, -1, 1, 1, -1, -1}; const int INT_INF = (int)(2e9); const ll LL_INF = (ll)(2e18); inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }; template <typename T, typename S> inline ostream &operator<<(ostream &os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; } template <typename T, typename S> inline ostream &operator<<(ostream &os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; } template <typename T> inline ostream &operator<<(ostream &os, const vector<T> &v) { for (auto el : v) cout << el << " "; return os; } template <typename T> inline ostream &operator<<(ostream &os, const deque<T> &v) { for (auto el : v) cout << el << " "; return os; } template <typename T> inline ostream &operator<<(ostream &os, const set<T> &v) { for (auto el : v) cout << el << " "; return os; } template <typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto &elem : ret) cin >> elem; return ret; } int N; vector<int> B; void input() { fast_io(); cin >> N; B = fetch_vec<int>(N); } bool solve() { for (int i = 0; i < N; i++) { if (B[i] > i + 1) return false; } vector<int> ans; while (!B.empty()) { for (int i = B.size() - 1; i >= 0; i--) { if (B[i] == i + 1) { ans.push_back(i + 1); B.erase(B.begin() + i); break; } } } reverse(ans.begin(), ans.end()); for (auto a : ans) cout << a << endl; return true; } int main() { input(); if (!solve()) cout << -1 << endl; return 0; }
[ "identifier.change", "call.function.change" ]
904,114
904,115
u858670323
cpp
p03089
#include <bits/stdc++.h> using namespace std; #define rep(i, cc, n) for (int i = cc; i < n; ++i) #define lrep(i, cc, n) for (long long i = cc; i < n; ++i) #define rrep(i, cc, n) for (int i = cc; i >= n; --i) #define pii pair<int, int> #define pll pair<long long, long long> using ll = long long; int n; vector<int> a; void solve() { vector<int> ans; rep(i, 0, n) { int k = -1; rrep(j, a.size() - 1, 0) { if (a[j] == j) { k = j; break; } } if (k == -1) { cout << -1 << endl; return; } ans.push_back(k + 1); a.erase(a.begin() + k); } reverse(a.begin(), a.end()); rep(i, 0, n) { cout << ans[i] << endl; } } int main() { cin >> n; a.resize(n); rep(i, 0, n) { cin >> a[i]; a[i]--; } solve(); }
#include <bits/stdc++.h> using namespace std; #define rep(i, cc, n) for (int i = cc; i < n; ++i) #define lrep(i, cc, n) for (long long i = cc; i < n; ++i) #define rrep(i, cc, n) for (int i = cc; i >= n; --i) #define pii pair<int, int> #define pll pair<long long, long long> using ll = long long; int n; vector<int> a; void solve() { vector<int> ans; rep(i, 0, n) { int k = -1; rrep(j, a.size() - 1, 0) { if (a[j] == j) { k = j; break; } } if (k == -1) { cout << -1 << endl; return; } ans.push_back(k + 1); a.erase(a.begin() + k); } reverse(ans.begin(), ans.end()); rep(i, 0, n) { cout << ans[i] << endl; } } int main() { cin >> n; a.resize(n); rep(i, 0, n) { cin >> a[i]; a[i]--; } solve(); }
[ "identifier.change", "call.arguments.change" ]
904,118
904,119
u330518333
cpp
p03089
#include <bits/stdc++.h> using namespace std; #define REP(i, start, count) for (int i = (start); i < (int)(count); ++i) #define rep(i, count) REP(i, 0, count) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; typedef unsigned long long ull; typedef vector<int> veci; typedef vector<long long> vecll; typedef vector<unsigned long long> vecull; int N; int main(void) { cin >> N; veci b(N); rep(i, N) { cin >> b[i]; b[i]--; } bool flag = true; stack<int> ans; while (b.size() != 0) { int k = -1; for (int i = 0; i < b.size(); ++i) { if (b[i] == i) { k = i; continue; } break; } if (k == -1) { flag = false; break; } ans.push(k); b.erase(b.begin() + k); } if (!flag) { cout << -1 << endl; return 0; } while (!ans.empty()) { cout << ans.top() + 1 << endl; ans.pop(); } return 0; }
#include <bits/stdc++.h> using namespace std; #define REP(i, start, count) for (int i = (start); i < (int)(count); ++i) #define rep(i, count) REP(i, 0, count) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; typedef unsigned long long ull; typedef vector<int> veci; typedef vector<long long> vecll; typedef vector<unsigned long long> vecull; int N; int main(void) { cin >> N; veci b(N); rep(i, N) { cin >> b[i]; b[i]--; } bool flag = true; stack<int> ans; while (b.size() != 0) { int k = -1; for (int i = 0; i < b.size(); ++i) { if (b[i] == i) { k = i; } } if (k == -1) { flag = false; break; } ans.push(k); b.erase(b.begin() + k); } if (!flag) { cout << -1 << endl; return 0; } while (!ans.empty()) { cout << ans.top() + 1 << endl; ans.pop(); } return 0; }
[]
904,124
904,125
u159231764
cpp
p03089
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> b(N), ans(N, 0); for (int i = 0; i < N; i++) { cin >> b[i]; if (b[i] > i + 1) { cout << -1 << endl; return 0; } } int num, loc; for (int i = N - 1; i >= 0; i--) { num = i - (b[i] - 1); loc = N - 1; while (loc >= 0) { if (num == 0) { ans[loc] = b[i]; break; } if (ans[loc - 1] == 0) { num--; } loc--; } } for (int i = 0; i < N; i++) { cout << ans[i] << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> b(N), ans(N, 0); for (int i = 0; i < N; i++) { cin >> b[i]; if (b[i] > i + 1) { cout << -1 << endl; return 0; } } int num, loc; for (int i = N - 1; i >= 0; i--) { num = i - (b[i] - 1) + 1; loc = N; while (loc >= 0) { if (num == 0) { ans[loc] = b[i]; break; } if (ans[loc - 1] == 0) { num--; } loc--; } } for (int i = 0; i < N; i++) { cout << ans[i] << endl; } }
[ "assignment.change", "expression.operation.binary.remove" ]
904,128
904,129
u912534104
cpp
p03087
#include <bits/stdc++.h> #define mins(a, b) a = min(a, b) #define maxs(a, b) a = max(a, b) using namespace std; int main() { int n, q; int x[100010]; for (int r = 0; r < 100010; r++) { x[r] = 0; } cin >> n >> q; string s; cin >> s; pair<int, int> len[q]; for (int i = 0; i < q; i++) { cin >> len[i].first >> len[i].second; } for (int i = 1; i <= 100010; i++) { if (s[i - 1] == 'A' and s[i] == 'C') x[i] = 1 + x[i - 1]; else x[i] += x[i - 1]; } for (int i = 0; i < q; i++) { cout << x[len[i].second - 1] - x[len[i].first - 1] << endl; } }
#include <bits/stdc++.h> #define mins(a, b) a = min(a, b) #define maxs(a, b) a = max(a, b) using namespace std; int main() { int n, q; int x[100010]; for (int r = 0; r < 100010; r++) { x[r] = 0; } cin >> n >> q; string s; cin >> s; pair<int, int> len[q]; for (int i = 0; i < q; i++) { cin >> len[i].first >> len[i].second; } for (int i = 1; i < s.size(); i++) { if (s[i - 1] == 'A' and s[i] == 'C') x[i] = 1 + x[i - 1]; else x[i] += x[i - 1]; } for (int i = 0; i < q; i++) { cout << x[len[i].second - 1] - x[len[i].first - 1] << endl; } }
[ "control_flow.loop.for.condition.change", "call.add" ]
904,138
904,139
u127856129
cpp
p03087
#include <bits/stdc++.h> #define mins(a, b) a = min(a, b) #define maxs(a, b) a = max(a, b) using namespace std; int main() { int n, q; int x[100010]; for (int r = 0; r < 100010; r++) { x[r] = 0; } cin >> n >> q; string s; cin >> s; pair<int, int> len[q]; for (int i = 0; i < q; i++) { cin >> len[i].first >> len[i].second; } for (int i = 1; i <= 100010; i++) { if (s[i - 1] == 'A' and s[i] == 'C') x[i] = 1 + x[i - 1]; else x[i] += x[i - 1]; } for (int i = 0; i < q; i++) { cout << x[len[i].second - 1] - x[len[i].first - 1] << endl; } }
#include <bits/stdc++.h> #define mins(a, b) a = min(a, b) #define maxs(a, b) a = max(a, b) using namespace std; int main() { int n, q; int x[100010]; for (int r = 0; r < 100010; r++) { x[r] = 0; } cin >> n >> q; string s; cin >> s; pair<int, int> len[q]; for (int i = 0; i < q; i++) { cin >> len[i].first >> len[i].second; } for (int i = 1; i <= s.size(); i++) { if (s[i - 1] == 'A' and s[i] == 'C') x[i] = 1 + x[i - 1]; else x[i] += x[i - 1]; } for (int i = 0; i < q; i++) { cout << x[len[i].second - 1] - x[len[i].first - 1] << endl; } }
[ "identifier.replace.add", "literal.replace.remove", "control_flow.loop.for.condition.change", "expression.operation.binary.change", "call.add" ]
904,138
904,141
u127856129
cpp
p03089
// 2019.5.15 by ljz #include <bits/stdc++.h> using namespace std; #define res register int #define LL long long #define inf 0x3f3f3f3f #define eps 1e-10 #define RG register inline int read() { res s = 0, ch = getchar(), w = 1; while (ch < '0' || ch > '9') { if (ch == '-') w = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar(); return s * w; } inline LL Read() { RG LL s = 0; res ch = getchar(); while (ch < '0' || ch > '9') ch = getchar(); while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar(); return s; } inline void swap(res &x, res &y) { x ^= y ^= x ^= y; } mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); namespace MAIN { int n; vector<int> a, ans; #define pb push_back inline void MAIN() { n = read(); for (res i = 0; i < n; i++) a.pb(read() - 1); for (res i = 0; i < n; i++) { res p = -1; for (res j = 0; j < n - i; j++) if (a[j] == j) p = j; if (p == -1) { puts("-1"); return; } ans.pb(p), a.erase(a.begin() + p); } sort(ans.begin(), ans.end()); for (res i = 0; i < n; i++) printf("%d\n", ans[i] + 1); } } // namespace MAIN int main() { // srand((unsigned)time(NULL)); // freopen("graph.in","r",stdin); // freopen("graph.out","w",stdout); MAIN::MAIN(); return 0; }
// 2019.5.15 by ljz #include <bits/stdc++.h> using namespace std; #define res register int #define LL long long #define inf 0x3f3f3f3f #define eps 1e-10 #define RG register inline int read() { res s = 0, ch = getchar(), w = 1; while (ch < '0' || ch > '9') { if (ch == '-') w = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar(); return s * w; } inline LL Read() { RG LL s = 0; res ch = getchar(); while (ch < '0' || ch > '9') ch = getchar(); while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar(); return s; } inline void swap(res &x, res &y) { x ^= y ^= x ^= y; } mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); namespace MAIN { int n; vector<int> a, ans; #define pb push_back inline void MAIN() { n = read(); for (res i = 0; i < n; i++) a.pb(read() - 1); for (res i = 0; i < n; i++) { res p = -1; for (res j = 0; j < n - i; j++) if (a[j] == j) p = j; if (p == -1) { puts("-1"); return; } ans.pb(p), a.erase(a.begin() + p); } reverse(ans.begin(), ans.end()); for (res i = 0; i < n; i++) printf("%d\n", ans[i] + 1); } } // namespace MAIN int main() { // srand((unsigned)time(NULL)); // freopen("graph.in","r",stdin); // freopen("graph.out","w",stdout); MAIN::MAIN(); return 0; }
[ "identifier.change", "call.function.change" ]
904,170
904,171
u920156500
cpp
p03089
#include <iostream> #include <vector> using namespace std; int main() { int N; cin >> N; int b_tmp; vector<int> b; for (int i = 0; i < N; i++) { cin >> b_tmp; b.push_back(b_tmp); } vector<int> operate; bool is_continue = true, is_erase = false; while (is_continue) { is_erase = false; for (int i = b.size() - 1; i >= 0; i--) { if (i + 1 == b[i]) { operate.push_back(b[i]); b.erase(b.begin() + i); is_erase = true; } } if (b.size() == 0) is_continue = false; else if (is_erase == false) is_continue = false; } if (is_erase == false) cout << -1 << endl; else { for (int i = operate.size() - 1; i >= 0; i--) { cout << operate[i] << endl; } } return 0; }
#include <iostream> #include <vector> using namespace std; int main() { int N; cin >> N; int b_tmp; vector<int> b; for (int i = 0; i < N; i++) { cin >> b_tmp; b.push_back(b_tmp); } vector<int> operate; bool is_continue = true, is_erase = false; while (is_continue) { is_erase = false; for (int i = b.size() - 1; i >= 0; i--) { if (i + 1 == b[i]) { operate.push_back(b[i]); b.erase(b.begin() + i); is_erase = true; break; } } if (b.size() == 0) is_continue = false; else if (is_erase == false) is_continue = false; } if (is_erase == false) cout << -1 << endl; else { for (int i = operate.size() - 1; i >= 0; i--) { cout << operate[i] << endl; } } return 0; }
[ "control_flow.break.add" ]
904,177
904,176
u785644520
cpp
p03089
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> b(n), a(n); for (int i = 0; i < n; i++) cin >> b[i]; for (int j = 0; j < n; j++) { for (int i = n - 1; i >= 0; i--) { if (i + 1 == b[i]) { a[j] = b[i]; b.erase(b.begin() + i); break; } } } if (a[n - 1] != 1) cout << -1 << endl; else { for (int i = n - 1; i >= 0; i--) cout << a[i] << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> b(n), a(n); for (int i = 0; i < n; i++) cin >> b[i]; for (int j = 0; j < n; j++) { for (int i = b.size() - 1; i >= 0; i--) { if (i + 1 == b[i]) { a[j] = b[i]; b.erase(b.begin() + i); break; } } } if (a[n - 1] != 1) cout << -1 << endl; else { for (int i = n - 1; i >= 0; i--) cout << a[i] << endl; } }
[ "control_flow.loop.for.initializer.change", "expression.operation.binary.change", "call.add" ]
904,186
904,187
u513726585
cpp
p03089
#include <algorithm> #include <functional> #include <iostream> #include <queue> #include <vector> #define REP(i, N) for (int i = 0; i < N; ++i) using namespace std; int main() { int N; cin >> N; vector<int> line(N); REP(i, N) { cin >> line[i]; } vector<int> ans; while (!line.empty()) { int pl = -1; for (int i = 0; i < N; ++i) { if (line[i] == i + 1) { pl = i; } } if (pl == -1) { cout << -1 << endl; return 0; } ans.push_back(pl + 1); line.erase(line.begin() + pl); } reverse(ans.begin(), ans.end()); for (int i = 0; i < N; ++i) { cout << ans[i] << endl; } return 0; }
#include <algorithm> #include <functional> #include <iostream> #include <queue> #include <vector> #define REP(i, N) for (int i = 0; i < N; ++i) using namespace std; int main() { int N; cin >> N; vector<int> line(N); REP(i, N) { cin >> line[i]; } vector<int> ans; while (!line.empty()) { int pl = -1; for (int i = 0; i < line.size(); ++i) { if (line[i] == i + 1) { pl = i; } } if (pl == -1) { cout << -1 << endl; return 0; } ans.push_back(pl + 1); line.erase(line.begin() + pl); } reverse(ans.begin(), ans.end()); for (int i = 0; i < N; ++i) { cout << ans[i] << endl; } return 0; }
[ "control_flow.loop.condition.change", "control_flow.loop.for.condition.change", "call.add" ]
904,192
904,193
u074014027
cpp
p03089
/* ----------------------------------------------------------------------------- Author : --------------------------------------------------------- UTKARSH SAXENA --------------------------------------------------------- GOOGLE --------------------------------------------------------- ----------------------------------------------------------------------------- */ #include <algorithm> #include <iostream> #include <map> #include <set> #include <vector> using namespace std; #define fre freopen("0.in", "r", stdin), freopen("0.out", "w", stdout) #define abs(x) ((x) > 0 ? (x) : -(x)) #define MOD 1000000007 #define LL signed long long int #define ps(x) push_back(x) #define scan(x) scanf("%d", &x) #define print(x) printf("%d\n", x) #define scanll(x) scanf("%lld", &x) #define printll(x) printf("%lld\n", x) #define boost ios_base::sync_with_stdio(0) // vector<int> g[2*100000+5];int par[2*100000+5]; int main() { fre; int N; cin >> N; std::vector<int> v; for (int i = 1; i <= N; ++i) { int x; cin >> x; v.push_back(x); } int ok = 1; std::vector<int> res; for (int i = N; i >= 1; --i) { int found = 0; for (int j = i; j >= 1; j--) { if (v[j - 1] == j) { found = j; break; } } if (found == 0) { ok = 0; break; } res.push_back(found); v.erase(v.begin() + found - 1); } if (!ok) cout << -1; else for (int i = N - 1; i >= 0; i--) cout << res[i] << endl; }
/* ----------------------------------------------------------------------------- Author : --------------------------------------------------------- UTKARSH SAXENA --------------------------------------------------------- GOOGLE --------------------------------------------------------- ----------------------------------------------------------------------------- */ #include <algorithm> #include <iostream> #include <map> #include <set> #include <vector> using namespace std; #define fre freopen("0.in", "r", stdin), freopen("0.out", "w", stdout) #define abs(x) ((x) > 0 ? (x) : -(x)) #define MOD 1000000007 #define LL signed long long int #define ps(x) push_back(x) #define scan(x) scanf("%d", &x) #define print(x) printf("%d\n", x) #define scanll(x) scanf("%lld", &x) #define printll(x) printf("%lld\n", x) #define boost ios_base::sync_with_stdio(0) // vector<int> g[2*100000+5];int par[2*100000+5]; int main() { int N; cin >> N; std::vector<int> v; for (int i = 1; i <= N; ++i) { int x; cin >> x; v.push_back(x); } int ok = 1; std::vector<int> res; for (int i = N; i >= 1; --i) { int found = 0; for (int j = i; j >= 1; j--) { if (v[j - 1] == j) { found = j; break; } } if (found == 0) { ok = 0; break; } res.push_back(found); v.erase(v.begin() + found - 1); } if (!ok) cout << -1; else for (int i = N - 1; i >= 0; i--) cout << res[i] << endl; }
[]
904,201
904,202
u525782412
cpp
p03089
#if defined(LOCAL) const double _max_double_error = 1e-9; #include "testutils.h" #define L(x...) (debug(x, #x)) #define I(x, ...) (x) #define C(x...) CHECK(x) #else #define L(x, ...) (x) #define I(x, ...) (x) #define C(x, ...) ; #endif #include <algorithm> #include <bitset> #include <chrono> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <math.h> #include <memory> #include <numeric> #include <queue> #include <random> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>; using ii = pair<int, int>; using lu = unsigned long long; using l = long long; using vs = vector<string>; using vii = vector<ii>; using vl = vector<l>; using vvl = vector<vl>; using vvvl = vector<vvl>; using vlu = vector<lu>; using ll = pair<l, l>; using vll = vector<ll>; using vvll = vector<vll>; using vb = vector<bool>; using vvb = vector<vb>; using vd = vector<double>; using vvd = vector<vd>; using mll = unordered_map<l, l>; using sl = unordered_set<l>; const l INF = numeric_limits<l>::max(); const double EPS = 1e-10; const double PI = 3.14159265358979323846; const l e0 = 1, e3 = 1000, e5 = 100000, e6 = 10 * e5, e7 = 10 * e6, e8 = 10 * e7, e9 = 10 * e8; const char lf = '\n'; #define all(x) begin(x), end(x) #define F(a, b, c) for (l a = l(b); a < l(c); a++) #define B(a, b, c) for (l a = l(c) - 1; a >= l(b); a--) #define VVL(x, a, b, i) vvl x(a, vl(b, l(i))); #define VVVL(x, a, b, c, i) vvvl x(a, vvl(b, vl(c, l(i)))); void solve(istream &in, ostream &out); void solve_brute(istream &, ostream &); bool interactive_judge(istream &, istream &, ostream &); bool generate_random(l, ostream &); bool solution_checker(istream &, istream &, istream &, ostream &); int main(int argc, char **argv) { ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15); #if defined(LOCAL) tst::test_init(argc, argv); // _generate_random_test = generate_random; // _solve_brute = solve_brute; // _judge = interactive_judge; // _custom_solution_checker = solution_checker; tst::maybe_run_tests(cin, cout); #else solve(cin, cout); #endif } const l MOD = e9 + 7; // end of template void solve(istream &in, ostream &out) { l n; in >> n; vl v(n); F(i, 0, n) in >> v[i]; vl z(n); B(i, 0, n) { l k = -1; F(j, 0, v.size()) { if (v[j] == j + 1) k = j; } if (k == -1) { out << -1 << lf; } z[i] = k + 1; vl c; F(j, 0, v.size()) if (j != k) c.emplace_back(v[j]); swap(c, v); } F(i, 0, n) out << z[i] << lf; }
#if defined(LOCAL) const double _max_double_error = 1e-9; #include "testutils.h" #define L(x...) (debug(x, #x)) #define I(x, ...) (x) #define C(x...) CHECK(x) #else #define L(x, ...) (x) #define I(x, ...) (x) #define C(x, ...) ; #endif #include <algorithm> #include <bitset> #include <chrono> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <math.h> #include <memory> #include <numeric> #include <queue> #include <random> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>; using ii = pair<int, int>; using lu = unsigned long long; using l = long long; using vs = vector<string>; using vii = vector<ii>; using vl = vector<l>; using vvl = vector<vl>; using vvvl = vector<vvl>; using vlu = vector<lu>; using ll = pair<l, l>; using vll = vector<ll>; using vvll = vector<vll>; using vb = vector<bool>; using vvb = vector<vb>; using vd = vector<double>; using vvd = vector<vd>; using mll = unordered_map<l, l>; using sl = unordered_set<l>; const l INF = numeric_limits<l>::max(); const double EPS = 1e-10; const double PI = 3.14159265358979323846; const l e0 = 1, e3 = 1000, e5 = 100000, e6 = 10 * e5, e7 = 10 * e6, e8 = 10 * e7, e9 = 10 * e8; const char lf = '\n'; #define all(x) begin(x), end(x) #define F(a, b, c) for (l a = l(b); a < l(c); a++) #define B(a, b, c) for (l a = l(c) - 1; a >= l(b); a--) #define VVL(x, a, b, i) vvl x(a, vl(b, l(i))); #define VVVL(x, a, b, c, i) vvvl x(a, vvl(b, vl(c, l(i)))); void solve(istream &in, ostream &out); void solve_brute(istream &, ostream &); bool interactive_judge(istream &, istream &, ostream &); bool generate_random(l, ostream &); bool solution_checker(istream &, istream &, istream &, ostream &); int main(int argc, char **argv) { ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15); #if defined(LOCAL) tst::test_init(argc, argv); // _generate_random_test = generate_random; // _solve_brute = solve_brute; // _judge = interactive_judge; // _custom_solution_checker = solution_checker; tst::maybe_run_tests(cin, cout); #else solve(cin, cout); #endif } const l MOD = e9 + 7; // end of template void solve(istream &in, ostream &out) { l n; in >> n; vl v(n); F(i, 0, n) in >> v[i]; vl z(n); B(i, 0, n) { l k = -1; F(j, 0, v.size()) { if (v[j] == j + 1) k = j; } if (k == -1) { out << -1 << lf; return; } z[i] = k + 1; vl c; F(j, 0, v.size()) if (j != k) c.emplace_back(v[j]); swap(c, v); } F(i, 0, n) out << z[i] << lf; }
[ "control_flow.return.add" ]
904,203
904,204
u934544251
cpp
p03089
#include <bits/stdc++.h> using namespace std; void solve(vector<int> a, vector<int> &b) { if (a.size() == 0) return; for (int i = a.size() - 1; i >= 0; i--) { if (a[i] == i) { b.push_back(i); vector<int> na; for (int j = 0; j < i; j++) na.push_back(a[j]); for (int j = i + 1; j < a.size(); j++) na.push_back(a[j]); solve(na, b); return; } } b.clear(); } int main() { int n; cin >> n; vector<int> a(n); for (int &v : a) cin >> v; for (int &v : a) v--; vector<int> an; solve(a, an); if (an.size() == n) { for (int i = 0; i < n; i++) cout << an[i] + 1 << endl; } else { cout << -1 << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; void solve(vector<int> a, vector<int> &b) { if (a.size() == 0) return; for (int i = a.size() - 1; i >= 0; i--) { if (a[i] == i) { b.push_back(i); vector<int> na; for (int j = 0; j < i; j++) na.push_back(a[j]); for (int j = i + 1; j < a.size(); j++) na.push_back(a[j]); solve(na, b); return; } } b.clear(); } int main() { int n; cin >> n; vector<int> a(n); for (int &v : a) cin >> v; for (int &v : a) v--; vector<int> an; solve(a, an); if (an.size() == n) { for (int i = 0; i < n; i++) cout << an[n - i - 1] + 1 << endl; } else { cout << -1 << endl; } return 0; }
[ "expression.operation.binary.add" ]
904,205
904,206
u251828455
cpp
p03089
#include <bits/stdc++.h> using namespace std; void solve(vector<int> a, vector<int> &b) { if (a.size() == 0) return; for (int i = a.size() - 1; i >= 0; i--) { if (a[i] == i) { b.push_back(i); vector<int> na; for (int j = 0; j < i; j++) na.push_back(a[j]); for (int j = i + 1; j < a.size(); j++) na.push_back(a[j]); solve(na, b); return; } } b.clear(); } int main() { int n; cin >> n; vector<int> a(n); for (int &v : a) cin >> v; for (int &v : a) v--; vector<int> an; solve(a, an); if (an.size() == n) { for (int i = 0; i < n; i++) cout << an[i] << endl; } else { cout << -1 << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; void solve(vector<int> a, vector<int> &b) { if (a.size() == 0) return; for (int i = a.size() - 1; i >= 0; i--) { if (a[i] == i) { b.push_back(i); vector<int> na; for (int j = 0; j < i; j++) na.push_back(a[j]); for (int j = i + 1; j < a.size(); j++) na.push_back(a[j]); solve(na, b); return; } } b.clear(); } int main() { int n; cin >> n; vector<int> a(n); for (int &v : a) cin >> v; for (int &v : a) v--; vector<int> an; solve(a, an); if (an.size() == n) { for (int i = 0; i < n; i++) cout << an[n - i - 1] + 1 << endl; } else { cout << -1 << endl; } return 0; }
[ "expression.operation.binary.add" ]
904,207
904,206
u251828455
cpp
p03089
#include <bits/stdc++.h> #include <vector> using namespace std; int main() { int n; cin >> n; int *a, *b, *c; b = new int[n]; a = new int[n]; c = new int[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n; i++) { bool flag = 0; if (a[0]) c[0] = 1; else c[0] = 0; for (int j = 1; j < n; j++) { if (a[j]) c[j] = c[j - 1] + 1; else c[j] = c[j - 1]; // cout<<c[j]<<' '; } // cout<<endl; for (int j = n - 1; j >= 0; j--) { // cout<<c[j]<<' '<<a[j]<<endl; if (c[j] == a[j]) { b[i] = a[j]; a[j] = 0; flag = 1; break; } } if (!flag) { cout << -1; return 0; } } for (int i = n - 1; i >= 0; i--) cout << b[i] << endl; }
#include <bits/stdc++.h> #include <vector> using namespace std; int main() { int n; cin >> n; int *a, *b, *c; b = new int[n]; a = new int[n]; c = new int[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n; i++) { bool flag = 0; if (a[0]) c[0] = 1; else c[0] = 0; for (int j = 1; j < n; j++) { if (a[j]) c[j] = c[j - 1] + 1; else c[j] = c[j - 1]; // cout<<c[j]<<' '; } // cout<<endl; for (int j = n - 1; j >= 0; j--) { // cout<<c[j]<<' '<<a[j]<<endl; if (c[j] == a[j] && a[j]) { b[i] = a[j]; a[j] = 0; flag = 1; break; } } if (!flag) { cout << -1; return 0; } } for (int i = n - 1; i >= 0; i--) cout << b[i] << endl; }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change" ]
904,210
904,211
u211694760
cpp
p03089
#include "bits/stdc++.h" using namespace std; using ll = long long; int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; } int main() { std::cin.sync_with_stdio(false); std::cin.tie(0); int n; cin >> n; list<char> b; for (int i = 0; i < n; i++) { char a; cin >> a; b.push_back(a); } vector<char> ret; reverse(b.begin(), b.end()); for (int icount = 0; icount < n; icount++) { int count = n - icount; for (auto itr = b.begin(); itr != b.end(); itr++) { if (count == ctoi(*itr)) { ret.push_back(*itr); b.erase(itr); break; } count--; } if (count < 1) { cout << "-1" << endl; return 0; } } reverse(ret.begin(), ret.end()); for (int i = 0; i < n; i++) { cout << ret[i] << endl; } return 0; }
#include "bits/stdc++.h" using namespace std; using ll = long long; int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; } int main() { std::cin.sync_with_stdio(false); std::cin.tie(0); int n; cin >> n; list<int> b; for (int i = 0; i < n; i++) { int a; cin >> a; b.push_back(a); } vector<int> ret; reverse(b.begin(), b.end()); for (int icount = 0; icount < n; icount++) { int count = n - icount; for (auto itr = b.begin(); itr != b.end(); itr++) { if (count == *itr) { ret.push_back(*itr); b.erase(itr); break; } count--; } if (count < 1) { cout << "-1" << endl; return 0; } } reverse(ret.begin(), ret.end()); for (int i = 0; i < n; i++) { cout << ret[i] << endl; } return 0; }
[ "variable_declaration.type.primitive.change", "control_flow.loop.for.condition.change", "call.remove", "control_flow.branch.if.condition.change" ]
904,215
904,216
u487641373
cpp
p03089
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long long int llint; typedef pair<ll, ll> pa; #define MM 1000000000 #define MOD MM + 7 #define MAX 101000 #define MAP 110 #define initial_value -1 #define Pair pair<int, int> #define chmax(a, b) (a < b ? a = b : 0) #define chmin(a, b) (a > b ? a = b : 0) #define INF (1 << 29) // 536870912 int dx[4] = {-1, 0, 1, 0}; int dy[4] = {0, -1, 0, 1}; int N; vector<int> b; int main() { cin >> N; for (int i = 0; i < N; i++) { int x; cin >> x; b.push_back(x); if (x > i + 1) { cout << -1 << endl; return 0; } } vector<int> a(0); while (b.size()) { bool flg = false; for (int i = b.size() - 1; i >= 0; i--) { if (b[i] == i + 1) { a.push_back(b[i]); b.erase(b.begin() + i); flg = true; break; } if (!flg) { cout << -1 << endl; return 0; } } } for (int i = a.size() - 1; i >= 0; i--) { cout << a[i] << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long long int llint; typedef pair<ll, ll> pa; #define MM 1000000000 #define MOD MM + 7 #define MAX 101000 #define MAP 110 #define initial_value -1 #define Pair pair<int, int> #define chmax(a, b) (a < b ? a = b : 0) #define chmin(a, b) (a > b ? a = b : 0) #define INF (1 << 29) // 536870912 int dx[4] = {-1, 0, 1, 0}; int dy[4] = {0, -1, 0, 1}; int N; vector<int> b; int main() { cin >> N; for (int i = 0; i < N; i++) { int x; cin >> x; b.push_back(x); if (x > i + 1) { cout << -1 << endl; return 0; } } vector<int> a(0); while (b.size()) { bool flg = false; for (int i = b.size() - 1; i >= 0; i--) { if (b[i] == i + 1) { a.push_back(b[i]); b.erase(b.begin() + i); flg = true; break; } } if (!flg) { cout << -1 << endl; return 0; } } for (int i = a.size() - 1; i >= 0; i--) { cout << a[i] << endl; } return 0; }
[]
904,217
904,218
u342051078
cpp
p03089
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long long int llint; typedef pair<ll, ll> pa; #define MM 1000000000 #define MOD MM + 7 #define MAX 101000 #define MAP 110 #define initial_value -1 #define Pair pair<int, int> #define chmax(a, b) (a < b ? a = b : 0) #define chmin(a, b) (a > b ? a = b : 0) #define INF (1 << 29) // 536870912 int dx[4] = {-1, 0, 1, 0}; int dy[4] = {0, -1, 0, 1}; int N; vector<int> b; int main() { cin >> N; for (int i = 0; i < N; i++) { int x; cin >> x; b.push_back(x); if (x > i) { cout << -1 << endl; return 0; } } vector<int> a(0); while (b.size()) { bool flg = false; for (int i = b.size() - 1; i >= 0; i--) { if (b[i] == i + 1) { a.push_back(b[i]); b.erase(b.begin() + i); flg = true; break; } if (!flg) { cout << -1 << endl; return 0; } } } for (int i = a.size() - 1; i >= 0; i--) { cout << a[i] << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long long int llint; typedef pair<ll, ll> pa; #define MM 1000000000 #define MOD MM + 7 #define MAX 101000 #define MAP 110 #define initial_value -1 #define Pair pair<int, int> #define chmax(a, b) (a < b ? a = b : 0) #define chmin(a, b) (a > b ? a = b : 0) #define INF (1 << 29) // 536870912 int dx[4] = {-1, 0, 1, 0}; int dy[4] = {0, -1, 0, 1}; int N; vector<int> b; int main() { cin >> N; for (int i = 0; i < N; i++) { int x; cin >> x; b.push_back(x); if (x > i + 1) { cout << -1 << endl; return 0; } } vector<int> a(0); while (b.size()) { bool flg = false; for (int i = b.size() - 1; i >= 0; i--) { if (b[i] == i + 1) { a.push_back(b[i]); b.erase(b.begin() + i); flg = true; break; } } if (!flg) { cout << -1 << endl; return 0; } } for (int i = a.size() - 1; i >= 0; i--) { cout << a[i] << endl; } return 0; }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change", "misc.off_by_one" ]
904,219
904,218
u342051078
cpp
p03089
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long long int llint; typedef pair<ll, ll> pa; #define MM 1000000000 #define MOD MM + 7 #define MAX 101000 #define MAP 110 #define initial_value -1 #define Pair pair<int, int> #define chmax(a, b) (a < b ? a = b : 0) #define chmin(a, b) (a > b ? a = b : 0) #define INF (1 << 29) // 536870912 int dx[4] = {-1, 0, 1, 0}; int dy[4] = {0, -1, 0, 1}; int main() { int n; cin >> n; vector<int> a(0), b(n); for (int i = 0; i < n; i++) { cin >> b[i]; if (b[i] > i + 1) { cout << -1 << endl; return 0; } } while (b.size()) { bool tmp = false; for (int i = b.size() - 1; i >= 0; i--) { if (b[i] == i + 1) { tmp = true; a.push_back(b[i]); b.erase(b.begin() + i); } } if (!tmp) { cout << -1 << endl; return 0; } } reverse(a.begin(), a.end()); for (int i = 0; i < n; i++) { cout << a[i] << endl; } }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long long int llint; typedef pair<ll, ll> pa; #define MM 1000000000 #define MOD MM + 7 #define MAX 101000 #define MAP 110 #define initial_value -1 #define Pair pair<int, int> #define chmax(a, b) (a < b ? a = b : 0) #define chmin(a, b) (a > b ? a = b : 0) #define INF (1 << 29) // 536870912 int dx[4] = {-1, 0, 1, 0}; int dy[4] = {0, -1, 0, 1}; int main() { int n; cin >> n; vector<int> a(0), b(n); for (int i = 0; i < n; i++) { cin >> b[i]; if (b[i] > i + 1) { cout << -1 << endl; return 0; } } while (b.size()) { bool tmp = false; for (int i = b.size() - 1; i >= 0; i--) { if (b[i] == i + 1) { tmp = true; a.push_back(i + 1); b.erase(b.begin() + i); break; } } if (!tmp) { cout << -1 << endl; return 0; } } reverse(a.begin(), a.end()); for (int i = 0; i < n; i++) { cout << a[i] << endl; } }
[ "call.arguments.change" ]
904,220
904,221
u342051078
cpp
p03089
#include <iostream> #include <vector> using namespace std; int main() { int N; cin >> N; vector<int> b(N); vector<int> ans(N); ans[0] = 1; for (int i = 0; i < N; i++) { cin >> b[i]; } int j = N - 1; for (int i = 0; i < N; i++) { if (b[i] > i + 1) { cout << -1; return 0; } } while (b.size() != 1) { for (int i = N - 1; i > -1; i--) { if (b[i] == i + 1) { ans[j] = b[i]; j--; b.erase(b.begin() + i); break; } } } for (int i = 0; i < N; i++) { cout << ans[i] << endl; } return 0; }
#include <iostream> #include <vector> using namespace std; int main() { int N; cin >> N; vector<int> b(N); vector<int> ans(N); ans[0] = 1; for (int i = 0; i < N; i++) { cin >> b[i]; } int j = N - 1; for (int i = 0; i < N; i++) { if (b[i] > i + 1) { cout << -1; return 0; } } while (b.size() != 1) { for (int i = b.size() - 1; i > -1; i--) { if (b[i] == i + 1) { ans[j] = b[i]; j--; b.erase(b.begin() + i); break; } } } for (int i = 0; i < N; i++) { cout << ans[i] << endl; } return 0; }
[ "control_flow.loop.for.initializer.change", "expression.operation.binary.change", "call.add" ]
904,226
904,227
u117615163
cpp
p03089
#include <iostream> #include <queue> #include <vector> using namespace std; typedef long long ll; #define repi(i, a, b) for (int i = int(a); i < int(b); ++i) #define rep(i, n) repi(i, 0, n) #define rerepi(i, a, b) for (int i = int(a) - 1; i >= b; --i) #define rerep(i, n) rerepi(i, n, 0) 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; } template <typename T> inline void remove(std::vector<T> &vector, unsigned int index) { vector.erase(vector.begin() + index); } const long long INF = 1LL << 60; // ここから開始だよ! ll N, mark; vector<ll> B, ans; int main() { // 呪文エリア cin.tie(0); ios::sync_with_stdio(false); // 詠唱完了 cin >> N; rep(i, N) { ll tmp; cin >> tmp; B.push_back(tmp); } while (!B.empty()) { mark = -1; rep(i, B.size()) { if (B[i] == i + 1 && mark < i + 1) { mark = i + 1; } } if (mark == -1) { cout << -1 << endl; return 0; } else { remove(B, mark); ans.push_back(mark); } } rerep(i, ans.size()) { cout << ans[i] << endl; } return 0; }
#include <iostream> #include <queue> #include <vector> using namespace std; typedef long long ll; #define repi(i, a, b) for (int i = int(a); i < int(b); ++i) #define rep(i, n) repi(i, 0, n) #define rerepi(i, a, b) for (int i = int(a) - 1; i >= b; --i) #define rerep(i, n) rerepi(i, n, 0) 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; } template <typename T> inline void remove(std::vector<T> &vector, unsigned int index) { vector.erase(vector.begin() + index); } const long long INF = 1LL << 60; // ここから開始だよ! ll N, mark; vector<ll> B, ans; int main() { // 呪文エリア cin.tie(0); ios::sync_with_stdio(false); // 詠唱完了 cin >> N; rep(i, N) { ll tmp; cin >> tmp; B.push_back(tmp); } while (!B.empty()) { mark = -1; rep(i, B.size()) { if (B[i] == i + 1 && mark < i + 1) { mark = i + 1; } } if (mark == -1) { cout << -1 << endl; return 0; } else { remove(B, mark - 1); ans.push_back(mark); } } rerep(i, ans.size()) { cout << ans[i] << endl; } return 0; }
[ "expression.operation.binary.add" ]
904,230
904,231
u952022797
cpp
p03089
// ConsoleApplication1.cpp : このファイルには 'main' // 関数が含まれています。プログラム実行の開始と終了がそこで行われます。 // #include <iostream> #include <queue> #include <vector> using namespace std; typedef long long ll; #define repi(i, a, b) for (int i = int(a); i < int(b); ++i) #define rep(i, n) repi(i, 0, n) #define rerepi(i, a, b) for (int i = int(a) - 1; i >= b; --i) #define rerep(i, n) rerepi(i, n, 0) 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; } template <typename T> inline void remove(std::vector<T> &vector, unsigned int index) { vector.erase(vector.begin() + index); } const long long INF = 1LL << 60; // ここから開始だよ! ll N, mark; vector<ll> B, ans; int main() { // 呪文エリア cin.tie(0); ios::sync_with_stdio(false); // 詠唱完了 cin >> N; rep(i, N) { ll tmp; cin >> tmp; B.push_back(tmp); } while (!B.empty()) { mark = -1; rep(i, B.size()) { if (B[i] == i + 1 && mark < i + 1) { mark = i + 1; } } if (mark == -1) { cout << -1 << endl; return 0; } else { remove(B, mark); ans.push_back(mark); } } rerep(i, ans.size()) { cout << ans[i] << endl; } return 0; } // プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー // プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー // 作業を開始するためのヒント: // 1. ソリューション エクスプローラー // ウィンドウを使用してファイルを追加/管理します // 2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します // 3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します // 4. エラー一覧ウィンドウを使用してエラーを表示します // 5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード // ファイルを作成するか、[プロジェクト] > [既存の項目の追加] // と移動して既存のコード ファイルをプロジェクトに追加します // 6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > // [プロジェクト] と移動して .sln ファイルを選択します
#include <iostream> #include <queue> #include <vector> using namespace std; typedef long long ll; #define repi(i, a, b) for (int i = int(a); i < int(b); ++i) #define rep(i, n) repi(i, 0, n) #define rerepi(i, a, b) for (int i = int(a) - 1; i >= b; --i) #define rerep(i, n) rerepi(i, n, 0) 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; } template <typename T> inline void remove(std::vector<T> &vector, unsigned int index) { vector.erase(vector.begin() + index); } const long long INF = 1LL << 60; // ここから開始だよ! ll N, mark; vector<ll> B, ans; int main() { // 呪文エリア cin.tie(0); ios::sync_with_stdio(false); // 詠唱完了 cin >> N; rep(i, N) { ll tmp; cin >> tmp; B.push_back(tmp); } while (!B.empty()) { mark = -1; rep(i, B.size()) { if (B[i] == i + 1 && mark < i + 1) { mark = i + 1; } } if (mark == -1) { cout << -1 << endl; return 0; } else { remove(B, mark - 1); ans.push_back(mark); } } rerep(i, ans.size()) { cout << ans[i] << endl; } return 0; }
[ "expression.operation.binary.add" ]
904,232
904,231
u952022797
cpp
p03089
#include <bits/stdc++.h> using namespace std; int judge(vector<int> array, int n) { for (int i = 0; i < n; i++) { if (array.at(i) > i + 1) return -1; } return 1; } int find(vector<int> array, int n) { int ans; for (int i = n - 1; i > 0; i--) { if (array[i] == i + 1) { ans = i; break; } } return ans; } int main() { int N; cin >> N; vector<int> b(N); vector<int> a(N, 1); for (int i = 0; i < N; i++) cin >> b.at(i); for (int i = 0; i < N; i++) { if (judge(b, N - i) == -1) { cout << -1 << endl; return 0; } else { int ans = find(b, N - i); b.erase(b.begin() + ans); a.at(N - i - 1) = ans + 1; } } for (int i = 0; i < N; i++) { cout << a.at(i) << endl; } }
#include <bits/stdc++.h> using namespace std; int judge(vector<int> array, int n) { for (int i = 0; i < n; i++) { if (array.at(i) > i + 1) return -1; } return 1; } int find(vector<int> array, int n) { int ans; for (int i = n - 1; i >= 0; i--) { if (array[i] == i + 1) { ans = i; break; } } return ans; } int main() { int N; cin >> N; vector<int> b(N); vector<int> a(N, 1); for (int i = 0; i < N; i++) cin >> b.at(i); for (int i = 0; i < N; i++) { if (judge(b, N - i) == -1) { cout << -1 << endl; return 0; } else { int ans = find(b, N - i); b.erase(b.begin() + ans); a.at(N - i - 1) = ans + 1; } } for (int i = 0; i < N; i++) { cout << a.at(i) << endl; } }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
904,233
904,234
u803481017
cpp
p03089
#include <bits/stdc++.h> #define _ (*istream_iterator<int>(cin)) #define eb emplace_back #define em emplace using namespace std; const int mxn = 1e2 + 10; vector<int> v(mxn); stack<int> stk; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n = _; for (int i = 1; i <= n; i++) v[i] = _; for (bool f = true; f;) { f = false; for (int i = v.size() - 1; i; i--) { if (v[i] == i) { stk.em(i); v.erase(v.begin() + i); f = true; break; } } } if (stk.empty()) cout << -1; else for (; stk.size(); stk.pop()) cout << stk.top() << '\n'; return 0; }
#include <bits/stdc++.h> #define _ (*istream_iterator<int>(cin)) #define eb emplace_back #define em emplace using namespace std; const int mxn = 1e2 + 10; vector<int> v(mxn); stack<int> stk; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n = _; for (int i = 1; i <= n; i++) v[i] = _; for (bool f = true; f;) { f = false; for (int i = v.size() - 1; i; i--) { if (v[i] == i) { stk.em(i); v.erase(v.begin() + i); f = true; break; } } } if (stk.size() < n) cout << -1; else for (; stk.size(); stk.pop()) cout << stk.top() << '\n'; return 0; }
[ "call.function.change", "control_flow.branch.if.condition.change" ]
904,240
904,241
u080609335
cpp
p03089
#include <bits/stdc++.h> using namespace std; int n, a[100010], b[100010], nn, cnt; int main() { cin >> n; nn = n; for (int i = 1; i <= n; i++) cin >> b[i]; for (int i = i; i <= n; i++) { int j = nn; for (; j >= 1; j--) if (b[j] == j) break; if (!j) { puts("-1"); return 0; } a[++cnt] = j; for (int k = j + 1; k <= nn; k++) b[k - 1] = b[k]; nn--; } for (int i = cnt; i >= 1; i--) cout << a[i] << '\n'; }
#include <bits/stdc++.h> using namespace std; int n, a[100010], b[100010], nn, cnt; int main() { cin >> n; nn = n; for (int i = 1; i <= n; i++) cin >> b[i]; for (int i = 1; i <= n; i++) { int j = nn; for (; j >= 1; j--) if (b[j] == j) break; if (!j) { puts("-1"); return 0; } a[++cnt] = j; for (int k = j + 1; k <= nn; k++) b[k - 1] = b[k]; nn--; } for (int i = cnt; i >= 1; i--) cout << a[i] << '\n'; }
[ "variable_declaration.value.change", "identifier.replace.remove", "literal.replace.add", "control_flow.loop.for.initializer.change" ]
904,253
904,254
u759808436
cpp
p03089
#include <algorithm> #include <bitset> #include <chrono> #include <cmath> #include <cstdlib> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <vector> using namespace std; using ll = long long; using ull = unsigned long long; #define REP(i, n) for (long long i = 0; i < (n); i++) #define FOR(i, m, n) for (long long i = (m); i < (n); ++i) #define ALL(obj) (obj).begin(), (obj).end() template <class T> using V = vector<T>; template <class T, class U> using P = pair<T, U>; const ll MOD = (ll)1e9 + 7; const ll MOD2 = 998244353; const ll LLINF = (ll)1e18; const ll INTINF = (ll)1e9; const long double PI = 3.1415926535897932384626433; template <class T> void corner(bool flg, T hoge) { if (flg) { cout << hoge << endl; exit(0); } } template <class T, class U> ostream &operator<<(ostream &o, const map<T, U> &obj) { o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o; } template <class T> ostream &operator<<(ostream &o, const set<T> &obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; } template <class T> ostream &operator<<(ostream &o, const multiset<T> &obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; } template <class T> ostream &operator<<(ostream &o, const vector<T> &obj) { o << "{"; for (int i = 0; i < (int)obj.size(); ++i) o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o; } template <class T, class U> ostream &operator<<(ostream &o, const pair<T, U> &obj) { o << "{" << obj.first << ", " << obj.second << "}"; return o; } template <template <class tmp> class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; } void print(void) { cout << endl; } template <class Head> void print(Head &&head) { cout << head; print(); } template <class Head, class... Tail> void print(Head &&head, Tail &&...tail) { cout << head << " "; print(forward<Tail>(tail)...); } template <class T> void chmax(T &a, const T b) { a = max<T>(a, b); } template <class T> void chmin(T &a, const T b) { a = min<T>(a, b); } void YN(bool flg) { cout << ((flg) ? "YES" : "NO") << endl; } void Yn(bool flg) { cout << ((flg) ? "Yes" : "No") << endl; } void yn(bool flg) { cout << ((flg) ? "yes" : "no") << endl; } int main() { int N; cin >> N; V<int> b(N), ans(N); for (int i = 0; i < N; ++i) cin >> b[i]; for (int i = 0; i < N; ++i) { bool flg = 1; for (int j = b.size() - 1; 0 <= j; --j) { if (b[j] == j + 1) { ans[i] = b[j]; b[j] = 0; flg = 0; break; } } if (flg) { cout << -1 << endl; return 0; } V<int> tmp; for (int j = 0; j <= b.size(); ++j) if (b[j] != 0) tmp.push_back(b[j]); b = tmp; } for (int i = N - 1; 0 <= i; --i) cout << ans[i] << endl; return 0; }
#include <algorithm> #include <bitset> #include <chrono> #include <cmath> #include <cstdlib> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <vector> using namespace std; using ll = long long; using ull = unsigned long long; #define REP(i, n) for (long long i = 0; i < (n); i++) #define FOR(i, m, n) for (long long i = (m); i < (n); ++i) #define ALL(obj) (obj).begin(), (obj).end() template <class T> using V = vector<T>; template <class T, class U> using P = pair<T, U>; const ll MOD = (ll)1e9 + 7; const ll MOD2 = 998244353; const ll LLINF = (ll)1e18; const ll INTINF = (ll)1e9; const long double PI = 3.1415926535897932384626433; template <class T> void corner(bool flg, T hoge) { if (flg) { cout << hoge << endl; exit(0); } } template <class T, class U> ostream &operator<<(ostream &o, const map<T, U> &obj) { o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o; } template <class T> ostream &operator<<(ostream &o, const set<T> &obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; } template <class T> ostream &operator<<(ostream &o, const multiset<T> &obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; } template <class T> ostream &operator<<(ostream &o, const vector<T> &obj) { o << "{"; for (int i = 0; i < (int)obj.size(); ++i) o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o; } template <class T, class U> ostream &operator<<(ostream &o, const pair<T, U> &obj) { o << "{" << obj.first << ", " << obj.second << "}"; return o; } template <template <class tmp> class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; } void print(void) { cout << endl; } template <class Head> void print(Head &&head) { cout << head; print(); } template <class Head, class... Tail> void print(Head &&head, Tail &&...tail) { cout << head << " "; print(forward<Tail>(tail)...); } template <class T> void chmax(T &a, const T b) { a = max<T>(a, b); } template <class T> void chmin(T &a, const T b) { a = min<T>(a, b); } void YN(bool flg) { cout << ((flg) ? "YES" : "NO") << endl; } void Yn(bool flg) { cout << ((flg) ? "Yes" : "No") << endl; } void yn(bool flg) { cout << ((flg) ? "yes" : "no") << endl; } int main() { int N; cin >> N; V<int> b(N), ans(N); for (int i = 0; i < N; ++i) cin >> b[i]; for (int i = 0; i < N; ++i) { bool flg = 1; for (int j = b.size() - 1; 0 <= j; --j) { if (b[j] == j + 1) { ans[i] = b[j]; b[j] = 0; flg = 0; break; } } if (flg) { cout << -1 << endl; return 0; } V<int> tmp; for (int j = 0; j < b.size(); ++j) if (b[j] != 0) tmp.push_back(b[j]); b = tmp; } for (int i = N - 1; 0 <= i; --i) cout << ans[i] << endl; return 0; }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
904,258
904,259
u898651494
cpp
p03089
#pragma GCC optimize("Ofast") #pragma comment(linker, "/stack:200000000") #include <algorithm> #include <cmath> #include <cstring> #include <ctime> #include <iomanip> #include <iostream> #include <map> #include <set> #include <string> #include <vector> using namespace std; const int N = 5100; const int MOD = 1e9 + 7; vector<int> now; set<vector<int>> vis; void cur(vector<int> stuff) { if (stuff.empty()) { reverse(now.begin(), now.end()); for (auto x : now) { cout << x << "\n"; } exit(0); } if (vis.count(stuff)) { return; } vis.insert(stuff); vector<int> check = stuff; sort(check.begin(), check.end()); for (int i = 0; i < check.size(); ++i) { if (check[i] > i + 1) { return; } } for (int i = 0; i < stuff.size(); ++i) { if (stuff[i] > i) { return; } } for (int i = stuff.size() - 1; i >= 0; --i) { if (stuff[i] == i + 1) { vector<int> stuff2 = stuff; stuff2.erase(stuff2.begin() + i); now.push_back(i + 1); cur(stuff2); now.pop_back(); } } } int main() { ::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; vector<int> v(n); for (int i = 0; i < n; ++i) { cin >> v[i]; } cur(v); cout << -1 << endl; return 0; }
#pragma GCC optimize("Ofast") #pragma comment(linker, "/stack:200000000") #include <algorithm> #include <cmath> #include <cstring> #include <ctime> #include <iomanip> #include <iostream> #include <map> #include <set> #include <string> #include <vector> using namespace std; const int N = 5100; const int MOD = 1e9 + 7; vector<int> now; set<vector<int>> vis; void cur(vector<int> stuff) { if (stuff.empty()) { reverse(now.begin(), now.end()); for (auto x : now) { cout << x << "\n"; } exit(0); } if (vis.count(stuff)) { return; } vis.insert(stuff); vector<int> check = stuff; sort(check.begin(), check.end()); for (int i = 0; i < check.size(); ++i) { if (check[i] > i + 1) { return; } } for (int i = 0; i < stuff.size(); ++i) { if (stuff[i] > i + 1) { return; } } for (int i = stuff.size() - 1; i >= 0; --i) { if (stuff[i] == i + 1) { vector<int> stuff2 = stuff; stuff2.erase(stuff2.begin() + i); now.push_back(i + 1); cur(stuff2); now.pop_back(); } } } int main() { ::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; vector<int> v(n); for (int i = 0; i < n; ++i) { cin >> v[i]; } cur(v); cout << -1 << endl; return 0; }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change", "misc.off_by_one" ]
904,260
904,261
u217145434
cpp
p03089
#include <bits/stdc++.h> using namespace std; using i64 = int64_t; #define rep(i, x, y) \ for (i64 i = i64(x), i##_max_for_repmacro = i64(y); \ i < i##_max_for_repmacro; ++i) #define debug(x) #x << "=" << (x) #ifdef DEBUG #define _GLIBCXX_DEBUG #define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl #else #define print(x) #endif const int inf = 1.01e9; const i64 inf64 = 4.01e18; const double eps = 1e-9; template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; } template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) { os << "["; for (const auto &v : vec) { os << v << ","; } os << "]"; return os; } template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; } template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } void solve() { // const i64 mod = 1'000'000'007; i64 N; cin >> N; vector<i64> b(N); rep(i, 0, N) { cin >> b[i]; --b[i]; } vector<i64> cnt(N); rep(i, 0, N) { ++cnt[b[i]]; } rep(i, 0, N) { if (cnt[i] > N - i) { cout << -1 << endl; return; } } vector<i64> v = b, ans; rep(i, 0, N) { i64 maxi = -1, pos = -1; rep(j, 0, v.size()) { if (j != v[j]) continue; if (maxi < v[j]) { maxi = v[j]; pos = j; } } if (maxi > N - 1 - i) { cout << -1 << endl; return; } ans.emplace_back(v[pos]); v.erase(begin(v) + pos); } reverse(begin(ans), end(ans)); rep(i, 0, N) { cout << ans[i] + 1 << endl; } } int main() { std::cin.tie(0); std::ios::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(16); solve(); return 0; }
#include <bits/stdc++.h> using namespace std; using i64 = int64_t; #define rep(i, x, y) \ for (i64 i = i64(x), i##_max_for_repmacro = i64(y); \ i < i##_max_for_repmacro; ++i) #define debug(x) #x << "=" << (x) #ifdef DEBUG #define _GLIBCXX_DEBUG #define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl #else #define print(x) #endif const int inf = 1.01e9; const i64 inf64 = 4.01e18; const double eps = 1e-9; template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; } template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) { os << "["; for (const auto &v : vec) { os << v << ","; } os << "]"; return os; } template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; } template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } void solve() { // const i64 mod = 1'000'000'007; i64 N; cin >> N; vector<i64> b(N); rep(i, 0, N) { cin >> b[i]; --b[i]; } vector<i64> cnt(N); rep(i, 0, N) { ++cnt[b[i]]; } rep(i, 0, N) { if (cnt[i] > N - i) { cout << -1 << endl; return; } } vector<i64> v = b, ans; rep(i, 0, N) { i64 maxi = -1, pos = -1; rep(j, 0, v.size()) { if (j != v[j]) continue; if (maxi < v[j]) { maxi = v[j]; pos = j; } } if (maxi > N - 1 - i or pos == -1) { cout << -1 << endl; return; } ans.emplace_back(v[pos]); v.erase(begin(v) + pos); } reverse(begin(ans), end(ans)); rep(i, 0, N) { cout << ans[i] + 1 << endl; } } int main() { std::cin.tie(0); std::ios::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(16); solve(); return 0; }
[ "control_flow.branch.if.condition.change" ]
904,262
904,263
u759266806
cpp
p03089
#include <algorithm> #include <array> #include <bitset> #include <complex> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <valarray> #include <vector> #include <cassert> #include <cctype> #include <cstdio> #include <cstdlib> #include <cstring> #include <chrono> #include <random> #include <thread> #include <unordered_map> #include <unordered_set> using namespace std; #define all(c) c.begin(), c.end() #define repeat(i, n) for (int i = 0; i < static_cast<int>(n); i++) #define debug(x) #x << "=" << (x) #ifdef DEBUG #define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl #else #define dump(x) #endif template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os << "{"; for (auto it = v.begin(); it != v.end(); ++it) { if (it != v.begin()) os << ","; os << *it; } return os << "}"; } template <typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &v) { os << "{"; os << v.first << ", " << v.second; return os << "}"; } // --------------------------------------------------------------------------- using point = complex<double>; using ll = int64_t; vector<int> solve(vector<int> b) { int N = b.size(); vector<int> ans; for (int i = N; i >= 1; i--) { int del = -1; for (int j = i; j >= 1; j--) { if (b[j - 1] == j) { del = j; break; } } if (del < 0) return vector<int>(); ans.push_back(del); b.erase(b.begin() + (del - 1), b.begin() + del); } reverse(all(ans)); return ans; } int my_main(int argc, char **argv) { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<int> b(n); for (int i = 0; i < n; i++) { cin >> b[i]; } vector<int> ans = solve(b); if (ans.size() == 0) { cout << -1 << endl; } else { assert(b.size() == n); for (int i = 0; i < n; i++) { cout << b[i] << endl; } } return 0; } // ---------------------------------------------------------------------------- // Test driver #ifdef DEBUG #define MAY_RUN_TESTCASE #endif #ifdef MAY_RUN_TESTCASE #include <fstream> #if __has_include(<unistd.h>) // Mac, Linux #include <unistd.h> #elif __has_include(<io.h>) // Windows #include <io.h> #else // Other? #error "unistd.h or io.h not found" #endif bool test_file_exists(const std::string &str) { std::ifstream fs(str); return fs.is_open(); } #endif int main(int argc, char **argv) { #ifndef MAY_RUN_TESTCASE return my_main(argc, argv); #else if (argc == 1) { return my_main(argc, argv); } else if (argc == 2) { char *stdin_file = argv[1]; freopen(stdin_file, "r", stdin); return my_main(argc, argv); } else if (argc == 5) { std::string stdin_file = argv[1]; std::string expected_file = argv[2]; std::string stdout_file = argv[3]; std::string stderr_file = argv[4]; if (!test_file_exists(stdin_file)) { std::cerr << stdin_file << " not found" << std::endl; return 3; } if (!test_file_exists(expected_file)) { std::cerr << expected_file << " not found" << std::endl; return 3; } int original_stdin = dup(fileno(stdin)); int original_stdout = dup(fileno(stdout)); int original_stderr = dup(fileno(stderr)); freopen(stdin_file.c_str(), "r", stdin); freopen(stdout_file.c_str(), "w", stdout); freopen(stderr_file.c_str(), "w", stderr); int ret = my_main(argc, argv); fflush(stdout); fflush(stderr); dup2(original_stderr, fileno(stderr)); dup2(original_stdout, fileno(stdout)); dup2(original_stdin, fileno(stdin)); if (ret != 0) { std::cerr << "main returns " << ret << std::endl; return ret; } std::ifstream inp(stdin_file); std::ifstream out(stdout_file); std::ifstream err(stderr_file); std::ifstream exp(expected_file); // Clear is needed if the file is empty. std::cout << "----- input -----" << std::endl; std::cout << inp.rdbuf() << std::endl; std::cout.clear(); std::cout << "-----------------" << std::endl << std::endl; std::cout << "----- output ----" << std::endl; std::cout << out.rdbuf() << std::endl; std::cout.clear(); std::cout << "-----------------" << std::endl << std::endl; std::cout << "---- expected ---" << std::endl; std::cout << exp.rdbuf() << std::endl; std::cout.clear(); std::cout << "-----------------" << std::endl << std::endl; std::cout << "----- stderr ----" << std::endl; std::cout << err.rdbuf() << std::endl; std::cout.clear(); std::cout << "-----------------" << std::endl; inp.seekg(0); out.seekg(0); exp.seekg(0); err.seekg(0); std::string output_str, expected_str; { std::stringstream output_ss; output_ss << out.rdbuf(); output_str = output_ss.str(); std::stringstream expected_ss; expected_ss << exp.rdbuf(); expected_str = expected_ss.str(); } // Remove trailing spaces output_str.erase(output_str.find_last_not_of(" \n\r\t") + 1); expected_str.erase(expected_str.find_last_not_of(" \n\r\t") + 1); if (output_str == expected_str) return 0; else return 1; } return 1; #endif }
#include <algorithm> #include <array> #include <bitset> #include <complex> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <valarray> #include <vector> #include <cassert> #include <cctype> #include <cstdio> #include <cstdlib> #include <cstring> #include <chrono> #include <random> #include <thread> #include <unordered_map> #include <unordered_set> using namespace std; #define all(c) c.begin(), c.end() #define repeat(i, n) for (int i = 0; i < static_cast<int>(n); i++) #define debug(x) #x << "=" << (x) #ifdef DEBUG #define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl #else #define dump(x) #endif template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os << "{"; for (auto it = v.begin(); it != v.end(); ++it) { if (it != v.begin()) os << ","; os << *it; } return os << "}"; } template <typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &v) { os << "{"; os << v.first << ", " << v.second; return os << "}"; } // --------------------------------------------------------------------------- using point = complex<double>; using ll = int64_t; vector<int> solve(vector<int> b) { int N = b.size(); vector<int> ans; for (int i = N; i >= 1; i--) { int del = -1; for (int j = i; j >= 1; j--) { if (b[j - 1] == j) { del = j; break; } } if (del < 0) return vector<int>(); ans.push_back(del); b.erase(b.begin() + (del - 1), b.begin() + del); } reverse(all(ans)); return ans; } int my_main(int argc, char **argv) { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<int> b(n); for (int i = 0; i < n; i++) { cin >> b[i]; } vector<int> ans = solve(b); if (ans.size() == 0) { cout << -1 << endl; } else { assert(ans.size() == n); for (int i = 0; i < n; i++) { cout << ans[i] << endl; } } return 0; } // ---------------------------------------------------------------------------- // Test driver #ifdef DEBUG #define MAY_RUN_TESTCASE #endif #ifdef MAY_RUN_TESTCASE #include <fstream> #if __has_include(<unistd.h>) // Mac, Linux #include <unistd.h> #elif __has_include(<io.h>) // Windows #include <io.h> #else // Other? #error "unistd.h or io.h not found" #endif bool test_file_exists(const std::string &str) { std::ifstream fs(str); return fs.is_open(); } #endif int main(int argc, char **argv) { #ifndef MAY_RUN_TESTCASE return my_main(argc, argv); #else if (argc == 1) { return my_main(argc, argv); } else if (argc == 2) { char *stdin_file = argv[1]; freopen(stdin_file, "r", stdin); return my_main(argc, argv); } else if (argc == 5) { std::string stdin_file = argv[1]; std::string expected_file = argv[2]; std::string stdout_file = argv[3]; std::string stderr_file = argv[4]; if (!test_file_exists(stdin_file)) { std::cerr << stdin_file << " not found" << std::endl; return 3; } if (!test_file_exists(expected_file)) { std::cerr << expected_file << " not found" << std::endl; return 3; } int original_stdin = dup(fileno(stdin)); int original_stdout = dup(fileno(stdout)); int original_stderr = dup(fileno(stderr)); freopen(stdin_file.c_str(), "r", stdin); freopen(stdout_file.c_str(), "w", stdout); freopen(stderr_file.c_str(), "w", stderr); int ret = my_main(argc, argv); fflush(stdout); fflush(stderr); dup2(original_stderr, fileno(stderr)); dup2(original_stdout, fileno(stdout)); dup2(original_stdin, fileno(stdin)); if (ret != 0) { std::cerr << "main returns " << ret << std::endl; return ret; } std::ifstream inp(stdin_file); std::ifstream out(stdout_file); std::ifstream err(stderr_file); std::ifstream exp(expected_file); // Clear is needed if the file is empty. std::cout << "----- input -----" << std::endl; std::cout << inp.rdbuf() << std::endl; std::cout.clear(); std::cout << "-----------------" << std::endl << std::endl; std::cout << "----- output ----" << std::endl; std::cout << out.rdbuf() << std::endl; std::cout.clear(); std::cout << "-----------------" << std::endl << std::endl; std::cout << "---- expected ---" << std::endl; std::cout << exp.rdbuf() << std::endl; std::cout.clear(); std::cout << "-----------------" << std::endl << std::endl; std::cout << "----- stderr ----" << std::endl; std::cout << err.rdbuf() << std::endl; std::cout.clear(); std::cout << "-----------------" << std::endl; inp.seekg(0); out.seekg(0); exp.seekg(0); err.seekg(0); std::string output_str, expected_str; { std::stringstream output_ss; output_ss << out.rdbuf(); output_str = output_ss.str(); std::stringstream expected_ss; expected_ss << exp.rdbuf(); expected_str = expected_ss.str(); } // Remove trailing spaces output_str.erase(output_str.find_last_not_of(" \n\r\t") + 1); expected_str.erase(expected_str.find_last_not_of(" \n\r\t") + 1); if (output_str == expected_str) return 0; else return 1; } return 1; #endif }
[ "identifier.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
904,266
904,267
u419874471
cpp
p03089
#include "bits/stdc++.h" using namespace std; using ll = long long; using vll = vector<ll>; using pl4 = pair<ll, ll>; using str = string; using vpl4 = vector<pair<ll, ll>>; #define sz size() #define be begin() #define en end() #define fi first #define se second #define pb push_back #define mp make_pair #define llin(x) \ ll(x); \ cin >> (x); #define stin(x) \ str(x); \ cin >> (x); #define vllin(x, n) \ vll(x)(n); \ FOR(i, 0, n - 1) { cin >> (x)[i]; } #define vllin2(a, b, n) \ vll(a)(n); \ vll(b)(n); \ FOR(i, 0, n - 1) { cin >> (a)[i] >> b[i]; } #define vpl4in(x, n) \ vpl4(x)((n), mp(0, 0)); \ FOR(i, 0, n - 1) { cin >> x[i].fi >> x[i].se; } #define FOR(i, a, b) for (ll i = a; i <= b; i++) #define rFOR(i, b, a) for (ll i = a; i >= b; i--) #define SORT(x) sort(x.be, x.en) #define rSORT(x) sort(x.rbegin(), x.rend()) #define say(x) cout << (x); #define sal(x) cout << (x) << endl; #define says(x) cout << (x) << (' '); #define sas cout << (' '); #define sayR(x) cout << fixed << setprecision(10) << (x); #define salR(x) cout << fixed << setprecision(10) << (x) << endl; #define yn(a) cout << ((a) ? "yes" : "no") << endl; #define Yn(a) cout << ((a) ? "Yes" : "No") << endl; #define YN(a) cout << ((a) ? "YES" : "NO") << endl; #define Imp(a) cout << ((a) ? "Possible" : "Impossible") << endl; #define IMP(a) cout << ((a) ? "POSSIBLE" : "IMPOSSIBLE") << endl; #define pow(a, b) ll(pow(a, b)) ll MOD = 1000000007; signed main() { llin(n); vllin(b, n); ll l = 0; vll c(n, 0); rFOR(i, 0, n - 1) { rFOR(j, 0, i) { if (b[j] == j + 1) { l = 1; b.erase(b.be + j); c[i] = j + 1; break; } } if (l == 0) { return (-1); } l = 0; } FOR(i, 0, n - 1) { sal(c[i]); } }
#include "bits/stdc++.h" using namespace std; using ll = long long; using vll = vector<ll>; using pl4 = pair<ll, ll>; using str = string; using vpl4 = vector<pair<ll, ll>>; #define sz size() #define be begin() #define en end() #define fi first #define se second #define pb push_back #define mp make_pair #define llin(x) \ ll(x); \ cin >> (x); #define stin(x) \ str(x); \ cin >> (x); #define vllin(x, n) \ vll(x)(n); \ FOR(i, 0, n - 1) { cin >> (x)[i]; } #define vllin2(a, b, n) \ vll(a)(n); \ vll(b)(n); \ FOR(i, 0, n - 1) { cin >> (a)[i] >> b[i]; } #define vpl4in(x, n) \ vpl4(x)((n), mp(0, 0)); \ FOR(i, 0, n - 1) { cin >> x[i].fi >> x[i].se; } #define FOR(i, a, b) for (ll i = a; i <= b; i++) #define rFOR(i, b, a) for (ll i = a; i >= b; i--) #define SORT(x) sort(x.be, x.en) #define rSORT(x) sort(x.rbegin(), x.rend()) #define say(x) cout << (x); #define sal(x) cout << (x) << endl; #define says(x) cout << (x) << (' '); #define sas cout << (' '); #define sayR(x) cout << fixed << setprecision(10) << (x); #define salR(x) cout << fixed << setprecision(10) << (x) << endl; #define yn(a) cout << ((a) ? "yes" : "no") << endl; #define Yn(a) cout << ((a) ? "Yes" : "No") << endl; #define YN(a) cout << ((a) ? "YES" : "NO") << endl; #define Imp(a) cout << ((a) ? "Possible" : "Impossible") << endl; #define IMP(a) cout << ((a) ? "POSSIBLE" : "IMPOSSIBLE") << endl; #define pow(a, b) ll(pow(a, b)) ll MOD = 1000000007; signed main() { llin(n); vllin(b, n); ll l = 0; vll c(n, 0); rFOR(i, 0, n - 1) { rFOR(j, 0, i) { if (b[j] == j + 1) { l = 1; b.erase(b.be + j); c[i] = j + 1; break; } } if (l == 0) { sal(-1); return 0; } l = 0; } FOR(i, 0, n - 1) { sal(c[i]); } }
[ "function.return_value.change", "control_flow.return.add", "control_flow.return.0.add" ]
904,270
904,271
u614421689
cpp
p03089
#include <algorithm> #include <iostream> #include <string> #include <unordered_map> #include <vector> using namespace std; typedef long long ll; int main(int argc, char *argv[]) { ll N; cin >> N; vector<ll> a(N), b(N); vector<ll> d(N); for (int i = 0; i < N; ++i) { cin >> b[i]; d[i] = i + 1 - b[i]; if (d[i] < 0) { cout << "-1" << endl; return 0; } } for (int n = 0; n < N; n++) { auto p = find(d.rbegin(), d.rend(), 0); if (p == d.rend()) { cout << "-1" << endl; return 0; } for (auto q = p.base(); q != d.end(); q++) { (*q)--; } a[N - n - 1] = distance(d.begin(), p.base()); d.erase(p.base() - 1); // cerr << "d"; for( auto x : d ) cerr << " " << x; cerr << endl; // cerr << "a"; for( auto x : a ) cerr << " " << x; cerr << endl; } for (auto x : a) cerr << x << endl; return 0; }
#include <algorithm> #include <iostream> #include <string> #include <unordered_map> #include <vector> using namespace std; typedef long long ll; int main(int argc, char *argv[]) { ll N; cin >> N; vector<ll> a(N), b(N); vector<ll> d(N); for (int i = 0; i < N; ++i) { cin >> b[i]; d[i] = i + 1 - b[i]; if (d[i] < 0) { cout << "-1" << endl; return 0; } } for (int n = 0; n < N; n++) { auto p = find(d.rbegin(), d.rend(), 0); if (p == d.rend()) { cout << "-1" << endl; return 0; } for (auto q = p.base(); q != d.end(); q++) { (*q)--; } a[N - n - 1] = distance(d.begin(), p.base()); d.erase(p.base() - 1); // cerr << "d"; for( auto x : d ) cerr << " " << x; cerr << endl; // cerr << "a"; for( auto x : a ) cerr << " " << x; cerr << endl; } for (auto x : a) cout << x << endl; return 0; }
[ "identifier.change", "io.output.change" ]
904,290
904,291
u155128304
cpp
p03089
#include <algorithm> #include <bitset> #include <complex> #include <deque> #include <exception> #include <fstream> #include <functional> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <locale> #include <map> #include <memory> #include <new> #include <numeric> #include <ostream> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <stdio.h> #include <streambuf> #include <string> #include <typeinfo> #include <utility> #include <valarray> #include <vector> #define rep(i, a, n) for (ll i = (a); i < (n); ++i) #define urep(i, a, n) for (ll i = (a); i >= (n); --i) #define all(x) (x).begin(), (x).end() #define INF 1e18 const int mod = 1e9 + 7; typedef long long ll; using namespace std; ll dx[4] = {1, -1, 0, 0}; ll dy[4] = {0, 0, 1, -1}; ll N, M, X, Y, A, B, C, D, Q, K, R, W, H, P, L; ll ans; string S, T; ll y[101010]; ll a[101010]; ll b[101010]; ll t[101010]; ll p[101010]; ll n[101010]; ll l[101010]; ll r[101010]; ll gcd(ll a, ll b) { if (b == 0) return a; else return gcd(b, a % b); } struct Edge { ll to, cost; Edge(ll to, ll cost) : to(to), cost(cost) {} }; typedef vector<vector<Edge>> AdjList; AdjList graph; vector<ll> dist; struct UnionFind { vector<ll> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2 vector<ll> size; UnionFind(ll N) : par(N), size(N) { //最初は全てが根であるとして初期化 for (ll i = 0; i < N; i++) par[i] = i; for (ll i = 0; i < N; i++) size[i] = 1; } ll root(ll x) { // データxが属する木の根を再帰で得る:root(x) = {xの木の根} if (par[x] == x) return x; return par[x] = root(par[x]); } ll GetSize(ll x) { return size[root(x)]; } void unite(ll x, ll y) { // xとyの木を併合 ll rx = root(x); // xの根をrx ll ry = root(y); // yの根をry if (rx == ry) return; // xとyの根が同じ(=同じ木にある)時はそのまま par[rx] = ry; // xとyの根が同じでない(=同じ木にない)時:xの根rxをyの根ryにつける size[ry] += size[rx]; } bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す ll rx = root(x); ll ry = root(y); return rx == ry; } }; int main() { cin >> N; rep(i, 0, N) { cin >> b[i]; if (b[i] > i + 1) { cout << -1 << endl; break; } } rep(i, 0, N) { urep(j, N - 1, 0) { if (b[j] <= a[j] + 1) { cout << b[j] << endl; b[j] = 1000; rep(k, j, N) { // cerr<<"inc"<<" "<<k<<endl; a[k]++; } break; } } } return 0; }
#include <algorithm> #include <bitset> #include <complex> #include <deque> #include <exception> #include <fstream> #include <functional> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <locale> #include <map> #include <memory> #include <new> #include <numeric> #include <ostream> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <stdio.h> #include <streambuf> #include <string> #include <typeinfo> #include <utility> #include <valarray> #include <vector> #define rep(i, a, n) for (ll i = (a); i < (n); ++i) #define urep(i, a, n) for (ll i = (a); i >= (n); --i) #define all(x) (x).begin(), (x).end() #define INF 1e18 const int mod = 1e9 + 7; typedef long long ll; using namespace std; ll dx[4] = {1, -1, 0, 0}; ll dy[4] = {0, 0, 1, -1}; ll N, M, X, Y, A, B, C, D, Q, K, R, W, H, P, L; ll ans; string S, T; ll y[101010]; ll a[101010]; ll b[101010]; ll t[101010]; ll p[101010]; ll n[101010]; ll l[101010]; ll r[101010]; ll gcd(ll a, ll b) { if (b == 0) return a; else return gcd(b, a % b); } struct Edge { ll to, cost; Edge(ll to, ll cost) : to(to), cost(cost) {} }; typedef vector<vector<Edge>> AdjList; AdjList graph; vector<ll> dist; struct UnionFind { vector<ll> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2 vector<ll> size; UnionFind(ll N) : par(N), size(N) { //最初は全てが根であるとして初期化 for (ll i = 0; i < N; i++) par[i] = i; for (ll i = 0; i < N; i++) size[i] = 1; } ll root(ll x) { // データxが属する木の根を再帰で得る:root(x) = {xの木の根} if (par[x] == x) return x; return par[x] = root(par[x]); } ll GetSize(ll x) { return size[root(x)]; } void unite(ll x, ll y) { // xとyの木を併合 ll rx = root(x); // xの根をrx ll ry = root(y); // yの根をry if (rx == ry) return; // xとyの根が同じ(=同じ木にある)時はそのまま par[rx] = ry; // xとyの根が同じでない(=同じ木にない)時:xの根rxをyの根ryにつける size[ry] += size[rx]; } bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す ll rx = root(x); ll ry = root(y); return rx == ry; } }; int main() { cin >> N; rep(i, 0, N) { cin >> b[i]; if (b[i] > i + 1) { cout << -1 << endl; return 0; } } rep(i, 0, N) { urep(j, N - 1, 0) { if (b[j] <= a[j] + 1) { cout << b[j] << endl; b[j] = 1000; rep(k, j, N) { // cerr<<"inc"<<" "<<k<<endl; a[k]++; } break; } } } return 0; }
[ "control_flow.break.remove", "control_flow.return.add", "function.return_value.change" ]
904,292
904,293
u406225550
cpp
p03089
#include <bits/stdc++.h> using namespace std; int main() { int N, b; bool z = true; cin >> N; int a[N] = {}; for (int i = 0; i < N; i++) { cin >> b; if (b <= i + 1) { for (int j = i; j < b - 1; j--) { a[j] = a[j - 1]; } a[b - 1] = b; } else { cout << -1 << endl; z = false; break; } } if (z) { for (int i = 0; i < N; i++) { cout << a[i] << endl; } } }
#include <bits/stdc++.h> using namespace std; int main() { int N, b; bool z = true; cin >> N; int a[N] = {}; for (int i = 0; i < N; i++) { cin >> b; if (b <= i + 1) { for (int j = i; j > b - 1; j--) { a[j] = a[j - 1]; } a[b - 1] = b; } else { cout << -1 << endl; z = false; break; } } if (z) { for (int i = 0; i < N; i++) { cout << a[i] << endl; } } }
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
904,305
904,306
u785409986
cpp
p03089
#include <bits/stdc++.h> using namespace std; int main() { int N, b; bool z = true; cin >> N; int a[N] = {}; for (int i = 0; i < N; i++) { cin >> b; if (b <= i + 1) { for (int j = i; j <= b - 1; j--) { a[j] = a[j - 1]; } a[b - 1] = b; } else { cout << -1 << endl; z = false; break; } } if (z) { for (int i = 0; i < N; i++) { cout << a[i] << endl; } } }
#include <bits/stdc++.h> using namespace std; int main() { int N, b; bool z = true; cin >> N; int a[N] = {}; for (int i = 0; i < N; i++) { cin >> b; if (b <= i + 1) { for (int j = i; j > b - 1; j--) { a[j] = a[j - 1]; } a[b - 1] = b; } else { cout << -1 << endl; z = false; break; } } if (z) { for (int i = 0; i < N; i++) { cout << a[i] << endl; } } }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
904,307
904,306
u785409986
cpp
p03089
#include <algorithm> #include <assert.h> #include <bitset> #include <chrono> #include <cmath> #include <complex> #include <deque> #include <functional> #include <iostream> #include <limits.h> #include <map> #include <math.h> #include <queue> #include <random> #include <set> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <time.h> #include <unordered_map> #include <unordered_set> #include <vector> #define ll long long #define rep2(i, a, b) for (ll i = a; i <= b; ++i) #define rep(i, n) for (ll i = 0; i < n; i++) #define rep3(i, a, b) for (ll i = a; i >= b; i--) #define REP(e, v) for (auto e : v) #define pii pair<int, int> #define pll pair<ll, ll> #define tii tuple<int, int, int> #define pq priority_queue<int> #define pqg priority_queue<int, vector<int>, greater<int>> #define pb push_back #define edge(v, a, b) \ v[a].pb(b); \ v[b].pb(a); #define MAX_V 400010 #define vec vector<int> #define vecll vector<ll> #define vecpii vector<pii> #define endl "\n" #define ALL(c) (c).begin(), (c).end() using namespace std; int in() { int x; scanf("%d", &x); return x; } ll lin() { ll x; scanf("%lld", &x); return x; } #define INF 1e9 + 7 #define LLINF 1e18 + 7 ll MOD = 1e9 + 7; #define N 1100 main() { int n; n = in(); int a[110]; rep(i, n) a[i] = in(); vec ans; rep(i, n) { int count = 0, mem = -1; rep(j, n) { if (a[j]) count++; if (a[j] == count) mem = j; } if (mem == -1) { cout << -1; return 0; } ans.pb(a[mem]); a[mem] = 0; } rep(i, n) { cout << ans[n - i - 1] << endl; } }
#include <algorithm> #include <assert.h> #include <bitset> #include <chrono> #include <cmath> #include <complex> #include <deque> #include <functional> #include <iostream> #include <limits.h> #include <map> #include <math.h> #include <queue> #include <random> #include <set> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <time.h> #include <unordered_map> #include <unordered_set> #include <vector> #define ll long long #define rep2(i, a, b) for (ll i = a; i <= b; ++i) #define rep(i, n) for (ll i = 0; i < n; i++) #define rep3(i, a, b) for (ll i = a; i >= b; i--) #define REP(e, v) for (auto e : v) #define pii pair<int, int> #define pll pair<ll, ll> #define tii tuple<int, int, int> #define pq priority_queue<int> #define pqg priority_queue<int, vector<int>, greater<int>> #define pb push_back #define edge(v, a, b) \ v[a].pb(b); \ v[b].pb(a); #define MAX_V 400010 #define vec vector<int> #define vecll vector<ll> #define vecpii vector<pii> #define endl "\n" #define ALL(c) (c).begin(), (c).end() using namespace std; int in() { int x; scanf("%d", &x); return x; } ll lin() { ll x; scanf("%lld", &x); return x; } #define INF 1e9 + 7 #define LLINF 1e18 + 7 ll MOD = 1e9 + 7; #define N 1100 main() { int n; n = in(); int a[110]; rep(i, n) a[i] = in(); vec ans; rep(i, n) { int count = 0, mem = -1; rep(j, n) { if (a[j] > 0) count++; else continue; if (a[j] == count) mem = j; } if (mem == -1) { cout << -1; return 0; } ans.pb(a[mem]); a[mem] = 0; } rep(i, n) { cout << ans[n - i - 1] << endl; } }
[ "control_flow.branch.if.condition.change", "control_flow.branch.else_if.replace.remove", "control_flow.branch.if.replace.add" ]
904,315
904,316
u495699318
cpp
p03089
#include <algorithm> #include <functional> #include <iostream> #include <map> #include <math.h> #include <stack> #include <string> #include <vector> using namespace std; using ll = long long; ll mod = 1e9 + 7; int main() { int n; cin >> n; vector<int> v(n); vector<int> v2(n); for (int i = 0; i < n; i++) { int c; cin >> c; v[i] = c; v2[i] = i - c + 1; if (v2[i] < 0) { cout << -1 << endl; return 0; } } vector<int> out(n); for (int i = n - 1; i >= 0; --i) { for (int j = n - 1; j >= 0; j--) { if (v2[j] == 0) { out[i] = v2[j]; for (; j < n; j++) { v2[j]--; } break; } } } for (auto i : out) { cout << i << endl; } return 0; }
#include <algorithm> #include <functional> #include <iostream> #include <map> #include <math.h> #include <stack> #include <string> #include <vector> using namespace std; using ll = long long; ll mod = 1e9 + 7; int main() { int n; cin >> n; vector<int> v(n); vector<int> v2(n); for (int i = 0; i < n; i++) { int c; cin >> c; v[i] = c; v2[i] = i - c + 1; if (v2[i] < 0) { cout << -1 << endl; return 0; } } vector<int> out(n); for (int i = n - 1; i >= 0; --i) { for (int j = n - 1; j >= 0; j--) { if (v2[j] == 0) { out[i] = v[j]; for (; j < n; j++) { v2[j]--; } break; } } } for (auto i : out) { cout << i << endl; } return 0; }
[ "assignment.value.change", "identifier.change" ]
904,317
904,318
u625725849
cpp
p03089
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d", &n); vector<int> b(n); for (int i = 0; i < n; i++) { scanf("%d", &b[i]); } vector<int> ans; while (b.size() > 0) { for (int i = b.size() - 1; i >= 0; i--) { if (b[i] == i + 1) { ans.push_back(b[i]); b.erase(b.begin() + i); break; } else if (i == 0) { ans.push_back(-1); goto END; } } } END: for (int i = n - 1; i >= 0; i--) { printf("%d\n", ans[i]); if (ans[i] == -1) break; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d", &n); vector<int> b(n); for (int i = 0; i < n; i++) { scanf("%d", &b[i]); } vector<int> ans; while (b.size() > 0) { for (int i = b.size() - 1; i >= 0; i--) { if (b[i] == i + 1) { ans.push_back(b[i]); b.erase(b.begin() + i); break; } else if (i == 0) { ans.push_back(-1); goto END; } } } END: for (int i = ans.size() - 1; i >= 0; i--) { printf("%d\n", ans[i]); if (ans[i] == -1) break; } return 0; }
[ "control_flow.loop.for.initializer.change", "expression.operation.binary.change", "call.add" ]
904,319
904,320
u203062059
cpp
p03089
#pragma GCC optimize(2) #include <bits/stdc++.h> using namespace std; vector<int> V, ans; inline int read() { int x = 0, f = 1; char ch = getchar(); for (; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') f = -1; for (; ch >= '0' && ch <= '9'; ch = getchar()) x = (x << 1) + (x << 3) + ch - '0'; return x * f; } int main() { int n = read(); for (int i = 1; i <= n; i++) V.push_back(read() - 1); for (int i = 1; i <= n; i++) { bool flag = 0; for (int j = V.size(); ~j; j--) if (V[j] == j) { flag = 1; ans.push_back(j + 1); V.erase(V.begin() + j); break; } if (!flag) { puts("-1"); return 0; } } for (int i = ans.size() - 1; ~i; i--) printf("%d\n", ans[i]); return 0; }
#pragma GCC optimize(2) #include <bits/stdc++.h> using namespace std; vector<int> V, ans; inline int read() { int x = 0, f = 1; char ch = getchar(); for (; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') f = -1; for (; ch >= '0' && ch <= '9'; ch = getchar()) x = (x << 1) + (x << 3) + ch - '0'; return x * f; } int main() { int n = read(); for (int i = 1; i <= n; i++) V.push_back(read() - 1); for (int i = 1; i <= n; i++) { bool flag = 0; for (int j = V.size() - 1; ~j; j--) if (V[j] == j) { flag = 1; ans.push_back(j + 1); V.erase(V.begin() + j); break; } if (!flag) { puts("-1"); return 0; } } for (int i = ans.size() - 1; ~i; i--) printf("%d\n", ans[i]); return 0; }
[ "control_flow.loop.for.initializer.change" ]
904,337
904,338
u811313083
cpp
p03089
/*********************** * Author: xuziyuan * ***********************/ #include <bits/stdc++.h> #define rt0 return 0 #define rep(i, n) for (int i = 0; i < n; i++) #define repn(i, n) for (int i = 1; i <= n; i++) #define replet(c) for (char c = 'a'; c <= 'z'; c++) #define LL long long #define pii pair<int, int> #define pb push_back #define fi first #define se second #define mpr make_pair #define sqr(a) ((a) * (a)) using namespace std; const LL MOD = 1e9 + 7; int n; vector<int> a, ans; bool ok; int main() { cin >> n; rep(i, n) { int x; cin >> x; a.pb(x); } while (!a.empty()) { ok = false; for (int i = a.size() - 1; i >= 0; i--) { if (a[i] == i + 1) { ok = true; ans.pb(a[i]); a.erase(a.begin() + i); } } if (!ok) puts("-1"), exit(0); } for (int i = ans.size() - 1; i >= 0; i--) cout << ans[i] << endl; rt0; }
/*********************** * Author: xuziyuan * ***********************/ #include <bits/stdc++.h> #define rt0 return 0 #define rep(i, n) for (int i = 0; i < n; i++) #define repn(i, n) for (int i = 1; i <= n; i++) #define replet(c) for (char c = 'a'; c <= 'z'; c++) #define LL long long #define pii pair<int, int> #define pb push_back #define fi first #define se second #define mpr make_pair #define sqr(a) ((a) * (a)) using namespace std; const LL MOD = 1e9 + 7; int n; vector<int> a, ans; bool ok; int main() { cin >> n; rep(i, n) { int x; cin >> x; a.pb(x); } while (!a.empty()) { ok = false; for (int i = a.size() - 1; i >= 0; i--) { if (a[i] == i + 1) { ok = true; ans.pb(a[i]); a.erase(a.begin() + i); break; } } if (!ok) puts("-1"), exit(0); } for (int i = ans.size() - 1; i >= 0; i--) cout << ans[i] << endl; rt0; }
[ "control_flow.break.add" ]
904,339
904,340
u977365687
cpp
p03089
#include <algorithm> #include <cstring> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <map> #include <math.h> #include <queue> #include <string> #include <tuple> #include <vector> using namespace std; #define MOD (long long int)(1e9 + 7) #define ll long long int #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define reps(i, n) for (int i = 1; i <= (int)(n); i++) #define REP(i, n) for (int i = n - 1; i >= 0; i--) #define REPS(i, n) for (int i = n; i > 0; i--) #define INF (int)(1123456789) #define LINF (long long int)(123456789012345678) int main(void) { int N; cin >> N; int check = 1; vector<int> b, ans, tmp; rep(i, N) { int n; cin >> n; b.push_back(n); } int i = N; while (b.size()) { if (i == b[i - 1]) { ans.push_back(b[i - 1]); b.erase(b.begin() + i - 1); i = b.size(); } else { i--; if (i == 0) { check = 0; break; } } } // while (b.size()) { // REP(i, b.size()) { // if (i+1==b[i]) { // tmp.push_back(b[i]); // b.erase(b.begin()+i-1); // i = b.size()-1; // } // } // if (tmp.size()==0) { // check = 0; // break; // } // copy(tmp.begin(), tmp.end(), back_inserter(ans)); // tmp.clear(); // } if (check) { rep(i, N) { cout << ans[i] << endl; } } else { cout << -1 << endl; } return 0; }
#include <algorithm> #include <cstring> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <map> #include <math.h> #include <queue> #include <string> #include <tuple> #include <vector> using namespace std; #define MOD (long long int)(1e9 + 7) #define ll long long int #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define reps(i, n) for (int i = 1; i <= (int)(n); i++) #define REP(i, n) for (int i = n - 1; i >= 0; i--) #define REPS(i, n) for (int i = n; i > 0; i--) #define INF (int)(1123456789) #define LINF (long long int)(123456789012345678) int main(void) { int N; cin >> N; int check = 1; vector<int> b, ans, tmp; rep(i, N) { int n; cin >> n; b.push_back(n); } int i = N; while (b.size()) { if (i == b[i - 1]) { ans.push_back(b[i - 1]); b.erase(b.begin() + i - 1); i = b.size(); } else { i--; if (i == 0) { check = 0; break; } } } // while (b.size()) { // REP(i, b.size()) { // if (i+1==b[i]) { // tmp.push_back(b[i]); // b.erase(b.begin()+i-1); // i = b.size()-1; // } // } // if (tmp.size()==0) { // check = 0; // break; // } // copy(tmp.begin(), tmp.end(), back_inserter(ans)); // tmp.clear(); // } if (check) { REP(i, N) { cout << ans[i] << endl; } } else { cout << -1 << endl; } return 0; }
[ "identifier.change" ]
904,345
904,346
u050698451
cpp
p03089
#include <algorithm> #include <climits> #include <cmath> #include <iostream> #include <map> #include <math.h> #include <set> #include <string> #include <vector> #define X first #define Y second #define vsort(v) sort(v.begin(), v.end()) #define vrev(v) reverse(v.begin(), v.end()) #define P pair // stoi(s): string to int // stod(s): string to double // INT_MAX // INT_MIN // LLONG_MAX // LLONG_MIN // DBL_MIN // DBL_MAX // LDBL_MIN // LDBL_MAX // A-Z: 65~90 // a-z: 97~122 // |a-z| = 26 using namespace std; using ll = long long; int main(int argc, const char *argv[]) { int n; cin >> n; vector<int> v(n + 1), ans; for (int i = 0; i < n; i++) { cin >> v[i]; } for (int i = n - 1; i >= 0; i--) { if (v[i] == i + 1) { ans.push_back(v[i]); v.erase(v.begin() + i); i = v.size() - 1; } } if (ans.size() == n) { for (int i = 0; i < n; i++) { cout << ans[i] << endl; } } else { cout << -1 << endl; } }
#include <algorithm> #include <climits> #include <cmath> #include <iostream> #include <map> #include <math.h> #include <set> #include <string> #include <vector> #define X first #define Y second #define vsort(v) sort(v.begin(), v.end()) #define vrev(v) reverse(v.begin(), v.end()) #define P pair // stoi(s): string to int // stod(s): string to double // INT_MAX // INT_MIN // LLONG_MAX // LLONG_MIN // DBL_MIN // DBL_MAX // LDBL_MIN // LDBL_MAX // A-Z: 65~90 // a-z: 97~122 // |a-z| = 26 using namespace std; using ll = long long; int main(int argc, const char *argv[]) { int n; cin >> n; vector<int> v(n + 1), ans; for (int i = 0; i < n; i++) { cin >> v[i]; } for (int i = n - 1; i >= 0; i--) { if (v[i] == i + 1) { ans.push_back(v[i]); v.erase(v.begin() + i); i = v.size() - 1; } } vrev(ans); if (ans.size() == n) { for (int i = 0; i < n; i++) { cout << ans[i] << endl; } } else { cout << -1 << endl; } }
[ "call.add" ]
904,359
904,360
u493080913
cpp
p03089
#include <bits/stdc++.h> using namespace std; using ll = long long; const double eps = 1e-10; const int MOD = 1000000007; const int INF = 1000000000; const ll LINF = 1ll << 50; template <typename T> void printv(const vector<T> &s) { for (int i = 0; i < (int)(s.size()); ++i) { cout << s[i]; if (i == (int)(s.size()) - 1) cout << endl; else cout << " "; } } int n; vector<int> b; int main() { cin.tie(0); cout << fixed << setprecision(10); cin >> n; b.resize(n); for (int i = 0; i < n; ++i) { cin >> b[i]; b[i]--; if (b[i] > i) { cout << -1 << endl; return 0; } } printv(b); vector<int> res; for (int cnt = 0; cnt < n; ++cnt) { for (int i = (int)(b.size()) - 1; i >= 0; --i) { if (i == b[i]) { res.push_back(b[i]); b.erase(b.begin() + i); break; } } } reverse(res.begin(), res.end()); for (int i = 0; i < n; ++i) { cout << res[i] + 1 << endl; } }
#include <bits/stdc++.h> using namespace std; using ll = long long; const double eps = 1e-10; const int MOD = 1000000007; const int INF = 1000000000; const ll LINF = 1ll << 50; template <typename T> void printv(const vector<T> &s) { for (int i = 0; i < (int)(s.size()); ++i) { cout << s[i]; if (i == (int)(s.size()) - 1) cout << endl; else cout << " "; } } int n; vector<int> b; int main() { cin.tie(0); cout << fixed << setprecision(10); cin >> n; b.resize(n); for (int i = 0; i < n; ++i) { cin >> b[i]; b[i]--; if (b[i] > i) { cout << -1 << endl; return 0; } } // printv(b); vector<int> res; for (int cnt = 0; cnt < n; ++cnt) { for (int i = (int)(b.size()) - 1; i >= 0; --i) { if (i == b[i]) { res.push_back(b[i]); b.erase(b.begin() + i); break; } } } reverse(res.begin(), res.end()); for (int i = 0; i < n; ++i) { cout << res[i] + 1 << endl; } }
[ "call.remove" ]
904,361
904,362
u334351654
cpp
p03089
#include <bits/stdc++.h> using namespace std; #define forup(i, a, b) for (int i = a; i < b; i++) #define fordown(i, a, b) for (int i = b - 1; i >= a; i--) #define foreach(i, c) for (auto &i : (c)) #define all(c) (c).begin(), (c).end() #define sz(c) (int)(c).size() #ifdef DEBUG #define dump(v) cerr << "[" #v << ":" << (v) << "]" #else #define dump(v) #endif #define endl "\n" typedef long double ld; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<vector<int>> vii; typedef vector<ll> vl; const ll MOD = (1e9 + 7); const ll INF = (1e9 + 123456789); const ll INFL = (INF * INF); inline ll addm(ll a, ll b, ll m = MOD) { return ((a + b) % m); } inline ll subm(ll a, ll b, ll m = MOD) { return (((a - b) % m + m) % m); } inline ll mulm(ll a, ll b, ll m = MOD) { return ((a * b) % m); } ll powm(ll a, ll b, ll m = MOD) { ll ret = (!b) ? 1 : powm(a, b / 2); return (!b) ? 1 : mulm(mulm(ret, ret, m), b % 2 ? a : 1, m); } ll gcd(ll a, ll b) { return (!b) ? a : gcd(b, a % b); } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } ll inv(ll x, ll m = MOD) { return powm(x, m - 2, m); } void solve() { int n; cin >> n; vi b; forup(i, 0, n) { int x; cin >> x; --x; b.push_back(x); } vi ans; while (!b.empty()) { int d = -1; forup(i, 0, sz(b)) { if (b[i] == i) d = i; } if (d == -1) { cerr << "-1" << endl; return; } ans.push_back(d + 1); b.erase(b.begin() + d); } reverse(all(ans)); foreach (x, ans) cerr << x << endl; } int main(int argc, char *argv[]) { cin.sync_with_stdio(0); cin.tie(NULL); solve(); return 0; }
#include <bits/stdc++.h> using namespace std; #define forup(i, a, b) for (int i = a; i < b; i++) #define fordown(i, a, b) for (int i = b - 1; i >= a; i--) #define foreach(i, c) for (auto &i : (c)) #define all(c) (c).begin(), (c).end() #define sz(c) (int)(c).size() #ifdef DEBUG #define dump(v) cerr << "[" #v << ":" << (v) << "]" #else #define dump(v) #endif #define endl "\n" typedef long double ld; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<vector<int>> vii; typedef vector<ll> vl; const ll MOD = (1e9 + 7); const ll INF = (1e9 + 123456789); const ll INFL = (INF * INF); inline ll addm(ll a, ll b, ll m = MOD) { return ((a + b) % m); } inline ll subm(ll a, ll b, ll m = MOD) { return (((a - b) % m + m) % m); } inline ll mulm(ll a, ll b, ll m = MOD) { return ((a * b) % m); } ll powm(ll a, ll b, ll m = MOD) { ll ret = (!b) ? 1 : powm(a, b / 2); return (!b) ? 1 : mulm(mulm(ret, ret, m), b % 2 ? a : 1, m); } ll gcd(ll a, ll b) { return (!b) ? a : gcd(b, a % b); } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } ll inv(ll x, ll m = MOD) { return powm(x, m - 2, m); } void solve() { int n; cin >> n; vi b; forup(i, 0, n) { int x; cin >> x; --x; b.push_back(x); } vi ans; while (!b.empty()) { int d = -1; forup(i, 0, sz(b)) { if (b[i] == i) d = i; } if (d == -1) { cout << "-1" << endl; return; } ans.push_back(d + 1); b.erase(b.begin() + d); } reverse(all(ans)); foreach (x, ans) cout << x << endl; } int main(int argc, char *argv[]) { cin.sync_with_stdio(0); cin.tie(NULL); solve(); return 0; }
[ "identifier.change", "io.output.change", "expression.operation.binary.change" ]
904,365
904,366
u346692517
cpp
p03089
#include "algorithm" #include "bitset" #include "cassert" #include "climits" #include "cmath" #include "cstdio" #include "functional" #include "iomanip" #include "iostream" #include "list" #include "map" #include "numeric" #include "queue" #include "random" #include "set" #include "stack" #include "string" #include "unordered_map" #include "unordered_set" using namespace std; const long long int MOD = 1000000007; // const int MOD = 1000000007; // const int MOD = 998244353; long long int N, M, K, H, W, L, R; // int N, M, K, H, W, L, R; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> N; vector<int> v(N + 1); for (int i = 1; i <= N; i++) cin >> v[i]; vector<int> ans; while (v.size() > 1) { for (int i = v.size() - 1; i; i--) { if (v[i] == i) { ans.push_back(i); v.erase(v.begin() + i); } if (i == 1) { cout << -1 << endl; return 0; } } } reverse(ans.begin(), ans.end()); for (auto i : ans) cout << i << endl; return 0; }
#include "algorithm" #include "bitset" #include "cassert" #include "climits" #include "cmath" #include "cstdio" #include "functional" #include "iomanip" #include "iostream" #include "list" #include "map" #include "numeric" #include "queue" #include "random" #include "set" #include "stack" #include "string" #include "unordered_map" #include "unordered_set" using namespace std; const long long int MOD = 1000000007; // const int MOD = 1000000007; // const int MOD = 998244353; long long int N, M, K, H, W, L, R; // int N, M, K, H, W, L, R; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> N; vector<int> v(N + 1); for (int i = 1; i <= N; i++) cin >> v[i]; vector<int> ans; while (v.size() > 1) { for (int i = v.size() - 1; i; i--) { if (v[i] == i) { ans.push_back(i); v.erase(v.begin() + i); break; } if (i == 1) { cout << -1 << endl; return 0; } } } reverse(ans.begin(), ans.end()); for (auto i : ans) cout << i << endl; return 0; }
[ "control_flow.break.add" ]
904,380
904,381
u468700753
cpp
p03090
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { int n; cin >> n; vector<vector<int>> G(n + 1); vector<pair<int, int>> ans; if (n % 2 == 0) { for (int now = 1; now <= n; now++) { for (int to = 1; to < n + 1; to++) { if (to + now == n + 1 || to == now) continue; if (find(G.at(now).begin(), G.at(now).end(), to) != G.at(now).end()) continue; ans.push_back(make_pair(now, to)); G.at(now).push_back(to); G.at(to).push_back(now); } } } else { for (int i = 1; i < n; i++) { G.at(n).push_back(i); G.at(i).push_back(n); ans.push_back(make_pair(i, n)); } n -= 1; for (int now = 1; now <= n; now++) { for (int to = 1; to < n + 1; to++) { if (to + now == n || to == now) continue; if (find(G.at(now).begin(), G.at(now).end(), to) != G.at(now).end()) continue; ans.push_back(make_pair(now, to)); G.at(now).push_back(to); G.at(to).push_back(now); } } } cout << ans.size() << endl; for (auto P : ans) { cout << P.first << " " << P.second << endl; } }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { int n; cin >> n; vector<vector<int>> G(n + 1); vector<pair<int, int>> ans; if (n % 2 == 0) { for (int now = 1; now <= n; now++) { for (int to = 1; to < n + 1; to++) { if (to + now == n + 1 || to == now) continue; if (find(G.at(now).begin(), G.at(now).end(), to) != G.at(now).end()) continue; ans.push_back(make_pair(now, to)); G.at(now).push_back(to); G.at(to).push_back(now); } } } else { for (int i = 1; i < n; i++) { G.at(n).push_back(i); G.at(i).push_back(n); ans.push_back(make_pair(i, n)); } n -= 1; for (int now = 1; now <= n; now++) { for (int to = 1; to < n + 1; to++) { if (to + now == n + 1 || to == now) continue; if (find(G.at(now).begin(), G.at(now).end(), to) != G.at(now).end()) continue; ans.push_back(make_pair(now, to)); G.at(now).push_back(to); G.at(to).push_back(now); } } } cout << ans.size() << endl; for (auto P : ans) { cout << P.first << " " << P.second << endl; } }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change", "misc.off_by_one" ]
904,393
904,394
u619557935
cpp
p03090
#include <bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> // using namespace __gnu_pbds; //#include<atcoder/all> using namespace std; // using namespace atcoder; #define rep(i, n) for (ll i = 0; i < n; i++) #define repl(i, l, r) for (ll i = (l); i < (r); i++) #define per(i, n) for (ll i = n - 1; i >= 0; i--) #define perl(i, r, l) for (ll i = r - 1; i >= l; i--) #define fi first #define se second #define pb push_back #define ins insert #define all(x) (x).begin(), (x).end() using ll = long long; using vl = vector<ll>; using vvl = vector<vector<ll>>; const ll MOD9 = 1000000007; const ll MOD = 998244353; const int inf = 1e9 + 10; const ll INF = 4e18; const ll dy[8] = {1, 0, -1, 0, 1, 1, -1, -1}; const ll dx[8] = {0, -1, 0, 1, 1, -1, 1, -1}; using Graph = vector<vector<ll>>; // dijkstra  struct edge { ll to, cost; }; typedef pair<ll, ll> P; struct graph { ll V; vector<vector<edge>> G; vector<ll> d; graph(ll n) { init(n); } void init(ll n) { V = n; G.resize(V); d.resize(V); rep(i, V) { d[i] = INF; } } void add_edge(ll s, ll t, ll cost) { edge e; e.to = t, e.cost = cost; G[s].push_back(e); } void dijkstra(ll s) { rep(i, V) { d[i] = INF; } d[s] = 0; priority_queue<P, vector<P>, greater<P>> que; que.push(P(0, s)); while (!que.empty()) { P p = que.top(); que.pop(); ll v = p.second; if (d[v] < p.first) continue; for (auto e : G[v]) { if (d[e.to] > d[v] + e.cost) { d[e.to] = d[v] + e.cost; que.push(P(d[e.to], e.to)); } } } } }; // dijkstra end class UnionFind { public: ll par[100005]; ll depth[100005]; ll nGroup[100005]; UnionFind(ll n) { init(n); } void init(ll n) { for (ll i = 0; i < n; i++) { par[i] = i; depth[i] = 0; nGroup[i] = 1; } } ll root(ll x) { if (par[x] == x) { return x; } else { return par[x] = root(par[x]); } } bool same(ll x, ll y) { return root(x) == root(y); } void unite(ll x, ll y) { x = root(x); y = root(y); if (x == y) return; if (depth[x] < depth[y]) { par[x] = y; nGroup[y] += nGroup[x]; nGroup[x] = 0; } else { par[y] = x; nGroup[x] += nGroup[y]; nGroup[y] = 0; if (depth[x] == depth[y]) depth[x]++; } } }; // unionfind end // nCr const ll MAX = 500010; ll fac[MAX], finv[MAX], inv[MAX]; void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (ll 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; } } // nCr end // tree DP vector<ll> depth; vector<ll> h; void dfs(const Graph &G, ll v, ll p, ll d) { for (auto nv : G[v]) { if (nv == p) continue; dfs(G, nv, v, d); } if (d != v) { if (h[v] == 1 || depth[v] != 0) { depth[p] += 2 + depth[v]; } // cout << v << " " << depth[v] << " " << p << endl; } } // tree DP end template <ll MOD> struct Fp { ll val; constexpr Fp(ll v = 0) noexcept : val(v % MOD) { if (val < 0) val += MOD; } constexpr ll getmod() { return MOD; } constexpr Fp operator-() const noexcept { return val ? MOD - val : 0; } constexpr Fp operator+(const Fp &r) const noexcept { return Fp(*this) += r; } constexpr Fp operator-(const Fp &r) const noexcept { return Fp(*this) -= r; } constexpr Fp operator*(const Fp &r) const noexcept { return Fp(*this) *= r; } constexpr Fp operator/(const Fp &r) const noexcept { return Fp(*this) /= r; } constexpr Fp &operator+=(const Fp &r) noexcept { val += r.val; if (val >= MOD) val -= MOD; return *this; } constexpr Fp &operator-=(const Fp &r) noexcept { val -= r.val; if (val < 0) val += MOD; return *this; } constexpr Fp &operator*=(const Fp &r) noexcept { val = val * r.val % MOD; return *this; } constexpr Fp &operator/=(const Fp &r) noexcept { ll a = r.val, b = MOD, u = 1, v = 0; while (b) { ll t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } val = val * u % MOD; if (val < 0) val += MOD; return *this; } constexpr bool operator==(const Fp &r) const noexcept { return this->val == r.val; } constexpr bool operator!=(const Fp &r) const noexcept { return this->val != r.val; } friend constexpr ostream &operator<<(ostream &os, const Fp<MOD> &x) noexcept { return os << x.val; } friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, ll n) noexcept { if (n == 0) return 1; auto t = modpow(a, n / 2); t = t * t; if (n & 1) t = t * a; return t; } }; using mint = Fp<MOD>; mint calc(ll N, ll K) { mint res = 1; for (ll n = 0; n < K; ++n) { res *= (N - n); res /= (n + 1); } return res; } mint COM(ll n, ll k) { if (k == 0) return 1; if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } int main() { ll n; cin >> n; if (n % 2 == 0) { ll m = n * (n - 2) / 2; cout << m << endl; ll k = n; for (ll i = 1; i <= n; i++) { for (ll j = i + 1; j <= n; j++) { if (j != k) { cout << i << " " << j << endl; } } k--; } } else { ll m = (n - 1) + (n - 2) * (n - 1); cout << m << endl; ll k = n - 1; for (ll i = 1; i <= n; i++) { for (ll j = i + 1; j <= n; j++) { if (j != k) { cout << i << " " << j << endl; } } k--; } } }
#include <bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> // using namespace __gnu_pbds; //#include<atcoder/all> using namespace std; // using namespace atcoder; #define rep(i, n) for (ll i = 0; i < n; i++) #define repl(i, l, r) for (ll i = (l); i < (r); i++) #define per(i, n) for (ll i = n - 1; i >= 0; i--) #define perl(i, r, l) for (ll i = r - 1; i >= l; i--) #define fi first #define se second #define pb push_back #define ins insert #define all(x) (x).begin(), (x).end() using ll = long long; using vl = vector<ll>; using vvl = vector<vector<ll>>; const ll MOD9 = 1000000007; const ll MOD = 998244353; const int inf = 1e9 + 10; const ll INF = 4e18; const ll dy[8] = {1, 0, -1, 0, 1, 1, -1, -1}; const ll dx[8] = {0, -1, 0, 1, 1, -1, 1, -1}; using Graph = vector<vector<ll>>; // dijkstra  struct edge { ll to, cost; }; typedef pair<ll, ll> P; struct graph { ll V; vector<vector<edge>> G; vector<ll> d; graph(ll n) { init(n); } void init(ll n) { V = n; G.resize(V); d.resize(V); rep(i, V) { d[i] = INF; } } void add_edge(ll s, ll t, ll cost) { edge e; e.to = t, e.cost = cost; G[s].push_back(e); } void dijkstra(ll s) { rep(i, V) { d[i] = INF; } d[s] = 0; priority_queue<P, vector<P>, greater<P>> que; que.push(P(0, s)); while (!que.empty()) { P p = que.top(); que.pop(); ll v = p.second; if (d[v] < p.first) continue; for (auto e : G[v]) { if (d[e.to] > d[v] + e.cost) { d[e.to] = d[v] + e.cost; que.push(P(d[e.to], e.to)); } } } } }; // dijkstra end class UnionFind { public: ll par[100005]; ll depth[100005]; ll nGroup[100005]; UnionFind(ll n) { init(n); } void init(ll n) { for (ll i = 0; i < n; i++) { par[i] = i; depth[i] = 0; nGroup[i] = 1; } } ll root(ll x) { if (par[x] == x) { return x; } else { return par[x] = root(par[x]); } } bool same(ll x, ll y) { return root(x) == root(y); } void unite(ll x, ll y) { x = root(x); y = root(y); if (x == y) return; if (depth[x] < depth[y]) { par[x] = y; nGroup[y] += nGroup[x]; nGroup[x] = 0; } else { par[y] = x; nGroup[x] += nGroup[y]; nGroup[y] = 0; if (depth[x] == depth[y]) depth[x]++; } } }; // unionfind end // nCr const ll MAX = 500010; ll fac[MAX], finv[MAX], inv[MAX]; void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (ll 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; } } // nCr end // tree DP vector<ll> depth; vector<ll> h; void dfs(const Graph &G, ll v, ll p, ll d) { for (auto nv : G[v]) { if (nv == p) continue; dfs(G, nv, v, d); } if (d != v) { if (h[v] == 1 || depth[v] != 0) { depth[p] += 2 + depth[v]; } // cout << v << " " << depth[v] << " " << p << endl; } } // tree DP end template <ll MOD> struct Fp { ll val; constexpr Fp(ll v = 0) noexcept : val(v % MOD) { if (val < 0) val += MOD; } constexpr ll getmod() { return MOD; } constexpr Fp operator-() const noexcept { return val ? MOD - val : 0; } constexpr Fp operator+(const Fp &r) const noexcept { return Fp(*this) += r; } constexpr Fp operator-(const Fp &r) const noexcept { return Fp(*this) -= r; } constexpr Fp operator*(const Fp &r) const noexcept { return Fp(*this) *= r; } constexpr Fp operator/(const Fp &r) const noexcept { return Fp(*this) /= r; } constexpr Fp &operator+=(const Fp &r) noexcept { val += r.val; if (val >= MOD) val -= MOD; return *this; } constexpr Fp &operator-=(const Fp &r) noexcept { val -= r.val; if (val < 0) val += MOD; return *this; } constexpr Fp &operator*=(const Fp &r) noexcept { val = val * r.val % MOD; return *this; } constexpr Fp &operator/=(const Fp &r) noexcept { ll a = r.val, b = MOD, u = 1, v = 0; while (b) { ll t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } val = val * u % MOD; if (val < 0) val += MOD; return *this; } constexpr bool operator==(const Fp &r) const noexcept { return this->val == r.val; } constexpr bool operator!=(const Fp &r) const noexcept { return this->val != r.val; } friend constexpr ostream &operator<<(ostream &os, const Fp<MOD> &x) noexcept { return os << x.val; } friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, ll n) noexcept { if (n == 0) return 1; auto t = modpow(a, n / 2); t = t * t; if (n & 1) t = t * a; return t; } }; using mint = Fp<MOD>; mint calc(ll N, ll K) { mint res = 1; for (ll n = 0; n < K; ++n) { res *= (N - n); res /= (n + 1); } return res; } mint COM(ll n, ll k) { if (k == 0) return 1; if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } int main() { ll n; cin >> n; if (n % 2 == 0) { ll m = n * (n - 2) / 2; cout << m << endl; ll k = n; for (ll i = 1; i <= n; i++) { for (ll j = i + 1; j <= n; j++) { if (j != k) { cout << i << " " << j << endl; } } k--; } } else { ll m = ((n - 1) + (n - 2) * (n - 1)) / 2; cout << m << endl; ll k = n - 1; for (ll i = 1; i <= n; i++) { for (ll j = i + 1; j <= n; j++) { if (j != k) { cout << i << " " << j << endl; } } k--; } } }
[ "assignment.change" ]
904,395
904,396
u722640678
cpp
p03090
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; typedef pair<P, ll> PLL; typedef pair<P, P> PP; typedef vector<ll> VECLL; typedef vector<P> VECP; typedef priority_queue<P, VECP, greater<P>> PQP; typedef priority_queue<ll, VECLL, greater<ll>> PQll; #define rep(i, a, n) for (ll i = a; i < n; i++) #define rrep(i, a, n) for (ll i = n; i >= a; i--) #define index_check(i, n) \ if (i > n - 1 || i < 0) \ continue; #define LINF (ll)1e18 #define INF (int)1e9 #define fs first #define sc second int main() { ll n; cin >> n; vector<P> vec; rep(i, 1, n + 1) { rep(j, i + 1, n + 1) { if (n % 2) { if (i + j == n - 1 || j == n) { vec.push_back(P(i, j)); } } else { if (i + j == n) { vec.push_back(P(i, j)); } } } } cout << vec.size() << endl; rep(i, 0, vec.size()) { cout << vec[i].fs << " " << vec[i].sc << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; typedef pair<P, ll> PLL; typedef pair<P, P> PP; typedef vector<ll> VECLL; typedef vector<P> VECP; typedef priority_queue<P, VECP, greater<P>> PQP; typedef priority_queue<ll, VECLL, greater<ll>> PQll; #define rep(i, a, n) for (ll i = a; i < n; i++) #define rrep(i, a, n) for (ll i = n; i >= a; i--) #define index_check(i, n) \ if (i > n - 1 || i < 0) \ continue; #define LINF (ll)1e18 #define INF (int)1e9 #define fs first #define sc second int main() { ll n; cin >> n; vector<P> vec; rep(i, 1, n + 1) { rep(j, i + 1, n + 1) { if (n % 2) { if (i + j != n || j == n) { vec.push_back(P(i, j)); } } else { if (i + j != n + 1) { vec.push_back(P(i, j)); } } } } cout << vec.size() << endl; rep(i, 0, vec.size()) { cout << vec[i].fs << " " << vec[i].sc << endl; } return 0; }
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change", "expression.operation.binary.remove" ]
904,397
904,398
u129134470
cpp
p03090
#include <bits/stdc++.h> #define itn int #define REP(i, n) for (ll i = 0; i < n; i++) #define IREP(i, n) for (ll i = n - 1; i >= 0; i--) #define FOR(i, a, b) for (ll i = a; i < b; i++) #define all(v) v.begin(), v.end() #define SENTINEL 2000000000 #define NIL -1 using namespace std; typedef long long ll; const ll MAX = 510000; const ll INF = 1LL << 60; const ll MOD = 1000000007; 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; } int main() { ll n; cin >> n; if (n % 2 == 0) { cout << n * (n - 2) / 2 << endl; REP(i, n) { ll k = i + 1; FOR(j, i + 1, n) { if (k + j + 1 == n + 1) { continue; } cout << k << " " << j + 1 << endl; } } } else { cout << (n - 2) * (n - 1) / 2 << endl; REP(i, n - 1) { ll k = i + 1; FOR(j, i + 1, n) { if (k + j + 1 == n) { continue; } cout << k << " " << j + 1 << endl; } } } }
#include <bits/stdc++.h> #define itn int #define REP(i, n) for (ll i = 0; i < n; i++) #define IREP(i, n) for (ll i = n - 1; i >= 0; i--) #define FOR(i, a, b) for (ll i = a; i < b; i++) #define all(v) v.begin(), v.end() #define SENTINEL 2000000000 #define NIL -1 using namespace std; typedef long long ll; const ll MAX = 510000; const ll INF = 1LL << 60; const ll MOD = 1000000007; 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; } int main() { ll n; cin >> n; if (n % 2 == 0) { cout << n * (n - 2) / 2 << endl; REP(i, n) { ll k = i + 1; FOR(j, i + 1, n) { if (k + j + 1 == n + 1) { continue; } cout << k << " " << j + 1 << endl; } } } else { cout << n - 1 + (n - 3) * (n - 1) / 2 << endl; REP(i, n - 1) { ll k = i + 1; FOR(j, i + 1, n) { if (k + j + 1 == n) { continue; } cout << k << " " << j + 1 << endl; } } } }
[ "literal.number.change", "io.output.change" ]
904,399
904,400
u118875091
cpp
p03090
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define REP(i, n) for (int i = 1; i < (int)(n); i++) #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define debug(var) \ do { \ cout << #var << " : "; \ view(var); \ } while (0) template <class T> bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } template <class T> bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } using namespace std; template <class T> void view(T e) { cout << e << endl; } template <class T> void view(const vector<T> &v) { for (const auto &e : v) { cout << e << " "; } cout << endl; } template <class T> void view(const vector<vector<T>> &vv) { for (const auto &v : vv) { view(v); } } using vint = vector<int>; using vvint = vector<vector<int>>; using ll = long long; using vll = vector<ll>; using vvll = vector<vector<ll>>; using P = pair<int, int>; const int inf = 1e9; const ll inf_l = 1e18; const int MAX = 1e5; int main() { int n; cin >> n; vector<P> ans; if (n & 1) { for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (i == j || j == n - i) continue; ans.push_back(P(i, j)); } } } else { for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (i == j || i + j == n + 1) continue; ans.push_back(P(i, j)); } } } cout << ans.size() << endl; rep(i, ans.size()) cout << ans[i].first << " " << ans[i].second << endl; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define REP(i, n) for (int i = 1; i < (int)(n); i++) #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define debug(var) \ do { \ cout << #var << " : "; \ view(var); \ } while (0) template <class T> bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } template <class T> bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } using namespace std; template <class T> void view(T e) { cout << e << endl; } template <class T> void view(const vector<T> &v) { for (const auto &e : v) { cout << e << " "; } cout << endl; } template <class T> void view(const vector<vector<T>> &vv) { for (const auto &v : vv) { view(v); } } using vint = vector<int>; using vvint = vector<vector<int>>; using ll = long long; using vll = vector<ll>; using vvll = vector<vector<ll>>; using P = pair<int, int>; const int inf = 1e9; const ll inf_l = 1e18; const int MAX = 1e5; int main() { int n; cin >> n; vector<P> ans; if (n & 1) { for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) { if (i == j || j == n - i) continue; ans.push_back(P(i, j)); } } } else { for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) { if (i == j || i + j == n + 1) continue; ans.push_back(P(i, j)); } } } cout << ans.size() << endl; rep(i, ans.size()) cout << ans[i].first << " " << ans[i].second << endl; }
[ "control_flow.loop.for.initializer.change" ]
904,401
904,402
u697968316
cpp
p03090
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, s, n) for (int i = s; i < (int)(n); i++) #define Clear(a) a = decltype(a)() // queueのclear #define all(s) (s).begin(), (s).end() typedef long long ll; typedef pair<int, int> p; // const ll big=998244353; const ll big = 1000000007; const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; ll max(ll x, ll y) { if (x > y) return x; else return y; } ll min(ll x, ll y) { if (x < y) return x; else return y; } ll expm(ll x, ll y) { if (y == 0) return 1; // 0^0=1 if (x == 1 || x == 0) return x; if (y % 2 == 1) return (expm(x, y - 1) * x) % big; ll t = expm(x, y / 2); return (t * t) % big; } ll exp(ll x, ll y) { if (y == 0) return 1; // 0^0=1 if (x == 1 || y == 0) return x; if (y % 2 == 1) return exp(x, y - 1) * x; ll t = exp(x, y / 2); return t * t; } ll inv(ll x) { return expm(x, big - 2); } ll find(ll l, ll r, vector<vector<ll>> &dp, int n, ll wm) { if (r - l == 1) return l; ll s = (l + r) / 2; if (dp[n][s] > wm) return find(l, s, dp, n, wm); else return find(s, r, dp, n, wm); }; int main() { ios::sync_with_stdio(false); std::cin.tie(nullptr); cout << fixed << setprecision(10); /*--------------------------------*/ int n; cin >> n; if (n % 2 == 0) { cout << n * (n - 1) / 2 - (n - 1) / 2 << endl; rep2(i, 1, n) rep2(j, i + 1, n + 1) { if (i + j != n + 1) cout << i << ' ' << j << endl; } } else { cout << n * (n - 1) / 2 - n / 2 << endl; rep2(i, 1, n) rep2(j, i + 1, n + 1) { if (i + j != n) cout << i << ' ' << j << endl; } } } /* N:odd {1,N-1},{2,N-2},...,{i,N-i},...,{(N-1)/2,(N+1)/2},{N} N:even {1,N},{2,N-1},...,{i,N-i+1},...,{N/2,N/2+1} */
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, s, n) for (int i = s; i < (int)(n); i++) #define Clear(a) a = decltype(a)() // queueのclear #define all(s) (s).begin(), (s).end() typedef long long ll; typedef pair<int, int> p; // const ll big=998244353; const ll big = 1000000007; const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; ll max(ll x, ll y) { if (x > y) return x; else return y; } ll min(ll x, ll y) { if (x < y) return x; else return y; } ll expm(ll x, ll y) { if (y == 0) return 1; // 0^0=1 if (x == 1 || x == 0) return x; if (y % 2 == 1) return (expm(x, y - 1) * x) % big; ll t = expm(x, y / 2); return (t * t) % big; } ll exp(ll x, ll y) { if (y == 0) return 1; // 0^0=1 if (x == 1 || y == 0) return x; if (y % 2 == 1) return exp(x, y - 1) * x; ll t = exp(x, y / 2); return t * t; } ll inv(ll x) { return expm(x, big - 2); } ll find(ll l, ll r, vector<vector<ll>> &dp, int n, ll wm) { if (r - l == 1) return l; ll s = (l + r) / 2; if (dp[n][s] > wm) return find(l, s, dp, n, wm); else return find(s, r, dp, n, wm); }; int main() { ios::sync_with_stdio(false); std::cin.tie(nullptr); cout << fixed << setprecision(10); /*--------------------------------*/ int n; cin >> n; if (n % 2 == 0) { cout << n * (n - 1) / 2 - (n + 1) / 2 << endl; rep2(i, 1, n) rep2(j, i + 1, n + 1) { if (i + j != n + 1) cout << i << ' ' << j << endl; } } else { cout << n * (n - 1) / 2 - n / 2 << endl; rep2(i, 1, n) rep2(j, i + 1, n + 1) { if (i + j != n) cout << i << ' ' << j << endl; } } } /* N:odd {1,N-1},{2,N-2},...,{i,N-i},...,{(N-1)/2,(N+1)/2},{N} N:even {1,N},{2,N-1},...,{i,N-i+1},...,{N/2,N/2+1} */
[ "misc.opposites", "expression.operator.arithmetic.change", "io.output.change" ]
904,405
904,406
u425758699
cpp
p03090
/*****/ #define TRUE true //#define FALSE false #include <bits/stdc++.h> /**/ #pragma GCC target("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") /**/ using namespace std; using ll = long long; using ld = long double; using pint = pair<int, int>; using pll = pair<long long, long long>; template <class T> using vec = vector<T>; template <class T> using vec2 = vector<vector<T>>; template <class T> using vec3 = vector<vector<vector<T>>>; constexpr int INF = numeric_limits<int>::max(); constexpr ll INFL = numeric_limits<ll>::max(); constexpr ll MOD = 1000000007; // 10^9+7 #ifdef TRUE #define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i) #define rep1(i, n) for (ll i = 1, i##_len = (n); i <= i##_len; ++i) #define rrep(i, n) for (ll i = (n)-1; i >= 0; --i) #define rrep1(i, n) for (ll i = (n); i > 0; --i) #define step(i, a, n) for (ll i = (a), i##_len = (a) + (n); i < i##_len; ++i) #define rstep(i, a, n) \ for (ll i = (a) + (n)-1, i##_len = (a); i >= i##_len; --i) #define range(i, a, b) for (ll i = (a), i##_len = (b); i < i##_len; ++i) #define rrange(i, a, b) for (ll i = (b)-1, i##_len = (a); i >= i##_len; --i) std::string strMulti(const int n, const std::string &t) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; } std::string tab(const int n) { return string(n, '\t'); } std::string join(const vector<string> &v, const char *delim = 0) { std::string s; if (!v.empty()) { s += v[0]; for (decltype(v.size()) i = 1, c = v.size(); i < c; ++i) { if (delim) s += delim; s += v[i]; } } return s; } string to_string(string &s) { return '"' + s + '"'; } string to_string(char &c) { return string({'\'', c, '\''}); } template <class T1, class T2> string to_string(pair<T1, T2> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; } template <class Tuple, size_t... I> string _to_string_tuple(Tuple &&t, std::index_sequence<I...>) { return "(" + join({to_string(std::get<I>(t))...}, ", ") + ")"; } template <class... Args> string to_string(tuple<Args...> t) { return _to_string_tuple( std::forward<tuple<Args...>>(t), std::make_index_sequence< std::tuple_size<std::decay_t<tuple<Args...>>>::value>{}); } template <class T> string to_string(vector<T> ar) { vector<string> texts(ar.size()); for (size_t i = 0; i < ar.size(); ++i) { texts[i] = to_string(ar[i]); } return "{" + join(texts, ", ") + "}"; } template <class T> string to_string(set<T> s) { vector<string> texts(s.size()); int i = 0; for (auto e : s) { texts[i] = to_string(e); i++; } return "{" + join(texts, ", ") + "}"; } template <class T1, class T2> string to_string(map<T1, T2> m) { vector<string> texts(m.size()); int i = 0; for (auto e : m) { texts[i] = to_string(e); i++; } return "{" + join(texts, ", ") + "}"; } template <class T> string to_string(initializer_list<T> il) { vector<string> texts(il.size()); size_t i = 0; for (T v : il) { texts[i] = to_string(v); i++; } return "{" + join(texts, ", ") + "}"; } void debug(string name); void debugn(string name); template <class T> void debug(string name, T v); template <class T> void debugn(string name, T v); template <class T> void debug(string name, initializer_list<T> il); template <class T> void debugn(string name, initializer_list<T> il); template <class... Args> void debug(string name, Args... args); template <class... Args> void debugn(string name, Args... args); void debugdo(function<void()> func); #ifdef DEBUG_BUILD #define debugvar(x) debugn(#x, (x)) #define debugvartab(x, t) debugn(tab(t) + #x, (x)) void debug(string name) { std::cerr << name; } void debugn(string name) { std::cerr << name << '\n'; } template <class T> void debug(string name, T v) { std::cerr << name << " = " << to_string(v); } template <class T> void debugn(string name, T v) { std::cerr << name << " = " << to_string(v) << '\n'; } template <class T> void debug(string name, initializer_list<T> il) { std::cerr << name << " = " << to_string(il); } template <class T> void debugn(string name, initializer_list<T> il) { std::cerr << name << " = " << to_string(il) << '\n'; } template <class... Args> void debug(string name, Args... args) { std::cerr << name << " = " << to_string(tuple<Args...>(args...)); } template <class... Args> void debugn(string name, Args... args) { std::cerr << name << " = " << to_string(tuple<Args...>(args...)) << '\n'; } void debugdo(function<void()> func) { func(); } #else #define debugvar(x) #define debugvartab(x, t) void debug(string name) {} void debugn(string name) {} template <class T> void debug(string name, T v) {} template <class T> void debugn(string name, T v) {} template <class T> void debug(string name, initializer_list<T> il) {} template <class T> void debugn(string name, initializer_list<T> il) {} template <class... Args> void debug(string name, Args... args) {} template <class... Args> void debugn(string name, Args... args) {} void debugdo(function<void()> func) {} #endif #define all(x) (x).begin(), (x).end() #define pair(a, b) make_pair(a, b) template <class T> bool chmax(T &a, const T b) { if (a < b) { a = b; return true; } return false; } template <class T> bool chmin(T &a, const T b) { if (a > b) { a = b; return true; } return false; } template <class T> T divup(const T a, const T b) { return (a + (b - 1)) / b; } template <class T> bool cmp_2nd(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; } ll modpow(ll x, ll n, const ll &p) { ll ret = 1; while (n > 0) { if (n & 1) { (ret *= x) %= p; } (x *= x) %= p; n >>= 1; } return ret; } template <class T> T modinv(T a, const T &p) { T b = p, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= p; if (u < 0) { u += p; } return u; } template <class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; } template <class T> T math_C(T m, T n) { T ret = math_P(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; } ll extended_euclidean(ll u, ll v) { ll r0 = u; ll r1 = v; ll s0 = 1; ll s1 = 0; ll t0 = 0; ll t1 = 1; while (r1 != 0) { ll q = r0 / r1; ll r = r0 - q * r1; ll s = s0 - q * s1; ll t = t0 - q * t1; r0 = r1; s0 = s1; t0 = t1; r1 = r; s1 = s; t1 = t; } if (t0 < 0) { return t0 + u; } else { return t0; } } ll math_C_mod(ll n, ll c, const ll &p) { ll upe = 1; ll dow = 1; for (ll i = 1; i < c + 1; ++i) { upe = upe * n % p; dow = dow * i % p; n -= 1; } return (upe * extended_euclidean(p, dow)) % p; } template <class T> T math_gcd(T a, T b) { if (b == 0) { return a; } else { return math_gcd(b, a % b); } } template <class T> T math_lcm(T a, T b) { return a / math_gcd(a, b) * b; } template <class T> T SumStep(T a, T n, T d) { return n * (2 * a + (n - 1) * d) / 2; } template <class T> T SumRange(T a, T b, T d) { return SumStep(a, (b - a) / d, d); } #endif /*****/ int N, NG; vec<pint> G; void Main() { cin >> N; NG = N % 2 == 0 ? N : N - 1; for (int u = 1; u <= N; ++u) { for (int v = u + 1; v <= N; ++v) { if (v != NG) G.emplace_back(u, v); } } cout << G.size() << "\n"; for (auto g : G) { cout << g.first << " " << g.second << "\n"; } } /*****/ int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout << std::fixed << std::setprecision(10); Main(); std::cerr << flush; std::cout << flush; return 0; }
/*****/ #define TRUE true //#define FALSE false #include <bits/stdc++.h> /**/ #pragma GCC target("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") /**/ using namespace std; using ll = long long; using ld = long double; using pint = pair<int, int>; using pll = pair<long long, long long>; template <class T> using vec = vector<T>; template <class T> using vec2 = vector<vector<T>>; template <class T> using vec3 = vector<vector<vector<T>>>; constexpr int INF = numeric_limits<int>::max(); constexpr ll INFL = numeric_limits<ll>::max(); constexpr ll MOD = 1000000007; // 10^9+7 #ifdef TRUE #define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i) #define rep1(i, n) for (ll i = 1, i##_len = (n); i <= i##_len; ++i) #define rrep(i, n) for (ll i = (n)-1; i >= 0; --i) #define rrep1(i, n) for (ll i = (n); i > 0; --i) #define step(i, a, n) for (ll i = (a), i##_len = (a) + (n); i < i##_len; ++i) #define rstep(i, a, n) \ for (ll i = (a) + (n)-1, i##_len = (a); i >= i##_len; --i) #define range(i, a, b) for (ll i = (a), i##_len = (b); i < i##_len; ++i) #define rrange(i, a, b) for (ll i = (b)-1, i##_len = (a); i >= i##_len; --i) std::string strMulti(const int n, const std::string &t) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; } std::string tab(const int n) { return string(n, '\t'); } std::string join(const vector<string> &v, const char *delim = 0) { std::string s; if (!v.empty()) { s += v[0]; for (decltype(v.size()) i = 1, c = v.size(); i < c; ++i) { if (delim) s += delim; s += v[i]; } } return s; } string to_string(string &s) { return '"' + s + '"'; } string to_string(char &c) { return string({'\'', c, '\''}); } template <class T1, class T2> string to_string(pair<T1, T2> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; } template <class Tuple, size_t... I> string _to_string_tuple(Tuple &&t, std::index_sequence<I...>) { return "(" + join({to_string(std::get<I>(t))...}, ", ") + ")"; } template <class... Args> string to_string(tuple<Args...> t) { return _to_string_tuple( std::forward<tuple<Args...>>(t), std::make_index_sequence< std::tuple_size<std::decay_t<tuple<Args...>>>::value>{}); } template <class T> string to_string(vector<T> ar) { vector<string> texts(ar.size()); for (size_t i = 0; i < ar.size(); ++i) { texts[i] = to_string(ar[i]); } return "{" + join(texts, ", ") + "}"; } template <class T> string to_string(set<T> s) { vector<string> texts(s.size()); int i = 0; for (auto e : s) { texts[i] = to_string(e); i++; } return "{" + join(texts, ", ") + "}"; } template <class T1, class T2> string to_string(map<T1, T2> m) { vector<string> texts(m.size()); int i = 0; for (auto e : m) { texts[i] = to_string(e); i++; } return "{" + join(texts, ", ") + "}"; } template <class T> string to_string(initializer_list<T> il) { vector<string> texts(il.size()); size_t i = 0; for (T v : il) { texts[i] = to_string(v); i++; } return "{" + join(texts, ", ") + "}"; } void debug(string name); void debugn(string name); template <class T> void debug(string name, T v); template <class T> void debugn(string name, T v); template <class T> void debug(string name, initializer_list<T> il); template <class T> void debugn(string name, initializer_list<T> il); template <class... Args> void debug(string name, Args... args); template <class... Args> void debugn(string name, Args... args); void debugdo(function<void()> func); #ifdef DEBUG_BUILD #define debugvar(x) debugn(#x, (x)) #define debugvartab(x, t) debugn(tab(t) + #x, (x)) void debug(string name) { std::cerr << name; } void debugn(string name) { std::cerr << name << '\n'; } template <class T> void debug(string name, T v) { std::cerr << name << " = " << to_string(v); } template <class T> void debugn(string name, T v) { std::cerr << name << " = " << to_string(v) << '\n'; } template <class T> void debug(string name, initializer_list<T> il) { std::cerr << name << " = " << to_string(il); } template <class T> void debugn(string name, initializer_list<T> il) { std::cerr << name << " = " << to_string(il) << '\n'; } template <class... Args> void debug(string name, Args... args) { std::cerr << name << " = " << to_string(tuple<Args...>(args...)); } template <class... Args> void debugn(string name, Args... args) { std::cerr << name << " = " << to_string(tuple<Args...>(args...)) << '\n'; } void debugdo(function<void()> func) { func(); } #else #define debugvar(x) #define debugvartab(x, t) void debug(string name) {} void debugn(string name) {} template <class T> void debug(string name, T v) {} template <class T> void debugn(string name, T v) {} template <class T> void debug(string name, initializer_list<T> il) {} template <class T> void debugn(string name, initializer_list<T> il) {} template <class... Args> void debug(string name, Args... args) {} template <class... Args> void debugn(string name, Args... args) {} void debugdo(function<void()> func) {} #endif #define all(x) (x).begin(), (x).end() #define pair(a, b) make_pair(a, b) template <class T> bool chmax(T &a, const T b) { if (a < b) { a = b; return true; } return false; } template <class T> bool chmin(T &a, const T b) { if (a > b) { a = b; return true; } return false; } template <class T> T divup(const T a, const T b) { return (a + (b - 1)) / b; } template <class T> bool cmp_2nd(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; } ll modpow(ll x, ll n, const ll &p) { ll ret = 1; while (n > 0) { if (n & 1) { (ret *= x) %= p; } (x *= x) %= p; n >>= 1; } return ret; } template <class T> T modinv(T a, const T &p) { T b = p, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= p; if (u < 0) { u += p; } return u; } template <class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; } template <class T> T math_C(T m, T n) { T ret = math_P(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; } ll extended_euclidean(ll u, ll v) { ll r0 = u; ll r1 = v; ll s0 = 1; ll s1 = 0; ll t0 = 0; ll t1 = 1; while (r1 != 0) { ll q = r0 / r1; ll r = r0 - q * r1; ll s = s0 - q * s1; ll t = t0 - q * t1; r0 = r1; s0 = s1; t0 = t1; r1 = r; s1 = s; t1 = t; } if (t0 < 0) { return t0 + u; } else { return t0; } } ll math_C_mod(ll n, ll c, const ll &p) { ll upe = 1; ll dow = 1; for (ll i = 1; i < c + 1; ++i) { upe = upe * n % p; dow = dow * i % p; n -= 1; } return (upe * extended_euclidean(p, dow)) % p; } template <class T> T math_gcd(T a, T b) { if (b == 0) { return a; } else { return math_gcd(b, a % b); } } template <class T> T math_lcm(T a, T b) { return a / math_gcd(a, b) * b; } template <class T> T SumStep(T a, T n, T d) { return n * (2 * a + (n - 1) * d) / 2; } template <class T> T SumRange(T a, T b, T d) { return SumStep(a, (b - a) / d, d); } #endif /*****/ int N, NG; vec<pint> G; void Main() { cin >> N; NG = N % 2 == 0 ? N : N - 1; for (int u = 1; u <= N; ++u) { for (int v = u + 1; v <= N; ++v) { if (v != NG) G.emplace_back(u, v); } --NG; } cout << G.size() << "\n"; for (auto g : G) { cout << g.first << " " << g.second << "\n"; } } /*****/ int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout << std::fixed << std::setprecision(10); Main(); std::cerr << flush; std::cout << flush; return 0; }
[ "expression.unary.arithmetic.add" ]
904,409
904,410
u588369531
cpp
p03090
#include <bits/stdc++.h> using namespace std; //#define int long long typedef long long ll; // const int INF = 2e9; // const ll INF = 9e18; signed main() { ios::sync_with_stdio(false); cin.tie(0); int N; cin >> N; set<pair<int, int>> p; if (N % 2 == 0) { for (int i = 1; i <= N / 2; i++) { p.insert(make_pair(i, N - i)); } } else { for (int i = 1; i <= N / 2; i++) { p.insert(make_pair(i, N - i)); } } vector<pair<int, int>> ans; for (int i = 1; i < N; i++) { for (int j = i + 1; j <= N; j++) { if (p.find(make_pair(i, j)) == p.end()) { ans.emplace_back(i, j); } } } cout << ans.size() << "\n"; for (int i = 0; i < ans.size(); i++) { cout << ans[i].first << " " << ans[i].second << "\n"; } }
#include <bits/stdc++.h> using namespace std; //#define int long long typedef long long ll; // const int INF = 2e9; // const ll INF = 9e18; signed main() { ios::sync_with_stdio(false); cin.tie(0); int N; cin >> N; set<pair<int, int>> p; if (N % 2 == 0) { for (int i = 1; i <= N / 2; i++) { p.insert(make_pair(i, N + 1 - i)); } } else { for (int i = 1; i <= N / 2; i++) { p.insert(make_pair(i, N - i)); } } vector<pair<int, int>> ans; for (int i = 1; i < N; i++) { for (int j = i + 1; j <= N; j++) { if (p.find(make_pair(i, j)) == p.end()) { ans.emplace_back(i, j); } } } cout << ans.size() << "\n"; for (int i = 0; i < ans.size(); i++) { cout << ans[i].first << " " << ans[i].second << "\n"; } }
[ "expression.operation.binary.add" ]
904,411
904,412
u904131021
cpp
p03090
#include <cstdio> #include <iostream> #include <vector> using namespace std; typedef pair<int, int> pii; vector<pii> ans; int n; int main() { ios::sync_with_stdio(false); int i, j; cin >> n; if (n & 1) { for (i = 1; i < n; i++) ans.push_back(make_pair(i, n)); } n--; for (i = 1; i <= n; i++) for (j = i + 1; j <= n; j++) if (i + j != n + 1) ans.push_back(make_pair(i, j)); cout << (int)ans.size() << endl; for (i = 0; i < (int)ans.size(); i++) cout << ans[i].first << ' ' << ans[i].second << endl; return 0; }
#include <cstdio> #include <iostream> #include <vector> using namespace std; typedef pair<int, int> pii; vector<pii> ans; int n; int main() { ios::sync_with_stdio(false); int i, j; cin >> n; if (n & 1) { for (i = 1; i < n; i++) ans.push_back(make_pair(i, n)); n--; } for (i = 1; i <= n; i++) for (j = i + 1; j <= n; j++) if (i + j != n + 1) ans.push_back(make_pair(i, j)); cout << (int)ans.size() << endl; for (i = 0; i < (int)ans.size(); i++) cout << ans[i].first << ' ' << ans[i].second << endl; return 0; }
[]
904,413
904,414
u173958549
cpp
p03090
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; typedef vector<int> VI; 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 (a > b) { a = b; return 1; } return 0; } #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() template <typename T> struct edge { int src, to; T cost; edge(int to, T cost) : src(-1), to(to), cost(cost) {} edge(int src, int to, T cost) : src(src), to(to), cost(cost) {} edge &operator=(const int &x) { to = x; return *this; } operator int() const { return to; } }; template <typename T> using Edges = vector<edge<T>>; template <typename T> using WeightedGraph = vector<Edges<T>>; using UnWeightedGraph = vector<vector<int>>; template <typename T> using Matrix = vector<vector<T>>; int main() { int n; cin >> n; vector<P> ans; if (n % 2 == 0) { int s = n * (n + 1) / 2 - (n + 1); rep(i, 1, n + 1) { rep(j, i + 1, n + 1) { if (i + j == s) continue; ans.emplace_back(make_pair(i, j)); } } } else { int s = (n - 1) * n / 2; rep(i, 1, n) { ans.emplace_back(make_pair(i, n)); } rep(i, 1, n) { rep(j, i + 1, n) { if (i + j == n) continue; ans.emplace_back(make_pair(i, j)); } } } cout << ans.size() << endl; rep(i, ans.size()) { cout << ans[i].first << " " << ans[i].second << endl; } }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; typedef vector<int> VI; 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 (a > b) { a = b; return 1; } return 0; } #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() template <typename T> struct edge { int src, to; T cost; edge(int to, T cost) : src(-1), to(to), cost(cost) {} edge(int src, int to, T cost) : src(src), to(to), cost(cost) {} edge &operator=(const int &x) { to = x; return *this; } operator int() const { return to; } }; template <typename T> using Edges = vector<edge<T>>; template <typename T> using WeightedGraph = vector<Edges<T>>; using UnWeightedGraph = vector<vector<int>>; template <typename T> using Matrix = vector<vector<T>>; int main() { int n; cin >> n; vector<P> ans; if (n % 2 == 0) { int s = n * (n + 1) / 2 - (n + 1); rep(i, 1, n + 1) { rep(j, i + 1, n + 1) { if (i + j == n + 1) continue; ans.emplace_back(make_pair(i, j)); } } } else { int s = (n - 1) * n / 2; rep(i, 1, n) { ans.emplace_back(make_pair(i, n)); } rep(i, 1, n) { rep(j, i + 1, n) { if (i + j == n) continue; ans.emplace_back(make_pair(i, j)); } } } cout << ans.size() << endl; rep(i, ans.size()) { cout << ans[i].first << " " << ans[i].second << endl; } }
[ "identifier.change", "control_flow.branch.if.condition.change" ]
904,415
904,416
u378702452
cpp
p03090
#pragma GCC optimize("O3") #include <bits/stdc++.h> #define endl "\n" #define sz(x) ((ll)(x).size()) #define pb push_back #define all(x) (x).begin(), (x).end() #define prt(x) cout << (x) #define prtl(x) cout << (x) << endl #define rep(i, a, b) for (ll i = a; i < b; i++) #define rrep(i, a, b) for (ll i = a; i > b; i--) #define mp(a, b) make_pair(a, b) #define chmin(x, y) x = min(x, y) #define chmax(x, y) x = max(x, y) #define debug(v) cout << #v << ": " << v << endl; #define fst first #define snd second using namespace std; using vi = vector<int>; using vll = vector<long long int>; using vb = vector<bool>; using vvb = vector<vector<bool>>; using vc = vector<char>; using vvi = vector<vector<int>>; using vvll = vector<vector<long long int>>; using vvc = vector<vector<char>>; using ll = long long int; using P = pair<long long int, long long int>; using Map = map<long long int, long long int>; ll INF = 1LL << 60; ll M = 1000003; int main() { ll n; cin >> n; if (n % 2 == 0) { prtl((n - 1) * n / 2); rep(i, 1, n + 1) { rep(j, i + 1, n + 1) { if (i + j == n + 1) { continue; } else { prt(i); prt(" "); prtl(j); } } } } else { prtl((n - 1) * (n - 1) / 2); rep(i, 1, n) { rep(j, i + 1, n + 1) { if (i + j == n) { continue; } else { prt(i); prt(" "); prtl(j); } } } } }
#pragma GCC optimize("O3") #include <bits/stdc++.h> #define endl "\n" #define sz(x) ((ll)(x).size()) #define pb push_back #define all(x) (x).begin(), (x).end() #define prt(x) cout << (x) #define prtl(x) cout << (x) << endl #define rep(i, a, b) for (ll i = a; i < b; i++) #define rrep(i, a, b) for (ll i = a; i > b; i--) #define mp(a, b) make_pair(a, b) #define chmin(x, y) x = min(x, y) #define chmax(x, y) x = max(x, y) #define debug(v) cout << #v << ": " << v << endl; #define fst first #define snd second using namespace std; using vi = vector<int>; using vll = vector<long long int>; using vb = vector<bool>; using vvb = vector<vector<bool>>; using vc = vector<char>; using vvi = vector<vector<int>>; using vvll = vector<vector<long long int>>; using vvc = vector<vector<char>>; using ll = long long int; using P = pair<long long int, long long int>; using Map = map<long long int, long long int>; ll INF = 1LL << 60; ll M = 1000003; int main() { ll n; cin >> n; if (n % 2 == 0) { prtl((n - 2) * n / 2); rep(i, 1, n + 1) { rep(j, i + 1, n + 1) { if (i + j == n + 1) { continue; } else { prt(i); prt(" "); prtl(j); } } } } else { prtl((n - 1) * (n - 1) / 2); rep(i, 1, n) { rep(j, i + 1, n + 1) { if (i + j == n) { continue; } else { prt(i); prt(" "); prtl(j); } } } } }
[ "literal.number.change", "call.arguments.change", "expression.operation.binary.change" ]
904,417
904,418
u558667782
cpp
p03090
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (long long i = 0; i < n; i++) #define Rep(i, m, n) for (long long i = m; i < n; i++) #define REP(i, m, n, p) for (long long i = m; i < n; i += p) #define all(v) v.begin(), v.end() #define pq priority_queue #define bcnt(n) __builtin_popcountll(n) using vi = vector<int>; // intの1次元の型に vi という別名をつける using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける using vvvi = vector<vvi>; using ll = long long; // long longをllだけにした using vll = vector<ll>; using vvll = vector<vll>; using vvvll = vector<vvll>; using vb = vector<bool>; using vvb = vector<vb>; using mii = map<int, int>; using pqll = priority_queue<long long>; using pqllg = priority_queue<long long, vector<long long>, greater<long long>>; using mll = map<long long, long long>; using pll = pair<long long, long long>; using sll = set<long long>; using vpll = vector<pair<long long, long long>>; using mlv = map<long long, vector<long long>>; long long divup(long long a, long long b); long long kaijou(long long i); long long P(long long n, long long k); long long C(long long n, long long k); long long GCD(long long a, long long b); long long LCM(long long a, long long b); bool prime(long long N); double distance(vector<long long> p, vector<long long> q, long long n); void press(vector<long long> &v); void ranking(vector<long long> &v); void erase(vector<long long> &v, long long i); void unique(vector<long long> &v); void printv(vector<long long> v); vector<ll> keta(ll x); long long modpow(long long a, long long n, long long mod); long long modinv(long long a, long long mod); // 20200416 vector<long long> inputv(long long n); // 20200417 vector<long long> yakusuu(int n); map<long long, long long> soinsuu(long long n); vector<vector<long long>> maze(long long i, long long j, vector<string> &s); // 20200423 vector<long long> eratos(long long n); set<long long> eraset(long long n); ////////////////////////////////////////////////////// //端数繰りあがり割り算(検証済) // a÷bの端数繰り上げ // b!=0のデバグはしてないので分母に0を入れないように //負数対応 long long divup(long long a, long long b) { long long x = abs(a); long long y = abs(b); long long z = (x + y - 1) / y; if ((a < 0 && b > 0) || (a > 0 && b < 0)) return -z; else if (a == 0) return 0; else return z; } //階乗 //検証済み long long kaijou(long long i) { if (i == 0) return 1; long long j = 1; for (long long k = 1; k <= i; k++) { j *= k; } return j; } //順列nPk(完成) // n個の異なる要素から、取り出す順序を区別してk個取り出す場合の数 // n<kなら0を返す //敢えて負数時のデバグはしてない long long P(long long n, long long k) { if (n < k) return 0; long long y = 1; for (long long i = 0; i < k; i++) { y *= (n - i); } return y; } //組み合わせnCk(検証済み) // P,kaijouと併用 long long C(long long n, long long k) { if (n < k) return 0; return P(n, k) / kaijou(k); } // nHk //区別しないn個の要素を、区別するk個のグループに分ける // 0個のグループがあっ //て良い // C必須 //最大公約数GCD,最小公倍数LCM // LCMを使うときはGCDをセットで //検証済み long long GCD(long long a, long long b) { if (a < b) swap(a, b); long long d = a % b; if (d == 0) { return b; } return GCD(b, d); } long long LCM(long long a, long long b) { return (a / GCD(a, b)) * b; } //素数判定 //素数ならばtrue、素数以外の整数にはfalse //負数は全てfalse //検証済み bool prime(long long N) { if (N == 1) { return false; } if (N < 0) return false; long long p = sqrt(N); for (long long i = 2; i <= p; i++) { if (N % i == 0) { return false; } } return true; } //ユークリッド距離 //検証済み //位置ベクトル1,位置ベクトル2,ベクトルの次元(2または3が一般的) double distance(vector<long long> p, vector<long long> q, long long n) { double x = 0; for (long long i = 0; i < n; i++) { x += pow((p.at(i) - q.at(i)), 2); } return sqrt(x); } //配列圧縮(検証済) //{1,36,1,3,8,-2,-92}を //{2, 5,2,3,4, 1, 0}にする void press(vector<long long> &v) { long long n = v.size(); vector<long long> w(n); map<long long, long long> m; for (auto &p : v) { m[p] = 0; } long long i = 0; for (auto &p : m) { p.second = i; i++; } for (long long i = 0; i < n; i++) { w.at(i) = m[v.at(i)]; } v = w; return; } //配列のi番目の要素がj番目に小さいとき、j番目の数がiであるベクトルを返す関数 //配列の要素が全て異なるときにしか正常に動作しない //配列の要素に同じものが含まれても見かけ上動作はするが意味のない値を戻し、 //エラーも起きないので注意 //検証済 //{2,4,1,6,0,3,8,9,5}を //{4,2,0,5,1,8,3,6,7}にして返す //"rank"という名前にするとSTLの関数(配列の次元を返す関数)になるので注意 void ranking(vector<long long> &v) { long long n = v.size(); map<long long, long long> m; long long i; for (i = 0; i < n; i++) { m[v.at(i)] = i; } vector<long long> w(n); i = 0; for (auto &p : m) { v.at(i) = p.second; i++; } return; } //部分削除(未検証) //ベクトルのi番目(i=0,1,2,...,n-1)の要素を削除し、 //以降の要素を全て前に1ずらして参照返し //ベクトル長は1小さくなって返る // i>n-1の時は変化しない void erase(vector<long long> &v, long long i) { long long n = v.size(); if (i > n - 1) return; for (long long j = i; j < n - 1; j++) { v.at(j) = v.at(j + 1); } v.pop_back(); return; } //重複削除(未完成) //引数ベクトルに同一要素が複数あるとき、先頭を残し他は削除 //参照返し //ベクトル長も変化する // O(logn)くらい void unique(vector<long long> &v) { long long n = v.size(); set<long long> s; long long i = 0; while (i < n) { if (s.count(v.at(i))) { erase(v, i); n--; } else { s.insert(v.at(i)); i++; } } return; } //ベクトルの出力(検証済) // debug用にvectorの中身を出力する void printv(vector<long long> v) { cout << "{ "; for (auto &p : v) { cout << p << ","; } cout << "}" << endl; } // 10進法でn桁の整数xに対して、大きい方の位から、その位の1桁の数字を //収納した長さnのベクトルを返す // 0に対しては{0}を返す //検証済み vector<ll> keta(ll x) { if (x == 0) return {0}; ll n = log10(x) + 1; // xの桁数 vll w(n, 0); for (ll i = 0; i < n; i++) { ll p; p = x % 10; x = x / 10; w[n - 1 - i] = p; } return w; } // 20200415 // a^n mod を計算する long long modpow(long long a, long long n, long long mod) { long long res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } // a^{-1} mod を計算する // modとaが互いに素のときのみ有効(数学的に逆元が一意に定まるのがそのときのみ) long long modinv(long long a, long long mod) { return modpow(a, mod - 2, mod); } //整数n個の入力を受け取ってベクトルに突っ込んで返す //チェック済み vector<long long> inputv(long long n) { vector<long long> v(n); for (long long i = 0; i < n; i++) { cin >> v[i]; } return v; } vector<long long> yakusuu(long long n) // nの約数を列挙 { vector<long long> ret; for (long long i = 1; i <= sqrt(n); ++i) { if (n % i == 0) { ret.push_back(i); if (i * i != n) { ret.push_back(n / i); } } } sort(ret.begin(), ret.end()); return ret; } map<long long, long long> soinsuu(long long n) { map<long long, long long> m; long long p = sqrt(n); while (n % 2 == 0) { n /= 2; if (m.count(2)) { m[2]++; } else { m[2] = 1; } } for (long long i = 3; i * i <= n; i += 2) { while (n % i == 0) { n /= i; if (m.count(i)) { m[i]++; } else { m[i] = 1; } } } if (n != 1) m[n] = 1; return m; } //スタートが(i,j)の迷路の全ての地点までの距離を幅優先探索で解く //スタートから何マス離れているか(辿り着けない場合は-1)を入れたベクトルを返す //壁からスタートしても正常に動作するので注意(この関数の外で処理が必要) //検証済み 一応O(地図の広さ)くらい vector<vector<long long>> maze(ll i, ll j, vector<string> &s) { ll h = s.size(); ll w = s[0].size(); queue<vector<long long>> q; vector<vector<long long>> dis(h, vll(w, -1)); q.push({i, j}); dis[i][j] = 0; while (!q.empty()) { auto v = q.front(); q.pop(); if (v[0] > 0 && s[v[0] - 1][v[1]] == '.' && dis[v[0] - 1][v[1]] == -1) { dis[v[0] - 1][v[1]] = dis[v[0]][v[1]] + 1; q.push({v[0] - 1, v[1]}); } if (v[1] > 0 && s[v[0]][v[1] - 1] == '.' && dis[v[0]][v[1] - 1] == -1) { dis[v[0]][v[1] - 1] = dis[v[0]][v[1]] + 1; q.push({v[0], v[1] - 1}); } if (v[0] < h - 1 && s[v[0] + 1][v[1]] == '.' && dis[v[0] + 1][v[1]] == -1) { dis[v[0] + 1][v[1]] = dis[v[0]][v[1]] + 1; q.push({v[0] + 1, v[1]}); } if (v[1] < w - 1 && s[v[0]][v[1] + 1] == '.' && dis[v[0]][v[1] + 1] == -1) { dis[v[0]][v[1] + 1] = dis[v[0]][v[1]] + 1; q.push({v[0], v[1] + 1}); } } return dis; //スタートから何マス離れているか(辿り着けない場合は-1) } //エラトステネスのふるいによりn以下の素数を全てベクトルに入れて返す // vector<long long> eratos(long long n){ // } //二項係数の剰余を求める //引数は剰余の形ではなくもとの数そのものである //未検証(検証サンプルがない) long long modC(long long n, long long k, long long mod) { if (n < k) return 0; long long p = 1, q = 1; for (long long i = 0; i < k; i++) { p = p * (n - i) % mod; q = q * (i + 1) % mod; } return p * modinv(q, mod) % mod; } // 20200418 // 整数のとき限定の普通のPOW関数 //標準機能のpow(a,n)は整数だとバグるのでこちらを使う long long POW(long long a, long long n) { long long res = 1; while (n > 0) { if (n & 1) res = res * a; a = a * a; n >>= 1; } return res; } // 20200423 //エラトステネスのふるいによりn以下の素数を全てベクトルに入れて返す vector<long long> eratos(long long n) { if (n < 2) return {}; vll v(n - 1); rep(i, n - 1) { v[i] = i + 2; // 2からnまで } ll i = 0; while (i < n - 1) { ll p = v[i]; for (ll j = i + 1; j < n - 1; j++) { if (v[j] % p == 0) { v.erase(v.begin() + j); n--; } } i++; } v.resize(n - 1); return v; } // n以下の素数を全て詰めたset set<long long> eraset(long long n) { set<long long> s; vll v = eratos(n); for (auto &t : v) { s.insert(t); } return s; } // 20200428 //(x1,y1),(x2,y2)を通る直線をax+by+c=0としたとき //{a,b,c}を返す vll line(ll x1, ll y1, ll x2, ll y2) { vector<ll> v(3); v[0] = y1 - y2; v[1] = x2 - x1; v[2] = -x1 * (y1 - y2) + y1 * (x1 - x2); return v; } //(x,y)とv[0]x+v[1]y+v[2]=0との距離 double dis(vll v, ll x, ll y) { double s = sqrt(v[0] * v[0] + v[1] * v[1]); return (double)abs(v[0] * x + v[1] * y + v[2]) / s; } // 20200502 void maxin(ll &a, ll b) { a = max(a, b); return; } void minin(ll &a, ll b) { a = min(a, b); return; } // 20200506 map<long long, long long> countv(vll v) { map<long long, long long> m; for (auto &g : v) { if (m.count(g)) m[g]++; else m[g] = 1; } return m; } // nCk modを求める const ll MAX = 510000; const ll MOD = 1000000007; long long fac[MAX], finv[MAX], inv[MAX]; // テーブルを作る前処理 void cominit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (ll 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; } } // 二項係数計算 long long commod(ll n, ll k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } //順列計算 long long pmod(ll n, ll k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * finv[n - k] % MOD; } /* next combination */ //次の組み合わせをbitで返す //全探索のloopに使える long long next_combination(long long sub) { long long x = sub & -sub, y = sub + x; return (((sub & ~y) / x) >> 1) | y; } ////////////////////////////////////////// struct UF { //サイズが測れるUF vector<long long> par, size; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2 // sizeはiを根とする木のサイズ UF(long long N) : par(N), size(N) { //最初は全てが根であるとして初期化 for (long long i = 0; i < N; i++) { par[i] = i; size[i] = 1; } } long long root( long long x) { // データxが属する木の根を再帰で得る:root(x) = {xの木の根} if (par[x] == x) return x; return par[x] = root(par[x]); } void unite(long long x, long long y) { // xとyの木を併合 long long rx = root(x); // xの根をrx long long ry = root(y); // yの根をry if (rx == ry) return; // xとyの根が同じ(=同じ木にある)時はそのまま par[rx] = ry; // xとyの根が同じでない(=同じ木にない)時:xの根rxをyの根ryにつける size[ry] += size[rx]; size[rx] = 0; //サイズの処理 根じゃなくなったらサイズは0になる } bool same(long long x, long long y) { // 2つのデータx, yが属する木が同じならtrueを返す long long rx = root(x); long long ry = root(y); return rx == ry; } }; // auto mod int // https://youtu.be/L8grWxBlIZ4?t=9858 // https://youtu.be/ERZuLAxZffQ?t=4807 : optimize // https://youtu.be/8uowVvQ_-Mo?t=1329 : division const int mod = 1000000007; // int mod=17; // const int mod = 998244353; struct mint { ll x; // typedef long long ll; mint(ll x = 0) : x((x % mod + mod) % mod) {} mint operator-() const { return mint(-x); } mint &operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint &operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint &operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint a) const { return mint(*this) += a; } mint operator-(const mint a) const { return mint(*this) -= a; } mint operator*(const mint a) const { return mint(*this) *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod - 2); } mint &operator/=(const mint a) { return *this *= a.inv(); } mint operator/(const mint a) const { return mint(*this) /= a; } }; istream &operator>>(istream &is, const mint &a) { return is >> a.x; } ostream &operator<<(ostream &os, const mint &a) { return os << a.x; } void debug(ll &a) { cout << a << endl; } void debug(vll &a) { cout << "debug vector" << endl; cout << "{ "; for (auto t : a) { cout << t << ","; } cout << " }" << endl; cout << "debug finished" << endl; } void debug(set<long long> &a) { cout << "debug set" << endl; for (auto t : a) { cout << t << endl; } cout << "debug finished" << endl; } void debug(map<long long, long long> a) { cout << "debug map" << endl; for (auto t : a) { cout << t.first << " " << t.second << endl; } cout << "debug finished" << endl; } void debug(queue<long long> a) { cout << "debug queue" << endl; while (!a.empty()) { ll t = a.front(); a.pop(); cout << t << endl; } cout << "debug finished" << endl; } // 20200604 struct STmax { //最大値を測るセグ木 ll size; // treeの葉の数=m*2-1 ll m; // tree最下段の数 vector<long long> seg; STmax(long long n) : size(n), m(n), seg(0) { m = 1; while (m < n) { m *= 2; } size = m * 2 - 1; rep(i, size) { seg.push_back(-99999999977); } } //ここまで共通 // minの場合はpush_backの値をdekaiにする? void update(ll i, ll k) { // i番目をkに更新 ll v = i + m - 1; seg[v] = k; while (v > 0) { v = (v - 1) / 2; seg[v] = max(seg[v * 2 + 1], seg[v * 2 + 2]); } } void add(ll i, ll k) { update(i, seg[m - 1 + i] + k); } ll query(ll a, ll b, ll k, ll l, ll r) { //区間[a,b)での最大値を求める if (r <= a || b <= l) return -99999999977; if (a <= l && r <= b) return seg[k]; // cout << "#" << a << " " << b << " " << k << " " << l << " " << r << endl; ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2); ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r); return max(vl, vr); } ll largest(ll a, ll b) { if (a >= b) return -99999999977; return query(a, b, 0, 0, m); } }; struct STmin { //最小値を測るセグ木 ll size; // treeの葉の数=m*2-1 ll m; // tree最下段の数 vector<long long> seg; STmin(long long n) : size(n), m(n), seg(0) { m = 1; while (m < n) { m *= 2; } size = m * 2 - 1; rep(i, size) { seg.push_back(99999999977); } } //ここまで共通 // minの場合はpush_backの値をdekaiにする? void update(ll i, ll k) { // i番目をkに更新 ll v = i + m - 1; seg[v] = k; while (v > 0) { v = (v - 1) / 2; seg[v] = min(seg[v * 2 + 1], seg[v * 2 + 2]); } } ll query(ll a, ll b, ll k, ll l, ll r) { //区間[a,b)での最大値を求める if (r <= a || b <= l) return 99999999977; if (a <= l && r <= b) return seg[k]; // cout << "#" << a << " " << b << " " << k << " " << l << " " << r << endl; ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2); ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r); return min(vl, vr); } ll smallest(ll a, ll b) { if (a >= b) return 99999999977; return query(a, b, 0, 0, m); } }; struct STsum { //区間の合計値を測るセグ木 ll size; // treeの葉の数=m*2-1 ll m; // tree最下段の数 vector<long long> seg; STsum(long long n) : size(n), m(n), seg(0) { m = 1; while (m < n) { m *= 2; } size = m * 2 - 1; rep(i, size) { seg.push_back(0); } } //ここまで共通 // minの場合はpush_backの値をdekaiにする void update(ll i, ll k) { // i番目をkに更新 ll v = i + m - 1; seg[v] = k; while (v > 0) { v = (v - 1) / 2; seg[v] = seg[v * 2 + 1] + seg[v * 2 + 2]; } } void add(ll i, ll k) { update(i, seg[m - 1 + i] + k); } ll query(ll a, ll b, ll k, ll l, ll r) { //区間[a,b)での最大値を求める if (r <= a || b <= l) return 0; if (a <= l && r <= b) return seg[k]; // cout << "#" << a << " " << b << " " << k << " " << l << " " << r << endl; ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2); ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r); return vl + vr; } ll sum(ll a, ll b) { if (a >= b) return 0; return query(a, b, 0, 0, m); } }; ////////////////////////////////////////////// // ll const mod=1e9+7; ll const dekai = 99999999977; // 1e11-23.素数. ll dx[4] = {-1, 0, 1, 0}; ll dy[4] = {0, -1, 0, 1}; ll ddx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}; ll ddy[8] = {-1, 0, 1, -1, 1, -1, 0, 1}; // cout<<fixed<<setprecision(10); #define ednl endl #define endk endl // int main() { // // 再帰関数の定義 // function<int(int)> sum = [&](int n) { // if(n == 0) { // return 0; // } // int s = sum(n - 1); // return s + n; // }; // cout << sum(3) << endl; // } ////////////////////////////////////////////////// int main() { ll n; cin >> n; vpll ans(0); if (n % 2) { for (ll i = 1; i < n + 1; i++) { for (ll j = 1; j < n + 1; j++) { if (i >= j || i + j == n) continue; ans.push_back({i, j}); } } } else { for (ll i = 1; i < n + 1; i++) { for (ll j = i + 1; j < n + 1; j++) { if (i + j == n + 1) continue; ans.push_back({i, j}); } } } cout << ans.size(); for (auto t : ans) cout << t.first << " " << t.second << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (long long i = 0; i < n; i++) #define Rep(i, m, n) for (long long i = m; i < n; i++) #define REP(i, m, n, p) for (long long i = m; i < n; i += p) #define all(v) v.begin(), v.end() #define pq priority_queue #define bcnt(n) __builtin_popcountll(n) using vi = vector<int>; // intの1次元の型に vi という別名をつける using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける using vvvi = vector<vvi>; using ll = long long; // long longをllだけにした using vll = vector<ll>; using vvll = vector<vll>; using vvvll = vector<vvll>; using vb = vector<bool>; using vvb = vector<vb>; using mii = map<int, int>; using pqll = priority_queue<long long>; using pqllg = priority_queue<long long, vector<long long>, greater<long long>>; using mll = map<long long, long long>; using pll = pair<long long, long long>; using sll = set<long long>; using vpll = vector<pair<long long, long long>>; using mlv = map<long long, vector<long long>>; long long divup(long long a, long long b); long long kaijou(long long i); long long P(long long n, long long k); long long C(long long n, long long k); long long GCD(long long a, long long b); long long LCM(long long a, long long b); bool prime(long long N); double distance(vector<long long> p, vector<long long> q, long long n); void press(vector<long long> &v); void ranking(vector<long long> &v); void erase(vector<long long> &v, long long i); void unique(vector<long long> &v); void printv(vector<long long> v); vector<ll> keta(ll x); long long modpow(long long a, long long n, long long mod); long long modinv(long long a, long long mod); // 20200416 vector<long long> inputv(long long n); // 20200417 vector<long long> yakusuu(int n); map<long long, long long> soinsuu(long long n); vector<vector<long long>> maze(long long i, long long j, vector<string> &s); // 20200423 vector<long long> eratos(long long n); set<long long> eraset(long long n); ////////////////////////////////////////////////////// //端数繰りあがり割り算(検証済) // a÷bの端数繰り上げ // b!=0のデバグはしてないので分母に0を入れないように //負数対応 long long divup(long long a, long long b) { long long x = abs(a); long long y = abs(b); long long z = (x + y - 1) / y; if ((a < 0 && b > 0) || (a > 0 && b < 0)) return -z; else if (a == 0) return 0; else return z; } //階乗 //検証済み long long kaijou(long long i) { if (i == 0) return 1; long long j = 1; for (long long k = 1; k <= i; k++) { j *= k; } return j; } //順列nPk(完成) // n個の異なる要素から、取り出す順序を区別してk個取り出す場合の数 // n<kなら0を返す //敢えて負数時のデバグはしてない long long P(long long n, long long k) { if (n < k) return 0; long long y = 1; for (long long i = 0; i < k; i++) { y *= (n - i); } return y; } //組み合わせnCk(検証済み) // P,kaijouと併用 long long C(long long n, long long k) { if (n < k) return 0; return P(n, k) / kaijou(k); } // nHk //区別しないn個の要素を、区別するk個のグループに分ける // 0個のグループがあっ //て良い // C必須 //最大公約数GCD,最小公倍数LCM // LCMを使うときはGCDをセットで //検証済み long long GCD(long long a, long long b) { if (a < b) swap(a, b); long long d = a % b; if (d == 0) { return b; } return GCD(b, d); } long long LCM(long long a, long long b) { return (a / GCD(a, b)) * b; } //素数判定 //素数ならばtrue、素数以外の整数にはfalse //負数は全てfalse //検証済み bool prime(long long N) { if (N == 1) { return false; } if (N < 0) return false; long long p = sqrt(N); for (long long i = 2; i <= p; i++) { if (N % i == 0) { return false; } } return true; } //ユークリッド距離 //検証済み //位置ベクトル1,位置ベクトル2,ベクトルの次元(2または3が一般的) double distance(vector<long long> p, vector<long long> q, long long n) { double x = 0; for (long long i = 0; i < n; i++) { x += pow((p.at(i) - q.at(i)), 2); } return sqrt(x); } //配列圧縮(検証済) //{1,36,1,3,8,-2,-92}を //{2, 5,2,3,4, 1, 0}にする void press(vector<long long> &v) { long long n = v.size(); vector<long long> w(n); map<long long, long long> m; for (auto &p : v) { m[p] = 0; } long long i = 0; for (auto &p : m) { p.second = i; i++; } for (long long i = 0; i < n; i++) { w.at(i) = m[v.at(i)]; } v = w; return; } //配列のi番目の要素がj番目に小さいとき、j番目の数がiであるベクトルを返す関数 //配列の要素が全て異なるときにしか正常に動作しない //配列の要素に同じものが含まれても見かけ上動作はするが意味のない値を戻し、 //エラーも起きないので注意 //検証済 //{2,4,1,6,0,3,8,9,5}を //{4,2,0,5,1,8,3,6,7}にして返す //"rank"という名前にするとSTLの関数(配列の次元を返す関数)になるので注意 void ranking(vector<long long> &v) { long long n = v.size(); map<long long, long long> m; long long i; for (i = 0; i < n; i++) { m[v.at(i)] = i; } vector<long long> w(n); i = 0; for (auto &p : m) { v.at(i) = p.second; i++; } return; } //部分削除(未検証) //ベクトルのi番目(i=0,1,2,...,n-1)の要素を削除し、 //以降の要素を全て前に1ずらして参照返し //ベクトル長は1小さくなって返る // i>n-1の時は変化しない void erase(vector<long long> &v, long long i) { long long n = v.size(); if (i > n - 1) return; for (long long j = i; j < n - 1; j++) { v.at(j) = v.at(j + 1); } v.pop_back(); return; } //重複削除(未完成) //引数ベクトルに同一要素が複数あるとき、先頭を残し他は削除 //参照返し //ベクトル長も変化する // O(logn)くらい void unique(vector<long long> &v) { long long n = v.size(); set<long long> s; long long i = 0; while (i < n) { if (s.count(v.at(i))) { erase(v, i); n--; } else { s.insert(v.at(i)); i++; } } return; } //ベクトルの出力(検証済) // debug用にvectorの中身を出力する void printv(vector<long long> v) { cout << "{ "; for (auto &p : v) { cout << p << ","; } cout << "}" << endl; } // 10進法でn桁の整数xに対して、大きい方の位から、その位の1桁の数字を //収納した長さnのベクトルを返す // 0に対しては{0}を返す //検証済み vector<ll> keta(ll x) { if (x == 0) return {0}; ll n = log10(x) + 1; // xの桁数 vll w(n, 0); for (ll i = 0; i < n; i++) { ll p; p = x % 10; x = x / 10; w[n - 1 - i] = p; } return w; } // 20200415 // a^n mod を計算する long long modpow(long long a, long long n, long long mod) { long long res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } // a^{-1} mod を計算する // modとaが互いに素のときのみ有効(数学的に逆元が一意に定まるのがそのときのみ) long long modinv(long long a, long long mod) { return modpow(a, mod - 2, mod); } //整数n個の入力を受け取ってベクトルに突っ込んで返す //チェック済み vector<long long> inputv(long long n) { vector<long long> v(n); for (long long i = 0; i < n; i++) { cin >> v[i]; } return v; } vector<long long> yakusuu(long long n) // nの約数を列挙 { vector<long long> ret; for (long long i = 1; i <= sqrt(n); ++i) { if (n % i == 0) { ret.push_back(i); if (i * i != n) { ret.push_back(n / i); } } } sort(ret.begin(), ret.end()); return ret; } map<long long, long long> soinsuu(long long n) { map<long long, long long> m; long long p = sqrt(n); while (n % 2 == 0) { n /= 2; if (m.count(2)) { m[2]++; } else { m[2] = 1; } } for (long long i = 3; i * i <= n; i += 2) { while (n % i == 0) { n /= i; if (m.count(i)) { m[i]++; } else { m[i] = 1; } } } if (n != 1) m[n] = 1; return m; } //スタートが(i,j)の迷路の全ての地点までの距離を幅優先探索で解く //スタートから何マス離れているか(辿り着けない場合は-1)を入れたベクトルを返す //壁からスタートしても正常に動作するので注意(この関数の外で処理が必要) //検証済み 一応O(地図の広さ)くらい vector<vector<long long>> maze(ll i, ll j, vector<string> &s) { ll h = s.size(); ll w = s[0].size(); queue<vector<long long>> q; vector<vector<long long>> dis(h, vll(w, -1)); q.push({i, j}); dis[i][j] = 0; while (!q.empty()) { auto v = q.front(); q.pop(); if (v[0] > 0 && s[v[0] - 1][v[1]] == '.' && dis[v[0] - 1][v[1]] == -1) { dis[v[0] - 1][v[1]] = dis[v[0]][v[1]] + 1; q.push({v[0] - 1, v[1]}); } if (v[1] > 0 && s[v[0]][v[1] - 1] == '.' && dis[v[0]][v[1] - 1] == -1) { dis[v[0]][v[1] - 1] = dis[v[0]][v[1]] + 1; q.push({v[0], v[1] - 1}); } if (v[0] < h - 1 && s[v[0] + 1][v[1]] == '.' && dis[v[0] + 1][v[1]] == -1) { dis[v[0] + 1][v[1]] = dis[v[0]][v[1]] + 1; q.push({v[0] + 1, v[1]}); } if (v[1] < w - 1 && s[v[0]][v[1] + 1] == '.' && dis[v[0]][v[1] + 1] == -1) { dis[v[0]][v[1] + 1] = dis[v[0]][v[1]] + 1; q.push({v[0], v[1] + 1}); } } return dis; //スタートから何マス離れているか(辿り着けない場合は-1) } //エラトステネスのふるいによりn以下の素数を全てベクトルに入れて返す // vector<long long> eratos(long long n){ // } //二項係数の剰余を求める //引数は剰余の形ではなくもとの数そのものである //未検証(検証サンプルがない) long long modC(long long n, long long k, long long mod) { if (n < k) return 0; long long p = 1, q = 1; for (long long i = 0; i < k; i++) { p = p * (n - i) % mod; q = q * (i + 1) % mod; } return p * modinv(q, mod) % mod; } // 20200418 // 整数のとき限定の普通のPOW関数 //標準機能のpow(a,n)は整数だとバグるのでこちらを使う long long POW(long long a, long long n) { long long res = 1; while (n > 0) { if (n & 1) res = res * a; a = a * a; n >>= 1; } return res; } // 20200423 //エラトステネスのふるいによりn以下の素数を全てベクトルに入れて返す vector<long long> eratos(long long n) { if (n < 2) return {}; vll v(n - 1); rep(i, n - 1) { v[i] = i + 2; // 2からnまで } ll i = 0; while (i < n - 1) { ll p = v[i]; for (ll j = i + 1; j < n - 1; j++) { if (v[j] % p == 0) { v.erase(v.begin() + j); n--; } } i++; } v.resize(n - 1); return v; } // n以下の素数を全て詰めたset set<long long> eraset(long long n) { set<long long> s; vll v = eratos(n); for (auto &t : v) { s.insert(t); } return s; } // 20200428 //(x1,y1),(x2,y2)を通る直線をax+by+c=0としたとき //{a,b,c}を返す vll line(ll x1, ll y1, ll x2, ll y2) { vector<ll> v(3); v[0] = y1 - y2; v[1] = x2 - x1; v[2] = -x1 * (y1 - y2) + y1 * (x1 - x2); return v; } //(x,y)とv[0]x+v[1]y+v[2]=0との距離 double dis(vll v, ll x, ll y) { double s = sqrt(v[0] * v[0] + v[1] * v[1]); return (double)abs(v[0] * x + v[1] * y + v[2]) / s; } // 20200502 void maxin(ll &a, ll b) { a = max(a, b); return; } void minin(ll &a, ll b) { a = min(a, b); return; } // 20200506 map<long long, long long> countv(vll v) { map<long long, long long> m; for (auto &g : v) { if (m.count(g)) m[g]++; else m[g] = 1; } return m; } // nCk modを求める const ll MAX = 510000; const ll MOD = 1000000007; long long fac[MAX], finv[MAX], inv[MAX]; // テーブルを作る前処理 void cominit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (ll 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; } } // 二項係数計算 long long commod(ll n, ll k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } //順列計算 long long pmod(ll n, ll k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * finv[n - k] % MOD; } /* next combination */ //次の組み合わせをbitで返す //全探索のloopに使える long long next_combination(long long sub) { long long x = sub & -sub, y = sub + x; return (((sub & ~y) / x) >> 1) | y; } ////////////////////////////////////////// struct UF { //サイズが測れるUF vector<long long> par, size; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2 // sizeはiを根とする木のサイズ UF(long long N) : par(N), size(N) { //最初は全てが根であるとして初期化 for (long long i = 0; i < N; i++) { par[i] = i; size[i] = 1; } } long long root( long long x) { // データxが属する木の根を再帰で得る:root(x) = {xの木の根} if (par[x] == x) return x; return par[x] = root(par[x]); } void unite(long long x, long long y) { // xとyの木を併合 long long rx = root(x); // xの根をrx long long ry = root(y); // yの根をry if (rx == ry) return; // xとyの根が同じ(=同じ木にある)時はそのまま par[rx] = ry; // xとyの根が同じでない(=同じ木にない)時:xの根rxをyの根ryにつける size[ry] += size[rx]; size[rx] = 0; //サイズの処理 根じゃなくなったらサイズは0になる } bool same(long long x, long long y) { // 2つのデータx, yが属する木が同じならtrueを返す long long rx = root(x); long long ry = root(y); return rx == ry; } }; // auto mod int // https://youtu.be/L8grWxBlIZ4?t=9858 // https://youtu.be/ERZuLAxZffQ?t=4807 : optimize // https://youtu.be/8uowVvQ_-Mo?t=1329 : division const int mod = 1000000007; // int mod=17; // const int mod = 998244353; struct mint { ll x; // typedef long long ll; mint(ll x = 0) : x((x % mod + mod) % mod) {} mint operator-() const { return mint(-x); } mint &operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint &operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint &operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint a) const { return mint(*this) += a; } mint operator-(const mint a) const { return mint(*this) -= a; } mint operator*(const mint a) const { return mint(*this) *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod - 2); } mint &operator/=(const mint a) { return *this *= a.inv(); } mint operator/(const mint a) const { return mint(*this) /= a; } }; istream &operator>>(istream &is, const mint &a) { return is >> a.x; } ostream &operator<<(ostream &os, const mint &a) { return os << a.x; } void debug(ll &a) { cout << a << endl; } void debug(vll &a) { cout << "debug vector" << endl; cout << "{ "; for (auto t : a) { cout << t << ","; } cout << " }" << endl; cout << "debug finished" << endl; } void debug(set<long long> &a) { cout << "debug set" << endl; for (auto t : a) { cout << t << endl; } cout << "debug finished" << endl; } void debug(map<long long, long long> a) { cout << "debug map" << endl; for (auto t : a) { cout << t.first << " " << t.second << endl; } cout << "debug finished" << endl; } void debug(queue<long long> a) { cout << "debug queue" << endl; while (!a.empty()) { ll t = a.front(); a.pop(); cout << t << endl; } cout << "debug finished" << endl; } // 20200604 struct STmax { //最大値を測るセグ木 ll size; // treeの葉の数=m*2-1 ll m; // tree最下段の数 vector<long long> seg; STmax(long long n) : size(n), m(n), seg(0) { m = 1; while (m < n) { m *= 2; } size = m * 2 - 1; rep(i, size) { seg.push_back(-99999999977); } } //ここまで共通 // minの場合はpush_backの値をdekaiにする? void update(ll i, ll k) { // i番目をkに更新 ll v = i + m - 1; seg[v] = k; while (v > 0) { v = (v - 1) / 2; seg[v] = max(seg[v * 2 + 1], seg[v * 2 + 2]); } } void add(ll i, ll k) { update(i, seg[m - 1 + i] + k); } ll query(ll a, ll b, ll k, ll l, ll r) { //区間[a,b)での最大値を求める if (r <= a || b <= l) return -99999999977; if (a <= l && r <= b) return seg[k]; // cout << "#" << a << " " << b << " " << k << " " << l << " " << r << endl; ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2); ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r); return max(vl, vr); } ll largest(ll a, ll b) { if (a >= b) return -99999999977; return query(a, b, 0, 0, m); } }; struct STmin { //最小値を測るセグ木 ll size; // treeの葉の数=m*2-1 ll m; // tree最下段の数 vector<long long> seg; STmin(long long n) : size(n), m(n), seg(0) { m = 1; while (m < n) { m *= 2; } size = m * 2 - 1; rep(i, size) { seg.push_back(99999999977); } } //ここまで共通 // minの場合はpush_backの値をdekaiにする? void update(ll i, ll k) { // i番目をkに更新 ll v = i + m - 1; seg[v] = k; while (v > 0) { v = (v - 1) / 2; seg[v] = min(seg[v * 2 + 1], seg[v * 2 + 2]); } } ll query(ll a, ll b, ll k, ll l, ll r) { //区間[a,b)での最大値を求める if (r <= a || b <= l) return 99999999977; if (a <= l && r <= b) return seg[k]; // cout << "#" << a << " " << b << " " << k << " " << l << " " << r << endl; ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2); ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r); return min(vl, vr); } ll smallest(ll a, ll b) { if (a >= b) return 99999999977; return query(a, b, 0, 0, m); } }; struct STsum { //区間の合計値を測るセグ木 ll size; // treeの葉の数=m*2-1 ll m; // tree最下段の数 vector<long long> seg; STsum(long long n) : size(n), m(n), seg(0) { m = 1; while (m < n) { m *= 2; } size = m * 2 - 1; rep(i, size) { seg.push_back(0); } } //ここまで共通 // minの場合はpush_backの値をdekaiにする void update(ll i, ll k) { // i番目をkに更新 ll v = i + m - 1; seg[v] = k; while (v > 0) { v = (v - 1) / 2; seg[v] = seg[v * 2 + 1] + seg[v * 2 + 2]; } } void add(ll i, ll k) { update(i, seg[m - 1 + i] + k); } ll query(ll a, ll b, ll k, ll l, ll r) { //区間[a,b)での最大値を求める if (r <= a || b <= l) return 0; if (a <= l && r <= b) return seg[k]; // cout << "#" << a << " " << b << " " << k << " " << l << " " << r << endl; ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2); ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r); return vl + vr; } ll sum(ll a, ll b) { if (a >= b) return 0; return query(a, b, 0, 0, m); } }; ////////////////////////////////////////////// // ll const mod=1e9+7; ll const dekai = 99999999977; // 1e11-23.素数. ll dx[4] = {-1, 0, 1, 0}; ll dy[4] = {0, -1, 0, 1}; ll ddx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}; ll ddy[8] = {-1, 0, 1, -1, 1, -1, 0, 1}; // cout<<fixed<<setprecision(10); #define ednl endl #define endk endl // int main() { // // 再帰関数の定義 // function<int(int)> sum = [&](int n) { // if(n == 0) { // return 0; // } // int s = sum(n - 1); // return s + n; // }; // cout << sum(3) << endl; // } ////////////////////////////////////////////////// int main() { ll n; cin >> n; vpll ans(0); if (n % 2) { for (ll i = 1; i < n + 1; i++) { for (ll j = 1; j < n + 1; j++) { if (i >= j || i + j == n) continue; ans.push_back({i, j}); } } } else { for (ll i = 1; i < n + 1; i++) { for (ll j = i + 1; j < n + 1; j++) { if (i + j == n + 1) continue; ans.push_back({i, j}); } } } cout << ans.size() << endl; for (auto t : ans) cout << t.first << " " << t.second << endl; }
[ "io.output.newline.add" ]
904,429
904,430
u513211419
cpp
p03090
#include <bits/stdc++.h> #define fi first #define se second #define rep(i, n) for (int i = 0; i < (n); ++i) #define rrep(i, n) for (int i = 1; i <= (n); ++i) #define drep(i, n) for (int i = (n)-1; i >= 0; --i) #define srep(i, s, t) for (int i = s; i < t; ++i) #define rng(a) a.begin(), a.end() #define rrng(a) a.rbegin(), a.rend() #define maxs(x, y) (x = max(x, y)) #define mins(x, y) (x = min(x, y)) #define limit(x, l, r) max(l, min(x, r)) #define lims(x, l, r) (x = max(l, min(x, r))) #define isin(x, l, r) ((l) <= (x) && (x) < (r)) #define pb push_back #define eb emplace_back #define sz(x) (int)(x).size() #define pcnt __builtin_popcountll #define uni(x) x.erase(unique(rng(x)), x.end()) #define show(x) cout << #x << " = " << x << endl; #define print(x) cout << x << endl; #define PQ(T) priority_queue<T, v(T), greater<T>> #define bn(x) ((1 << x) - 1) #define dup(x, y) (((x) + (y)-1) / (y)) #define newline puts("") #define v(T) vector<T> #define vv(T) v(v(T)) using namespace std; typedef long long int ll; typedef unsigned uint; typedef unsigned long long ull; typedef pair<int, int> P; typedef tuple<int, int, int> T; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vl; typedef vector<P> vp; typedef vector<T> vt; int main() { int n; cin >> n; vp ans; int rem = n; if (n % 2 == 1) rem--; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (j <= i || j == rem) continue; ans.push_back(P(i, j)); } } cout << ans.size() << endl; for (auto it : ans) { cout << it.fi << " " << it.se << endl; } return 0; }
#include <bits/stdc++.h> #define fi first #define se second #define rep(i, n) for (int i = 0; i < (n); ++i) #define rrep(i, n) for (int i = 1; i <= (n); ++i) #define drep(i, n) for (int i = (n)-1; i >= 0; --i) #define srep(i, s, t) for (int i = s; i < t; ++i) #define rng(a) a.begin(), a.end() #define rrng(a) a.rbegin(), a.rend() #define maxs(x, y) (x = max(x, y)) #define mins(x, y) (x = min(x, y)) #define limit(x, l, r) max(l, min(x, r)) #define lims(x, l, r) (x = max(l, min(x, r))) #define isin(x, l, r) ((l) <= (x) && (x) < (r)) #define pb push_back #define eb emplace_back #define sz(x) (int)(x).size() #define pcnt __builtin_popcountll #define uni(x) x.erase(unique(rng(x)), x.end()) #define show(x) cout << #x << " = " << x << endl; #define print(x) cout << x << endl; #define PQ(T) priority_queue<T, v(T), greater<T>> #define bn(x) ((1 << x) - 1) #define dup(x, y) (((x) + (y)-1) / (y)) #define newline puts("") #define v(T) vector<T> #define vv(T) v(v(T)) using namespace std; typedef long long int ll; typedef unsigned uint; typedef unsigned long long ull; typedef pair<int, int> P; typedef tuple<int, int, int> T; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vl; typedef vector<P> vp; typedef vector<T> vt; int main() { int n; cin >> n; vp ans; int rem = n; if (n % 2 == 1) rem--; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (j <= i || j == rem) continue; ans.push_back(P(i, j)); } rem--; } cout << ans.size() << endl; for (auto it : ans) { cout << it.fi << " " << it.se << endl; } return 0; }
[ "expression.unary.arithmetic.add" ]
904,431
904,432
u814715203
cpp
p03090
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; if (N % 2 == 0) { cout << (N * (N - 2)) / 2 << endl; for (int i = 1; i <= N - 1; i++) { for (int j = i + 1; j <= N; j++) { if (j != N + 1 - i) { cout << i << " " << j << endl; } } } } else { cout << ((N - 1) * (N - 1)) / 2 << endl; for (int i = 1; i <= N - 1; i++) { for (int j = 1; j <= N; j++) { if (j != N - i) { cout << i << " " << j << endl; } } } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; if (N % 2 == 0) { cout << (N * (N - 2)) / 2 << endl; for (int i = 1; i <= N - 1; i++) { for (int j = i + 1; j <= N; j++) { if (j != N + 1 - i) { cout << i << " " << j << endl; } } } } else { cout << ((N - 1) * (N - 1)) / 2 << endl; for (int i = 1; i <= N - 1; i++) { for (int j = i + 1; j <= N; j++) { if (j != N - i) { cout << i << " " << j << endl; } } } } return 0; }
[ "control_flow.loop.for.initializer.change" ]
904,439
904,440
u101018317
cpp
p03090
#include <algorithm> #include <bits/stdc++.h> #include <cmath> #include <cstdlib> using namespace std; using ll = long long; using P = pair<int, int>; using Graph = vector<vector<int>>; #define rep(i, n) for (ll i = 0; i < (n); ++i) #define rep2(i, n, m) for (ll i = n; i <= m; i++) #define rep3(i, n, m) for (ll i = n; i >= m; i--) #define pb push_back #define eb emplace_back #define ppb pop_back const ll INF = 1e18; inline void chmax(ll &a, ll b) { a = max(a, b); } inline void chmin(ll &a, ll b) { a = min(a, b); } int main() { int n; cin >> n; if (n % 2 == 1) { int m = (n - 1) * (n - 1) / 2; cout << m << endl; rep2(i, 1, n - 1) { rep2(j, i + 1, n) { if (i + j != n) cout << i << " " << j << endl; } } } else { int m = (n - 2) * (n - 1) / 2; cout << m << endl; rep2(i, 1, n - 1) { rep2(j, i + 1, n) { if (i + j != n + 1) cout << i << " " << j << endl; } } } return 0; }
#include <algorithm> #include <bits/stdc++.h> #include <cmath> #include <cstdlib> using namespace std; using ll = long long; using P = pair<int, int>; using Graph = vector<vector<int>>; #define rep(i, n) for (ll i = 0; i < (n); ++i) #define rep2(i, n, m) for (ll i = n; i <= m; i++) #define rep3(i, n, m) for (ll i = n; i >= m; i--) #define pb push_back #define eb emplace_back #define ppb pop_back const ll INF = 1e18; inline void chmax(ll &a, ll b) { a = max(a, b); } inline void chmin(ll &a, ll b) { a = min(a, b); } int main() { int n; cin >> n; if (n % 2 == 1) { int m = (n - 1) * (n - 1) / 2; cout << m << endl; rep2(i, 1, n - 1) { rep2(j, i + 1, n) { if (i + j != n) cout << i << " " << j << endl; } } } else { int m = (n - 2) * (n) / 2; cout << m << endl; rep2(i, 1, n - 1) { rep2(j, i + 1, n) { if (i + j != n + 1) cout << i << " " << j << endl; } } } return 0; }
[ "expression.operation.binary.remove" ]
904,445
904,446
u449123607
cpp
p03090
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define pi 3.141592653589793238 #define int long long using namespace __gnu_pbds; using namespace std; template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0); #ifndef ONLINE_JUDGE if (fopen("INPUT.txt", "r")) { freopen("INPUT.txt", "r", stdin); freopen("OUTPUT.txt", "w", stdout); } #endif int n; cin >> n; vector<pair<int, int>> ans; if (n & 1) { for (int i = 1; i <= n - 1; i++) { for (int j = i + 1; j <= n - 1; j++) { if (i + j == n) continue; ans.push_back({i, j}); } } for (int i = 1; i <= n - 1; i++) ans.push_back({i, n}); } else { for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) { if (i + j == n) continue; ans.push_back({i, j}); } } } cout << ans.size() << "\n"; for (auto i : ans) cout << i.first << " " << i.second << '\n'; }
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define pi 3.141592653589793238 #define int long long using namespace __gnu_pbds; using namespace std; template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0); #ifndef ONLINE_JUDGE if (fopen("INPUT.txt", "r")) { freopen("INPUT.txt", "r", stdin); freopen("OUTPUT.txt", "w", stdout); } #endif int n; cin >> n; vector<pair<int, int>> ans; if (n & 1) { for (int i = 1; i <= n - 1; i++) { for (int j = i + 1; j <= n - 1; j++) { if (i + j == n) continue; ans.push_back({i, j}); } } for (int i = 1; i <= n - 1; i++) ans.push_back({i, n}); } else { for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) { if (i + j == n + 1) continue; ans.push_back({i, j}); } } } cout << ans.size() << "\n"; for (auto i : ans) cout << i.first << " " << i.second << '\n'; }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change", "misc.off_by_one" ]
904,449
904,450
u193815565
cpp
p03090
#include "bits/stdc++.h" using namespace std; using lint = long long int; using pint = pair<int, int>; using plint = pair<lint, lint>; #define ALL(x) (x).begin(), (x).end() #define SZ(x) ((lint)(x).size()) #define POW2(n) (1LL << (n)) #define FOR(i, begin, end) \ for (lint i = (begin), i##_end_ = (end); i < i##_end_; i++) #define IFOR(i, begin, end) \ for (lint i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--) #define REP(i, n) FOR(i, 0, n) #define IREP(i, n) IFOR(i, 0, n) template <typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); } template <typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); } const lint MOD = 1e9 + 7; lint N; int main() { cin.tie(0); ios_base::sync_with_stdio(false); cin >> N; if (N % 2 == 0) { cout << N * (N - 1) / 2 - N / 2 << endl; FOR(i, 1, N) { FOR(j, i + 1, N + 1) { if (j == N - (i - 1)) continue; cout << i << " " << j << endl; } } } else { cout << N * (N - 1) / 2 - N / 2 << endl; FOR(i, 1, N) { FOR(j, i + 1, N + 1) { if (j == N - (i - 2)) continue; cout << i << " " << j << endl; } } } }
#include "bits/stdc++.h" using namespace std; using lint = long long int; using pint = pair<int, int>; using plint = pair<lint, lint>; #define ALL(x) (x).begin(), (x).end() #define SZ(x) ((lint)(x).size()) #define POW2(n) (1LL << (n)) #define FOR(i, begin, end) \ for (lint i = (begin), i##_end_ = (end); i < i##_end_; i++) #define IFOR(i, begin, end) \ for (lint i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--) #define REP(i, n) FOR(i, 0, n) #define IREP(i, n) IFOR(i, 0, n) template <typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); } template <typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); } const lint MOD = 1e9 + 7; lint N; int main() { cin.tie(0); ios_base::sync_with_stdio(false); cin >> N; if (N % 2 == 0) { cout << N * (N - 1) / 2 - N / 2 << endl; FOR(i, 1, N) { FOR(j, i + 1, N + 1) { if (j == N - (i - 1)) continue; cout << i << " " << j << endl; } } } else { cout << N * (N - 1) / 2 - N / 2 << endl; FOR(i, 1, N) { FOR(j, i + 1, N + 1) { if (j == N - i) continue; cout << i << " " << j << endl; } } } }
[ "control_flow.branch.if.condition.change" ]
904,451
904,452
u554988565
cpp
p03090
#include <bits/stdc++.h> #include <sys/time.h> using namespace std; // hamko utils #define rep(i, n) for (long long i = 0; i < static_cast<long long>(n); i++) #define repi(i, a, b) \ for (long long i = static_cast<long long>(a); i < static_cast<long long>(b); \ i++) #define pb push_back #define all(x) (x).begin(), (x).end() #define fi first #define se second #define mt make_tuple #define mp make_pair template <class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); } template <class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); } using ll = long long; using vll = vector<ll>; using vvll = vector<vll>; using P = pair<ll, ll>; using ld = long double; using vld = vector<ld>; using vi = vector<int>; using vvi = vector<vi>; vll conv(vi &v) { vll r(v.size()); rep(i, v.size()) r[i] = v[i]; return r; } inline void input(int &v) { v = 0; char c = 0; int p = 1; while (c < '0' || c > '9') { if (c == '-') p = -1; c = getchar(); } while (c >= '0' && c <= '9') { v = (v << 3) + (v << 1) + c - '0'; c = getchar(); } v *= p; } // これを使うならば、tieとかを消して!! template <typename T, typename U> ostream &operator<<(ostream &o, const pair<T, U> &v) { o << "(" << v.first << ", " << v.second << ")"; return o; } template <size_t...> struct seq {}; template <size_t N, size_t... Is> struct gen_seq : gen_seq<N - 1, N - 1, Is...> {}; template <size_t... Is> struct gen_seq<0, Is...> : seq<Is...> {}; template <class Ch, class Tr, class Tuple, size_t... Is> void print_tuple(basic_ostream<Ch, Tr> &os, Tuple const &t, seq<Is...>) { using s = int[]; (void)s{0, (void(os << (Is == 0 ? "" : ", ") << get<Is>(t)), 0)...}; } template <class Ch, class Tr, class... Args> auto operator<<(basic_ostream<Ch, Tr> &os, tuple<Args...> const &t) -> basic_ostream<Ch, Tr> & { os << "("; print_tuple(os, t, gen_seq<sizeof...(Args)>()); return os << ")"; } ostream &operator<<(ostream &o, const vvll &v) { rep(i, v.size()) { rep(j, v[i].size()) o << v[i][j] << " "; o << endl; } return o; } template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { o << '['; rep(i, v.size()) o << v[i] << (i != v.size() - 1 ? ", " : ""); o << "]"; return o; } template <typename T> ostream &operator<<(ostream &o, const deque<T> &v) { o << '['; rep(i, v.size()) o << v[i] << (i != v.size() - 1 ? ", " : ""); o << "]"; return o; } template <typename T> ostream &operator<<(ostream &o, const set<T> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]"; return o; } template <typename T> ostream &operator<<(ostream &o, const unordered_set<T> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]"; return o; } template <typename T, typename U> ostream &operator<<(ostream &o, const map<T, U> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]"; return o; } template <typename T, typename U, typename V> ostream &operator<<(ostream &o, const unordered_map<T, U, V> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it; o << "]"; return o; } vector<int> range(const int x, const int y) { vector<int> v(y - x + 1); iota(v.begin(), v.end(), x); return v; } template <typename T> istream &operator>>(istream &i, vector<T> &o) { rep(j, o.size()) i >> o[j]; return i; } template <typename T, typename S, typename U> ostream &operator<<(ostream &o, const priority_queue<T, S, U> &v) { auto tmp = v; while (tmp.size()) { auto x = tmp.top(); tmp.pop(); o << x << " "; } return o; } template <typename T> ostream &operator<<(ostream &o, const queue<T> &v) { auto tmp = v; while (tmp.size()) { auto x = tmp.front(); tmp.pop(); o << x << " "; } return o; } template <typename T> ostream &operator<<(ostream &o, const stack<T> &v) { auto tmp = v; while (tmp.size()) { auto x = tmp.top(); tmp.pop(); o << x << " "; } return o; } template <typename T> unordered_map<T, ll> counter(vector<T> vec) { unordered_map<T, ll> ret; for (auto &&x : vec) ret[x]++; return ret; }; string substr(string s, P x) { return s.substr(x.fi, x.se - x.fi); } void vizGraph(vvll &g, int mode = 0, string filename = "out.png") { ofstream ofs("./out.dot"); ofs << "digraph graph_name {" << endl; set<P> memo; rep(i, g.size()) rep(j, g[i].size()) { if (mode && (memo.count(P(i, g[i][j])) || memo.count(P(g[i][j], i)))) continue; memo.insert(P(i, g[i][j])); ofs << " " << i << " -> " << g[i][j] << (mode ? " [arrowhead = none]" : "") << endl; } ofs << "}" << endl; ofs.close(); system((string("dot -T png out.dot >") + filename).c_str()); } class ScopedTime { public: ScopedTime(const std::string &msg = "") : msg_(msg) { start_ = std::chrono::system_clock::now(); } void lap(const std::string &msg) { const auto duration_time = std::chrono::system_clock::now() - start_; const auto duration_ms = std::chrono::duration_cast<std::chrono::milliseconds>(duration_time); std::cerr << "[" << duration_ms.count() << " ms] " << msg << std::endl; } virtual ~ScopedTime() { this->lap(msg_); } private: std::chrono::system_clock::time_point start_; std::string msg_; }; size_t g_random_seed; struct init_ { init_() { std::ios::sync_with_stdio(false); std::cin.tie(0); srand(static_cast<unsigned int>(time(NULL))); g_random_seed = RAND_MAX / 2 + rand() / 2; } } init__; namespace std { using argument_type = P; template <> struct hash<argument_type> { size_t operator()(argument_type const &x) const { size_t seed = g_random_seed; seed ^= hash<ll>{}(x.fi); seed ^= (hash<ll>{}(x.se) << 1); return seed; } }; }; // namespace std #define ldout fixed << setprecision(40) #define EPS (double)1e-14 #define INF (ll)1e18 #define mo (ll)(1e9 + 7) // end of hamko utils template <typename T, typename X> auto vectors(T a, X x) { return vector<T>(x, a); } template <typename T, typename X, typename Y, typename... Zs> auto vectors(T a, X x, Y y, Zs... zs) { auto cont = vectors(a, y, zs...); return vector<decltype(cont)>(x, cont); } // usage: vector<vector<vector<double> > > dp = vectors(double(), 10, 20, 30); int adjm[101][101]; void connect(int i, int j) { adjm[i][j] = 1; adjm[j][i] = 1; } void print(int N) { std::stringstream ss; ll cnt = 0; for (int i = 1; i <= N; i++) { for (int j = i + 1; j <= N; j++) { if (adjm[i][j]) { cnt++; ss << i << " " << j << endl; } } } std::cout << cnt << std::endl; std::cout << ss.str() << std::endl; } int main(void) { ll N; cin >> N; ll n; if (N % 2 != 0) { n = N - 1; } else { n = N; } if (N % 2 != 0) { for (int i = 1; i < N; i++) { connect(i, N); } } for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (i != j && (i + j) != (n + 1)) { connect(i, n); } } } print(N); return 0; }
#include <bits/stdc++.h> #include <sys/time.h> using namespace std; // hamko utils #define rep(i, n) for (long long i = 0; i < static_cast<long long>(n); i++) #define repi(i, a, b) \ for (long long i = static_cast<long long>(a); i < static_cast<long long>(b); \ i++) #define pb push_back #define all(x) (x).begin(), (x).end() #define fi first #define se second #define mt make_tuple #define mp make_pair template <class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); } template <class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); } using ll = long long; using vll = vector<ll>; using vvll = vector<vll>; using P = pair<ll, ll>; using ld = long double; using vld = vector<ld>; using vi = vector<int>; using vvi = vector<vi>; vll conv(vi &v) { vll r(v.size()); rep(i, v.size()) r[i] = v[i]; return r; } inline void input(int &v) { v = 0; char c = 0; int p = 1; while (c < '0' || c > '9') { if (c == '-') p = -1; c = getchar(); } while (c >= '0' && c <= '9') { v = (v << 3) + (v << 1) + c - '0'; c = getchar(); } v *= p; } // これを使うならば、tieとかを消して!! template <typename T, typename U> ostream &operator<<(ostream &o, const pair<T, U> &v) { o << "(" << v.first << ", " << v.second << ")"; return o; } template <size_t...> struct seq {}; template <size_t N, size_t... Is> struct gen_seq : gen_seq<N - 1, N - 1, Is...> {}; template <size_t... Is> struct gen_seq<0, Is...> : seq<Is...> {}; template <class Ch, class Tr, class Tuple, size_t... Is> void print_tuple(basic_ostream<Ch, Tr> &os, Tuple const &t, seq<Is...>) { using s = int[]; (void)s{0, (void(os << (Is == 0 ? "" : ", ") << get<Is>(t)), 0)...}; } template <class Ch, class Tr, class... Args> auto operator<<(basic_ostream<Ch, Tr> &os, tuple<Args...> const &t) -> basic_ostream<Ch, Tr> & { os << "("; print_tuple(os, t, gen_seq<sizeof...(Args)>()); return os << ")"; } ostream &operator<<(ostream &o, const vvll &v) { rep(i, v.size()) { rep(j, v[i].size()) o << v[i][j] << " "; o << endl; } return o; } template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { o << '['; rep(i, v.size()) o << v[i] << (i != v.size() - 1 ? ", " : ""); o << "]"; return o; } template <typename T> ostream &operator<<(ostream &o, const deque<T> &v) { o << '['; rep(i, v.size()) o << v[i] << (i != v.size() - 1 ? ", " : ""); o << "]"; return o; } template <typename T> ostream &operator<<(ostream &o, const set<T> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]"; return o; } template <typename T> ostream &operator<<(ostream &o, const unordered_set<T> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]"; return o; } template <typename T, typename U> ostream &operator<<(ostream &o, const map<T, U> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]"; return o; } template <typename T, typename U, typename V> ostream &operator<<(ostream &o, const unordered_map<T, U, V> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it; o << "]"; return o; } vector<int> range(const int x, const int y) { vector<int> v(y - x + 1); iota(v.begin(), v.end(), x); return v; } template <typename T> istream &operator>>(istream &i, vector<T> &o) { rep(j, o.size()) i >> o[j]; return i; } template <typename T, typename S, typename U> ostream &operator<<(ostream &o, const priority_queue<T, S, U> &v) { auto tmp = v; while (tmp.size()) { auto x = tmp.top(); tmp.pop(); o << x << " "; } return o; } template <typename T> ostream &operator<<(ostream &o, const queue<T> &v) { auto tmp = v; while (tmp.size()) { auto x = tmp.front(); tmp.pop(); o << x << " "; } return o; } template <typename T> ostream &operator<<(ostream &o, const stack<T> &v) { auto tmp = v; while (tmp.size()) { auto x = tmp.top(); tmp.pop(); o << x << " "; } return o; } template <typename T> unordered_map<T, ll> counter(vector<T> vec) { unordered_map<T, ll> ret; for (auto &&x : vec) ret[x]++; return ret; }; string substr(string s, P x) { return s.substr(x.fi, x.se - x.fi); } void vizGraph(vvll &g, int mode = 0, string filename = "out.png") { ofstream ofs("./out.dot"); ofs << "digraph graph_name {" << endl; set<P> memo; rep(i, g.size()) rep(j, g[i].size()) { if (mode && (memo.count(P(i, g[i][j])) || memo.count(P(g[i][j], i)))) continue; memo.insert(P(i, g[i][j])); ofs << " " << i << " -> " << g[i][j] << (mode ? " [arrowhead = none]" : "") << endl; } ofs << "}" << endl; ofs.close(); system((string("dot -T png out.dot >") + filename).c_str()); } class ScopedTime { public: ScopedTime(const std::string &msg = "") : msg_(msg) { start_ = std::chrono::system_clock::now(); } void lap(const std::string &msg) { const auto duration_time = std::chrono::system_clock::now() - start_; const auto duration_ms = std::chrono::duration_cast<std::chrono::milliseconds>(duration_time); std::cerr << "[" << duration_ms.count() << " ms] " << msg << std::endl; } virtual ~ScopedTime() { this->lap(msg_); } private: std::chrono::system_clock::time_point start_; std::string msg_; }; size_t g_random_seed; struct init_ { init_() { std::ios::sync_with_stdio(false); std::cin.tie(0); srand(static_cast<unsigned int>(time(NULL))); g_random_seed = RAND_MAX / 2 + rand() / 2; } } init__; namespace std { using argument_type = P; template <> struct hash<argument_type> { size_t operator()(argument_type const &x) const { size_t seed = g_random_seed; seed ^= hash<ll>{}(x.fi); seed ^= (hash<ll>{}(x.se) << 1); return seed; } }; }; // namespace std #define ldout fixed << setprecision(40) #define EPS (double)1e-14 #define INF (ll)1e18 #define mo (ll)(1e9 + 7) // end of hamko utils template <typename T, typename X> auto vectors(T a, X x) { return vector<T>(x, a); } template <typename T, typename X, typename Y, typename... Zs> auto vectors(T a, X x, Y y, Zs... zs) { auto cont = vectors(a, y, zs...); return vector<decltype(cont)>(x, cont); } // usage: vector<vector<vector<double> > > dp = vectors(double(), 10, 20, 30); int adjm[101][101]; void connect(int i, int j) { adjm[i][j] = 1; adjm[j][i] = 1; } void print(int N) { std::stringstream ss; ll cnt = 0; for (int i = 1; i <= N; i++) { for (int j = i + 1; j <= N; j++) { if (adjm[i][j]) { cnt++; ss << i << " " << j << endl; } } } std::cout << cnt << std::endl; std::cout << ss.str() << std::endl; } int main(void) { ll N; cin >> N; ll n; if (N % 2 != 0) { n = N - 1; } else { n = N; } if (N % 2 != 0) { for (int i = 1; i < N; i++) { connect(i, N); } } for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (i != j && (i + j) != (n + 1)) { connect(i, j); } } } print(N); return 0; }
[ "identifier.change", "call.arguments.change" ]
904,453
904,454
u897282055
cpp
p03090
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, j, n) for (ll i = j; i < n; i++) #define all(x) (x).begin(), (x).end() #define INF (1000000000) #define MOD (1000000007) #define MAX (100000) #define pii pair<int, int> ///////////////////////////////////////////////////////// class XY { public: ll x, y; XY() { x = y = 0; } XY(ll u, ll v) { x = u; y = v; } }; class e { public: ll a, b; e() { a = b = -1; } e(ll u, ll v) { a = u; b = v; } }; template <typename T1, typename T2> void chmin(T1 &a, T2 b) { if (a > b) a = b; } template <typename T1, typename T2> void chmax(T1 &a, T2 b) { if (a < b) a = b; } template <typename T1, typename T2> ll mypow(T1 a, T2 n) { if (n == 0) return 1; if (n == 1) return a; if (n % 2) return a * mypow(a, n - 1); ll tmp = mypow(a, n / 2); return tmp * tmp; } template <typename T> int BS(vector<T> &V, int left, int right, T key) { int mid = (left + right) / 2; if (V[mid] <= key) left = mid; else right = mid; if (right - mid == 1) return left; else return BS(V, left, right, key); } ll comb(ll n, ll r) { ll res = 1; rep(i, 0, r) { res *= n - i; res /= i + 1; } return res; } template <typename T> T euclid(T a, T b) { if (b == 0) return a; else return euclid(b, a % b); } ///////////////////////////////////////////////////////// void Main() { int N; cin >> N; if (N % 2 == 0) { cout << N * (N - 2) / 2 << endl; rep(i, 1, N + 1) { rep(j, i + 1, N + 1) { if (i + j == N + 1) continue; cout << i << " " << j << endl; } } } else { cout << (N - 1) * (N - 1) / 2 << endl; rep(i, 1, N + 1) { rep(j, i + 1, N + 1) { if (i + j == N + 1) continue; cout << i << " " << j << endl; } } } } ///////////////////////////////////////////////////////// int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << std::fixed << std::setprecision(15); Main(); }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, j, n) for (ll i = j; i < n; i++) #define all(x) (x).begin(), (x).end() #define INF (1000000000) #define MOD (1000000007) #define MAX (100000) #define pii pair<int, int> ///////////////////////////////////////////////////////// class XY { public: ll x, y; XY() { x = y = 0; } XY(ll u, ll v) { x = u; y = v; } }; class e { public: ll a, b; e() { a = b = -1; } e(ll u, ll v) { a = u; b = v; } }; template <typename T1, typename T2> void chmin(T1 &a, T2 b) { if (a > b) a = b; } template <typename T1, typename T2> void chmax(T1 &a, T2 b) { if (a < b) a = b; } template <typename T1, typename T2> ll mypow(T1 a, T2 n) { if (n == 0) return 1; if (n == 1) return a; if (n % 2) return a * mypow(a, n - 1); ll tmp = mypow(a, n / 2); return tmp * tmp; } template <typename T> int BS(vector<T> &V, int left, int right, T key) { int mid = (left + right) / 2; if (V[mid] <= key) left = mid; else right = mid; if (right - mid == 1) return left; else return BS(V, left, right, key); } ll comb(ll n, ll r) { ll res = 1; rep(i, 0, r) { res *= n - i; res /= i + 1; } return res; } template <typename T> T euclid(T a, T b) { if (b == 0) return a; else return euclid(b, a % b); } ///////////////////////////////////////////////////////// void Main() { int N; cin >> N; if (N % 2 == 0) { cout << N * (N - 2) / 2 << endl; rep(i, 1, N + 1) { rep(j, i + 1, N + 1) { if (i + j == N + 1) continue; cout << i << " " << j << endl; } } } else { cout << (N - 1) * (N - 1) / 2 << endl; rep(i, 1, N + 1) { rep(j, i + 1, N + 1) { if (i + j == N) continue; cout << i << " " << j << endl; } } } } ///////////////////////////////////////////////////////// int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << std::fixed << std::setprecision(15); Main(); }
[ "expression.operation.binary.remove" ]
904,457
904,458
u855985627
cpp
p03090
#include <algorithm> //STLͨ���㷨 #include <cmath> //������ѧ���� #include <cstdio> //��������/������� #include <cstring> //�ַ������� #include <ctime> //�������ʱ��ĺ��� #include <iostream> //����������/��� #include <string> //�ַ����� #define itn int #define fro for #define ll long long #define reg register #define inf 1234567890 #define rep(i, a, b, c) for (int i = a; i <= b; i += c) /*#include <bitset> //STLλ������ #include <cerrno> //��������� #include <clocale> //���屾�ػ����� #include <complex> //������ #include <cstdlib> //������������ڴ���亯�� #include <cstype> //�ַ����� #include <cwchar.h>//���ַ�����������/��� #include <cwctype.h> //���ַ�����*/ #include <deque> //STL˫�˶������� #include <exception> //�쳣������ #include <fstream> //�ļ�����/��� #include <functional> //STL�������㺯��(���������) #include <iomanip> //����������/��� #include <ios> //��������/���֧�� #include <iosfwd> //����/���ϵͳʹ�õ�ǰ������ #include <istream> //���������� #include <limits> //�����������������ֵ���� #include <list> //STL�����б����� #include <map> //STLӳ������ #include <ostream> //��������� #include <queue> //STL�������� #include <set> //STL�������� #include <sstream> //�����ַ������� #include <stack> //STL��ջ���� #include <stdexcept> //��׼�쳣�� #include <streambuf> //�ײ�����/���֧�� #include <utility> //STLͨ��ģ���� #include <vector> //STL��̬�������� using namespace std; int ans; int max(int x, int y) { return x > y ? x : y; } int min(int x, int y) { return x < y ? x : y; } int abs(int x) { return x > 0 ? x : -x; } int gcd(int x, int y) { return (!y) ? x : gcd(y, x % y); } void exgcd(int a, int b, int &d, int &x, int &y) { if (!b) { d = a, x = 1, y = 0; } else { exgcd(b, a % b, d, y, x); y -= x * (a / b); } } int quick_power(ll a, int b) { ll r = 1; for (; b; b >>= 1, a = a * a) if (b & 1) r = r * a; return r; } inline char read() { static const int IN_LEN = 1000000; static char buf[IN_LEN], *s, *t; return (s == t ? t = (s = buf) + fread(buf, 1, IN_LEN, stdin), (s == t ? -1 : *s++) : *s++); } template <class T> inline void read(T &x) { static bool iosig; static char c; for (iosig = false, c = read(); !isdigit(c); c = read()) { if (c == '-') iosig = true; if (c == -1) return; } for (x = 0; isdigit(c); c = read()) x = x * 10 + (c ^ '0'); if (iosig) x = -x; } char sr[10000000], z[20]; int C = -1, Z = 0; void Ot() { fwrite(sr, 1, C + 1, stdout), C = -1; } void print(int x) { if (x < 0) sr[++C] = '-', x = -x; while (z[++Z] = x % 10 + 48, x /= 10) ; while (sr[++C] = z[Z], --Z) ; sr[++C] = '\n'; } // int find(int x){return fa[x]=fa[x]==x?x:find(fa[x]);} // void add(int x,int y,int // z){to[++cnt]=y;v[cnt]=z;Next[cnt]=head[x];head[x]=cnt;} int main() { int n; read(n); if (n % 2 == 1) { printf("%d\n", (n - 1) * (n - 3) / 2 + n - 1); for (int i = 1; i < n; i++) printf("%d %d\n", i, n); for (int i = 1; i < n; i++) for (int j = i + 1; j < n; j++) if (i + j != n) printf("%d %d\n", i, j); } if (n % 2 == 0) { printf("%d\n", (n - 1) * (n - 2) / 2); for (int i = 1; i <= n; i++) for (int j = i + 1; j <= n; j++) if (i + j != n + 1) printf("%d %d\n", i, j); } return 0; }
#include <algorithm> //STLͨ���㷨 #include <cmath> //������ѧ���� #include <cstdio> //��������/������� #include <cstring> //�ַ������� #include <ctime> //�������ʱ��ĺ��� #include <iostream> //����������/��� #include <string> //�ַ����� #define itn int #define fro for #define ll long long #define reg register #define inf 1234567890 #define rep(i, a, b, c) for (int i = a; i <= b; i += c) /*#include <bitset> //STLλ������ #include <cerrno> //��������� #include <clocale> //���屾�ػ����� #include <complex> //������ #include <cstdlib> //������������ڴ���亯�� #include <cstype> //�ַ����� #include <cwchar.h>//���ַ�����������/��� #include <cwctype.h> //���ַ�����*/ #include <deque> //STL˫�˶������� #include <exception> //�쳣������ #include <fstream> //�ļ�����/��� #include <functional> //STL�������㺯��(���������) #include <iomanip> //����������/��� #include <ios> //��������/���֧�� #include <iosfwd> //����/���ϵͳʹ�õ�ǰ������ #include <istream> //���������� #include <limits> //�����������������ֵ���� #include <list> //STL�����б����� #include <map> //STLӳ������ #include <ostream> //��������� #include <queue> //STL�������� #include <set> //STL�������� #include <sstream> //�����ַ������� #include <stack> //STL��ջ���� #include <stdexcept> //��׼�쳣�� #include <streambuf> //�ײ�����/���֧�� #include <utility> //STLͨ��ģ���� #include <vector> //STL��̬�������� using namespace std; int ans; int max(int x, int y) { return x > y ? x : y; } int min(int x, int y) { return x < y ? x : y; } int abs(int x) { return x > 0 ? x : -x; } int gcd(int x, int y) { return (!y) ? x : gcd(y, x % y); } void exgcd(int a, int b, int &d, int &x, int &y) { if (!b) { d = a, x = 1, y = 0; } else { exgcd(b, a % b, d, y, x); y -= x * (a / b); } } int quick_power(ll a, int b) { ll r = 1; for (; b; b >>= 1, a = a * a) if (b & 1) r = r * a; return r; } inline char read() { static const int IN_LEN = 1000000; static char buf[IN_LEN], *s, *t; return (s == t ? t = (s = buf) + fread(buf, 1, IN_LEN, stdin), (s == t ? -1 : *s++) : *s++); } template <class T> inline void read(T &x) { static bool iosig; static char c; for (iosig = false, c = read(); !isdigit(c); c = read()) { if (c == '-') iosig = true; if (c == -1) return; } for (x = 0; isdigit(c); c = read()) x = x * 10 + (c ^ '0'); if (iosig) x = -x; } char sr[10000000], z[20]; int C = -1, Z = 0; void Ot() { fwrite(sr, 1, C + 1, stdout), C = -1; } void print(int x) { if (x < 0) sr[++C] = '-', x = -x; while (z[++Z] = x % 10 + 48, x /= 10) ; while (sr[++C] = z[Z], --Z) ; sr[++C] = '\n'; } // int find(int x){return fa[x]=fa[x]==x?x:find(fa[x]);} // void add(int x,int y,int // z){to[++cnt]=y;v[cnt]=z;Next[cnt]=head[x];head[x]=cnt;} int main() { int n; read(n); if (n % 2 == 1) { printf("%d\n", (n - 1) * (n - 3) / 2 + n - 1); for (int i = 1; i < n; i++) printf("%d %d\n", i, n); for (int i = 1; i < n; i++) for (int j = i + 1; j < n; j++) if (i + j != n) printf("%d %d\n", i, j); } if (n % 2 == 0) { printf("%d\n", n * (n - 2) / 2); for (int i = 1; i <= n; i++) for (int j = i + 1; j <= n; j++) if (i + j != n + 1) printf("%d %d\n", i, j); } return 0; }
[ "call.arguments.change" ]
904,459
904,460
u794315108
cpp
p03090
// https://atcoder.jp/contests/agc032/tasks/agc032_b #include <bits/stdc++.h> using namespace std; using pii = pair<int, int>; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<pii> v; if (n % 2 == 1) { // 五角形のノード 5 は「全部」 for (int i = 1; i < n; i++) { v.push_back({i, n}); } } for (int i = 1; i <= (n / 2 * 2); i++) { for (int j = i + 1; j <= (n / 2 * 2); j++) { // 四角形のノード 1 は「4 以外」 // 五角形のノード 1 は「4 以外」 if (i + j != (n + 1) / 2 * 2) { v.push_back({i, j}); } } } cout << v.size() << "\n"; for (auto &x : v) { cout << x.first << " " << x.second << "\n"; } return 0; }
// https://atcoder.jp/contests/agc032/tasks/agc032_b #include <bits/stdc++.h> using namespace std; using pii = pair<int, int>; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<pii> v; if (n % 2 == 1) { // 五角形のノード 5 は「全部」 for (int i = 1; i < n; i++) { v.push_back({i, n}); } } for (int i = 1; i <= (n / 2 * 2); i++) { for (int j = i + 1; j <= (n / 2 * 2); j++) { // 四角形のノード 1 は「4 以外」 // 五角形のノード 1 は「4 以外」 if (i + j != n + (n + 1) % 2) { v.push_back({i, j}); } } } cout << v.size() << "\n"; for (auto &x : v) { cout << x.first << " " << x.second << "\n"; } return 0; }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change", "expression.operator.arithmetic.change", "expression.operation.binary.remove" ]
904,465
904,466
u858107870
cpp
p03090
// https://atcoder.jp/contests/agc032/tasks/agc032_b #include <bits/stdc++.h> using namespace std; using pii = pair<int, int>; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<pii> v; if (n % 2 == 1) { for (int i = 1; i < n; i++) { v.push_back({i, n}); } } for (int i = 1; i <= (n / 2 * 2); i++) { for (int j = i + 1; j <= (n / 2 * 2); j++) { if (i + j != n + 1) { v.push_back({i, j}); } } } cout << v.size() << "\n"; for (auto &x : v) { cout << x.first << " " << x.second << "\n"; } return 0; }
// https://atcoder.jp/contests/agc032/tasks/agc032_b #include <bits/stdc++.h> using namespace std; using pii = pair<int, int>; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<pii> v; if (n % 2 == 1) { // 五角形のノード 5 は「全部」 for (int i = 1; i < n; i++) { v.push_back({i, n}); } } for (int i = 1; i <= (n / 2 * 2); i++) { for (int j = i + 1; j <= (n / 2 * 2); j++) { // 四角形のノード 1 は「4 以外」 // 五角形のノード 1 は「4 以外」 if (i + j != n + (n + 1) % 2) { v.push_back({i, j}); } } } cout << v.size() << "\n"; for (auto &x : v) { cout << x.first << " " << x.second << "\n"; } return 0; }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change" ]
904,467
904,466
u858107870
cpp
p03090
// https://atcoder.jp/contests/agc032/tasks/agc032_b #include <bits/stdc++.h> using namespace std; using pii = pair<int, int>; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<pii> v; if (n % 2 == 1) { for (int i = 1; i < n; i++) { v.push_back({i, n}); } } for (int i = 1; i <= (n / 2 * 2); i++) { for (int j = i + 1; j <= (n / 2 * 2); j++) { if (i + j != n + 1) { v.push_back({i, j}); } } } cout << v.size() << "\n"; for (auto &x : v) { cout << x.first << " " << x.second << "\n"; } return 0; }
// https://atcoder.jp/contests/agc032/tasks/agc032_b #include <bits/stdc++.h> using namespace std; using pii = pair<int, int>; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<pii> v; if (n % 2 == 1) { for (int i = 1; i < n; i++) { v.push_back({i, n}); } } for (int i = 1; i <= (n / 2 * 2); i++) { for (int j = i + 1; j <= (n / 2 * 2); j++) { if (i + j != n + (n + 1) % 2) { v.push_back({i, j}); } } } cout << v.size() << "\n"; for (auto &x : v) { cout << x.first << " " << x.second << "\n"; } return 0; }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change" ]
904,467
904,468
u858107870
cpp
p03090
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int N; cin >> N; int M = N * (N - 1) / 2 - N / 2; cout << M << "\n"; if (N % 2 == 1) { for (int i = 1; i < N; ++i) { cout << i << " " << N << "\n"; } N--; } for (int i = 1; i <= N / 2; ++i) { for (int j = i + 1; j <= N; ++j) { if (i + j != N + 1) { cout << i << " " << j << "\n"; } } } return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int N; cin >> N; int M = N * (N - 1) / 2 - N / 2; cout << M << "\n"; if (N % 2 == 1) { for (int i = 1; i < N; ++i) { cout << i << " " << N << "\n"; } N--; } for (int i = 1; i < N; ++i) { for (int j = i + 1; j <= N; ++j) { if (i + j != N + 1) { cout << i << " " << j << "\n"; } } } return 0; }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change", "expression.operation.binary.remove" ]
904,469
904,470
u590088474
cpp
p03090
#include <bits/stdc++.h> using namespace std; #define int long long const double PI = 3.14159265358979323846; typedef vector<int> vint; typedef pair<int, int> pint; const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; // cout << fixed << setprecision(20); int N; signed main() { cin >> N; vector<pint> ans; for (int i = 1; i <= N; i++) { for (int j = i + 1; j <= N; j++) if (i != N - j) ans.push_back(pint(i, j)); } cout << ans.size() << endl; for (int i = 0; i < ans.size(); i++) cout << ans[i].first << " " << ans[i].second << endl; }
#include <bits/stdc++.h> using namespace std; #define int long long const double PI = 3.14159265358979323846; typedef vector<int> vint; typedef pair<int, int> pint; const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; // cout << fixed << setprecision(20); int N; signed main() { cin >> N; vector<pint> ans; for (int i = 1; i <= N; i++) { for (int j = i + 1; j <= N; j++) if (i != N / 2 * 2 + 1 - j) ans.push_back(pint(i, j)); } cout << ans.size() << endl; for (int i = 0; i < ans.size(); i++) cout << ans[i].first << " " << ans[i].second << endl; }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change" ]
904,471
904,472
u450832845
cpp
p03090
#include <bits/stdc++.h> using namespace std; const unsigned long long MOD = 1000000007LL; long long GCD(long long a, long long b) { return b == 0 ? a : GCD(b, a % b); } long long fast_exp(long long base, long long exp) { long long tot = 1; for (; exp > 0; exp >>= 1) { if ((exp & 1) == 1) tot = tot * base % MOD; base = base * base % MOD; } return tot; } int main() { cin.sync_with_stdio(0); cin.tie(0); cout.tie(0); // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); // place into groups of (i, n - i) // proceed to connect all these groups int n; cin >> n; int target = n % 2 == 1 ? n + 1 : n; vector<pair<int, int>> q; for (int i = 1; i <= n; ++i) for (int j = i + 1; j <= n; ++j) if (i + j != target) q.push_back(make_pair(i, j)); cout << q.size() << "\n"; for (auto i : q) cout << i.first << " " << i.second << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; const unsigned long long MOD = 1000000007LL; long long GCD(long long a, long long b) { return b == 0 ? a : GCD(b, a % b); } long long fast_exp(long long base, long long exp) { long long tot = 1; for (; exp > 0; exp >>= 1) { if ((exp & 1) == 1) tot = tot * base % MOD; base = base * base % MOD; } return tot; } int main() { cin.sync_with_stdio(0); cin.tie(0); cout.tie(0); // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); // place into groups of (i, n - i) // proceed to connect all these groups int n; cin >> n; int target = n % 2 == 1 ? n : n + 1; vector<pair<int, int>> q; for (int i = 1; i <= n; ++i) for (int j = i + 1; j <= n; ++j) if (i + j != target) q.push_back(make_pair(i, j)); cout << q.size() << "\n"; for (auto i : q) cout << i.first << " " << i.second << "\n"; return 0; }
[ "expression.operation.binary.remove" ]
904,480
904,481
u276568758
cpp
p03090
#include <algorithm> #include <numeric> #include <stdio.h> #include <string> #include <vector> const int mod = 1000000007; int main() { int N; scanf("%d", &N); if (N % 2 == 0) { printf("%d\n", N * (N - 2) / 2); for (int i = 1; i <= N; i++) { for (int j = i + 1; j <= N; j++) { if (j != N - i + 1) { printf("%d %d\n", i, j); } } } } else { printf("%d", (N - 1) * (N - 3) / 2 + (N - 1)); for (int i = 1; i < N; i++) { for (int j = i + 1; j < N; j++) { if (j != N - i) { printf("%d %d\n", i, j); } } printf("%d %d\n", i, N); } } }
#include <algorithm> #include <numeric> #include <stdio.h> #include <string> #include <vector> const int mod = 1000000007; int main() { int N; scanf("%d", &N); if (N % 2 == 0) { printf("%d\n", N * (N - 2) / 2); for (int i = 1; i <= N; i++) { for (int j = i + 1; j <= N; j++) { if (j != N - i + 1) { printf("%d %d\n", i, j); } } } } else { printf("%d\n", (N - 1) * (N - 3) / 2 + (N - 1)); for (int i = 1; i < N; i++) { for (int j = i + 1; j < N; j++) { if (j != N - i) { printf("%d %d\n", i, j); } } printf("%d %d\n", i, N); } } }
[ "literal.string.change", "call.arguments.change", "io.output.change", "io.output.newline.add" ]
904,482
904,483
u617987447
cpp
p03090
#include <bits/stdc++.h> using namespace std; // types - only for stuff used a lot using ll = long long; #define vv vector #define Pp pair // IO #define get(x) scanf("%d", &x) #define getl(x) scanf("%lld", &x); // Operations #define pb push_back #define pob pop_back #define sz(a) int(a.size()) #define re(a, b) a = max(a, b) // relax #define ri(a, b) a = min(a, b) // relaxi // Debugging #ifndef LOCAL #define cerr \ if (0) \ cerr #else #define cerr cout #endif #define print(arr, n) \ { \ for (int _ = 0; _ < n; _++) \ cerr << arr[_] << " "; \ cerr << endl; \ } #define printv(vec) \ { \ for (int _ : vec) \ cerr << _ << " "; \ cerr << endl; \ } const int mod = 1e9 + 7, oo = 1e9; const ll loo = 1e18; // Functions ll modpow(ll a, ll b) { ll ans = 1; // faster modpow than recursive for (; b; b /= 2, a = a * a % mod) if (b & 1) ans = (ans * a) % mod; return ans; } ll gcd(ll a, ll b) { while (a) b %= a, swap(a, b); return b; } #define bitcount __builtin_popcountll #define f(i, a, b) for (int i = a; i < b; i++) #define fr(i, a, b) for (int i = b - 1; i >= a; i--) /* ALRIGHT HACKERS, THIS IS WHERE THE ACTUAL CODE BEGINS */ const bool DEBUG = 1; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); #ifdef LOCAL if (DEBUG) freopen("input.txt", "r", stdin); if (DEBUG) freopen("output.txt", "w", stdout); clock_t start = clock(); #endif int n; cin >> n; int gr[n]; int t = 0; if (n & 1) f(i, 0, n - 1) gr[i] = gr[n - 2 - i] = t++, gr[n] = t++; else f(i, 0, n) gr[i] = gr[n - 1 - i] = t++; int m = 0; stringstream ss; f(i, 0, n) f(j, i, m) if (gr[i] != gr[j]) { ss << i + 1 << " " << j + 1 << endl; m++; } cout << m << endl << ss.str(); #ifdef LOCAL cout << setprecision(12) << (long double)(clock() - start) / CLOCKS_PER_SEC << endl; #endif return 0; }
#include <bits/stdc++.h> using namespace std; // types - only for stuff used a lot using ll = long long; #define vv vector #define Pp pair // IO #define get(x) scanf("%d", &x) #define getl(x) scanf("%lld", &x); // Operations #define pb push_back #define pob pop_back #define sz(a) int(a.size()) #define re(a, b) a = max(a, b) // relax #define ri(a, b) a = min(a, b) // relaxi // Debugging #ifndef LOCAL #define cerr \ if (0) \ cerr #else #define cerr cout #endif #define print(arr, n) \ { \ for (int _ = 0; _ < n; _++) \ cerr << arr[_] << " "; \ cerr << endl; \ } #define printv(vec) \ { \ for (int _ : vec) \ cerr << _ << " "; \ cerr << endl; \ } const int mod = 1e9 + 7, oo = 1e9; const ll loo = 1e18; // Functions ll modpow(ll a, ll b) { ll ans = 1; // faster modpow than recursive for (; b; b /= 2, a = a * a % mod) if (b & 1) ans = (ans * a) % mod; return ans; } ll gcd(ll a, ll b) { while (a) b %= a, swap(a, b); return b; } #define bitcount __builtin_popcountll #define f(i, a, b) for (int i = a; i < b; i++) #define fr(i, a, b) for (int i = b - 1; i >= a; i--) /* ALRIGHT HACKERS, THIS IS WHERE THE ACTUAL CODE BEGINS */ const bool DEBUG = 1; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); #ifdef LOCAL if (DEBUG) freopen("input.txt", "r", stdin); if (DEBUG) freopen("output.txt", "w", stdout); clock_t start = clock(); #endif int n; cin >> n; int gr[n]; int t = 0; if (n & 1) f(i, 0, n - 1) gr[i] = gr[n - 2 - i] = t++, gr[n - 1] = t++; else f(i, 0, n) gr[i] = gr[n - 1 - i] = t++; int m = 0; stringstream ss; f(i, 0, n) f(j, i, n) if (gr[i] != gr[j]) { ss << i + 1 << " " << j + 1 << endl; m++; } cout << m << endl << ss.str(); #ifdef LOCAL cout << setprecision(12) << (long double)(clock() - start) / CLOCKS_PER_SEC << endl; #endif return 0; }
[ "assignment.change", "identifier.change", "call.arguments.change" ]
904,486
904,487
u027091475
cpp
p03090
#include <bits/stdc++.h> using namespace std; using ll = long long; template <class T> using V = vector<T>; template <class T, class U> using P = pair<T, U>; using vll = V<ll>; using vvll = V<vll>; #define rep(i, k, n) for (ll i = k; i < (ll)n; ++i) #define REP(i, n) rep(i, 0, n) const ll MOD = 1000000007; const ll HIGHINF = (ll)1e18; int main() { ll n; cin >> n; if (n % 2 == 1) { cout << ((n - 2) * (n - 1)) / 2 + 1 << endl; REP(i, n) { rep(j, i + 1, n) { if (i == j) continue; if (i + j + 2 == n) continue; cout << i + 1 << ' ' << j + 1 << endl; } } } else { cout << ((n - 2) * n) / 2 << endl; REP(i, n) { rep(j, i + 1, n) { if (i == j) continue; if (i + j + 2 == n + 1) continue; cout << i + 1 << ' ' << j + 1 << endl; } } } return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; template <class T> using V = vector<T>; template <class T, class U> using P = pair<T, U>; using vll = V<ll>; using vvll = V<vll>; #define rep(i, k, n) for (ll i = k; i < (ll)n; ++i) #define REP(i, n) rep(i, 0, n) const ll MOD = 1000000007; const ll HIGHINF = (ll)1e18; int main() { ll n; cin >> n; if (n % 2 == 1) { cout << ((n - 2) * n + 1) / 2 << endl; REP(i, n) { rep(j, i + 1, n) { if (i == j) continue; if (i + j + 2 == n) continue; cout << i + 1 << ' ' << j + 1 << endl; } } } else { cout << ((n - 2) * n) / 2 << endl; REP(i, n) { rep(j, i + 1, n) { if (i == j) continue; if (i + j + 2 == n + 1) continue; cout << i + 1 << ' ' << j + 1 << endl; } } } return 0; }
[ "misc.opposites", "expression.operator.arithmetic.change", "io.output.change", "expression.operation.binary.remove" ]
904,488
904,489
u077337864
cpp
p03090
#include <iostream> using namespace std; int main() { int n; cin >> n; int ans = n * (n - 1) / 2 - n / 2; cout << ans << endl; int a[ans], b[ans]; int k = 0; for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) { if (i + j != n + 1) { a[k] = i; b[k] = j; k++; } } } for (int i = 0; i < ans; i++) cout << a[i] << " " << b[i] << endl; }
#include <iostream> using namespace std; int main() { int n; cin >> n; int ans = n * (n - 1) / 2 - n / 2; cout << ans << endl; int a[ans], b[ans]; int k = 0; for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) { if (i + j != n / 2 * 2 + 1) { a[k] = i; b[k] = j; k++; } } } for (int i = 0; i < ans; i++) cout << a[i] << " " << b[i] << endl; }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change" ]
904,492
904,493
u179970156
cpp
p03090
#include <iostream> using namespace std; int main() { int n; cin >> n; int ans = n * (n - 1) / 2 - n / 2; cout << ans << endl; int a[ans], b[ans]; int k = 0; for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) { if (i + j != n) { a[k] = i; b[k] = j; k++; } } } for (int i = 0; i < ans; i++) cout << a[i] << " " << b[i] << endl; }
#include <iostream> using namespace std; int main() { int n; cin >> n; int ans = n * (n - 1) / 2 - n / 2; cout << ans << endl; int a[ans], b[ans]; int k = 0; for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) { if (i + j != n / 2 * 2 + 1) { a[k] = i; b[k] = j; k++; } } } for (int i = 0; i < ans; i++) cout << a[i] << " " << b[i] << endl; }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change" ]
904,494
904,493
u179970156
cpp
p03090
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <vector> using namespace std; typedef long long ll; const int N = 100 + 10; int n, cnt; int main() { // freopen("a.in","r",stdin); cin >> n; for (int i = 1; i <= n; i++) for (int j = i + 1; j <= n; j++) if (i + j != (n & 1) + n) cnt++; cout << cnt << endl; for (int i = 1; i <= n; i++) for (int j = i + 1; j <= n; j++) if (i + j != (!(n & 1)) + n) printf("%d %d\n", i, j); }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <vector> using namespace std; typedef long long ll; const int N = 100 + 10; int n, cnt; int main() { // freopen("a.in","r",stdin); cin >> n; for (int i = 1; i <= n; i++) for (int j = i + 1; j <= n; j++) if (i + j != (!(n & 1)) + n) cnt++; cout << cnt << endl; for (int i = 1; i <= n; i++) for (int j = i + 1; j <= n; j++) if (i + j != (!(n & 1)) + n) printf("%d %d\n", i, j); }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change" ]
904,495
904,496
u076546810
cpp
p03090
#include <algorithm> #include <cstdio> #include <cstring> const int maxn = 100 + 3; inline int getint() { bool flag = 0; register int n = 0; register char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') flag = 1; ch = getchar(); } while (ch >= '0' && ch <= '9') { n = ch - '0' + (n << 3) + (n << 1); ch = getchar(); } return flag ? (-n) : n; } int n; int cnt; bool des[maxn][maxn]; int main() { #ifdef Ezio freopen("input", "r", stdin); #endif n = getint(); if (n & 1) for (int i = 1; i <= (n >> 1); i++) des[i][n - i] = 1, cnt++; else for (int i = 1; i <= (n >> 1); i++) des[i][n + 1 - i] = 1, cnt++; printf("%d\n", n * (n + 1) / 2 - cnt); for (int i = 1; i <= n; i++) for (int j = i + 1; j <= n; j++) if (des[i][j] == 0) printf("%d %d\n", i, j); return 0; }
#include <algorithm> #include <cstdio> #include <cstring> const int maxn = 100 + 3; inline int getint() { bool flag = 0; register int n = 0; register char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') flag = 1; ch = getchar(); } while (ch >= '0' && ch <= '9') { n = ch - '0' + (n << 3) + (n << 1); ch = getchar(); } return flag ? (-n) : n; } int n; int cnt; bool des[maxn][maxn]; int main() { #ifdef Ezio freopen("input", "r", stdin); #endif n = getint(); if (n & 1) for (int i = 1; i <= (n >> 1); i++) des[i][n - i] = 1, cnt++; else for (int i = 1; i <= (n >> 1); i++) des[i][n + 1 - i] = 1, cnt++; printf("%d\n", n * (n - 1) / 2 - cnt); for (int i = 1; i <= n; i++) for (int j = i + 1; j <= n; j++) if (des[i][j] == 0) printf("%d %d\n", i, j); return 0; }
[ "misc.opposites", "expression.operator.arithmetic.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
904,505
904,506
u424325979
cpp
p03090
// g++ -std=c++11 a.cpp #include <algorithm> #include <assert.h> #include <bitset> #include <cmath> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <string> #include <typeinfo> #include <unordered_map> #include <utility> #include <vector> #define loop(i, a, b) for (int i = a; i < b; i++) #define rep(i, a) loop(i, 0, a) #define FOR(i, a) for (auto i : a) #define pb push_back #define all(in) in.begin(), in.end() #define shosu(x) fixed << setprecision(x) #define show1d(v) \ { \ rep(_, v.size()) cout << " " << v[_]; \ puts(""); \ } #define show2d(v) \ { rep(__, v.size()) show1d(v[__]); } using namespace std; // kaewasuretyuui typedef long long ll; // #define int ll typedef int Def; typedef pair<Def, Def> pii; typedef vector<Def> vi; typedef vector<vi> vvi; typedef vector<pii> vp; typedef vector<vp> vvp; typedef vector<string> vs; typedef vector<double> vd; typedef vector<vd> vvd; typedef pair<Def, pii> pip; typedef vector<pip> vip; #define mt make_tuple typedef tuple<int, int, int, int> tp; typedef vector<tp> vt; template <typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; } template <typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; } // template<class C>constexpr int size(const C &c){return (int)c.size();} // template<class T,size_t N> constexpr int size(const T // (&xs)[N])noexcept{return (int)N;} const double PI = acos(-1); const double EPS = 1e-9; Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9 + 10; // int dx[]={0,1,0,-1}; // int dy[]={1,0,-1,0};//RDLU #define yes puts("YES") #define no puts("NO") signed main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vvi out; rep(i, n) rep(j, i) { if (i + j + 2 == n - (n + 1) % 2) continue; out.pb({j + 1, i + 1}); } cout << out.size() << endl; for (auto a : out) cout << a[0] << " " << a[1] << endl; }
// g++ -std=c++11 a.cpp #include <algorithm> #include <assert.h> #include <bitset> #include <cmath> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <string> #include <typeinfo> #include <unordered_map> #include <utility> #include <vector> #define loop(i, a, b) for (int i = a; i < b; i++) #define rep(i, a) loop(i, 0, a) #define FOR(i, a) for (auto i : a) #define pb push_back #define all(in) in.begin(), in.end() #define shosu(x) fixed << setprecision(x) #define show1d(v) \ { \ rep(_, v.size()) cout << " " << v[_]; \ puts(""); \ } #define show2d(v) \ { rep(__, v.size()) show1d(v[__]); } using namespace std; // kaewasuretyuui typedef long long ll; // #define int ll typedef int Def; typedef pair<Def, Def> pii; typedef vector<Def> vi; typedef vector<vi> vvi; typedef vector<pii> vp; typedef vector<vp> vvp; typedef vector<string> vs; typedef vector<double> vd; typedef vector<vd> vvd; typedef pair<Def, pii> pip; typedef vector<pip> vip; #define mt make_tuple typedef tuple<int, int, int, int> tp; typedef vector<tp> vt; template <typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; } template <typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; } // template<class C>constexpr int size(const C &c){return (int)c.size();} // template<class T,size_t N> constexpr int size(const T // (&xs)[N])noexcept{return (int)N;} const double PI = acos(-1); const double EPS = 1e-9; Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9 + 10; // int dx[]={0,1,0,-1}; // int dy[]={1,0,-1,0};//RDLU #define yes puts("YES") #define no puts("NO") signed main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vvi out; rep(i, n) rep(j, i) { if (i + j + 2 == n + (n + 1) % 2) continue; out.pb({j + 1, i + 1}); } cout << out.size() << endl; for (auto a : out) cout << a[0] << " " << a[1] << endl; }
[ "misc.opposites", "expression.operator.arithmetic.change", "control_flow.branch.if.condition.change" ]
904,514
904,515
u010004797
cpp
p03090
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<vector<bool>> edges(n + 1, vector<bool>(n + 1)); int num = 0; for (int i = 1; i <= n; ++i) { for (int j = i + 1; j <= n; ++j) { edges[i][j] = true; ++num; } } if (n % 2 == 0) { for (int i = 1; i < n - i; ++i) { edges[i][n - i] = false; --num; } } else { for (int i = 1; i < n - i + 1; ++i) { edges[i][n - i + 1] = false; --num; } } cout << num << '\n'; for (int i = 1; i <= n; ++i) { for (int j = i + 1; j <= n; ++j) { if (edges[i][j]) { cout << i << ' ' << j << '\n'; } } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<vector<bool>> edges(n + 1, vector<bool>(n + 1)); int num = 0; for (int i = 1; i <= n; ++i) { for (int j = i + 1; j <= n; ++j) { edges[i][j] = true; ++num; } } if (n % 2 == 1) { for (int i = 1; i < n - i; ++i) { edges[i][n - i] = false; --num; } } else { for (int i = 1; i < n - i + 1; ++i) { edges[i][n - i + 1] = false; --num; } } cout << num << '\n'; for (int i = 1; i <= n; ++i) { for (int j = i + 1; j <= n; ++j) { if (edges[i][j]) { cout << i << ' ' << j << '\n'; } } } return 0; }
[ "literal.number.change", "control_flow.branch.if.condition.change" ]
904,516
904,517
u855388123
cpp
p03090
#include <bits/stdc++.h> using namespace std; int a[10005], b[10005], cnt; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) for (int j = i + 1; j <= n; j++) { if ((n & 1) && j != n + 1 - i || ((n & 1) ^ 1) && j != n - i) a[++cnt] = i, b[cnt] = j; } cout << cnt << endl; for (int i = 1; i <= cnt; i++) cout << a[i] << ' ' << b[i] << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int a[10005], b[10005], cnt; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) for (int j = i + 1; j <= n; j++) { if ((n & 1) && j != n - i || ((n & 1) ^ 1) && j != n + 1 - i) a[++cnt] = i, b[cnt] = j; } cout << cnt << endl; for (int i = 1; i <= cnt; i++) cout << a[i] << ' ' << b[i] << endl; return 0; }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.remove", "control_flow.branch.if.condition.change", "misc.off_by_one" ]
904,524
904,525
u088346989
cpp
p03090
#include <cstdio> #include <vector> using namespace std; int main() { int n; scanf("%d", &n); printf("%d\n", n * (n - 1) / 2 - n / 2); for (int i = 1; i < n; ++i) for (int j = i + 1; j <= n; ++j) if (i + j != n + 1) printf("%d %d\n", i, j); return 0; }
#include <cstdio> #include <vector> using namespace std; int main() { int n; scanf("%d", &n); printf("%d\n", n * (n - 1) / 2 - n / 2); for (int i = 1; i < n; ++i) for (int j = i + 1; j <= n; ++j) if (i + j != n + 1 - n % 2) printf("%d %d\n", i, j); return 0; }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change" ]
904,526
904,527
u359025499
cpp
p03090
#include <cstdio> #include <vector> using namespace std; int main() { int n; scanf("%d", &n); printf("%d\n", n * (n - 1) / 2 - 2); for (int i = 1; i < n; ++i) for (int j = i + 1; j <= n; ++j) if (i + j != n + 1) printf("%d %d\n", i, j); return 0; }
#include <cstdio> #include <vector> using namespace std; int main() { int n; scanf("%d", &n); printf("%d\n", n * (n - 1) / 2 - n / 2); for (int i = 1; i < n; ++i) for (int j = i + 1; j <= n; ++j) if (i + j != n + 1 - n % 2) printf("%d %d\n", i, j); return 0; }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change" ]
904,528
904,527
u359025499
cpp
p03090
#include <bits/stdc++.h> using namespace std; int n; set<pair<int, int>> s; int main() { ios::sync_with_stdio(false); cin >> n; if (n & 1) { for (int i = 1; i < n; i++) { int x = i; int y = n - i; if (x > y) swap(x, y); s.insert(make_pair(x, y)); } } else { for (int i = 1; i <= n; i++) { int x = i; int y = n - i; if (x > y) swap(x, y); s.insert(make_pair(x, y)); } } cout << n * (n - 1) / 2 - (int)s.size() << endl; for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) { if (s.find(make_pair(i, j)) == s.end()) { cout << i << " " << j << endl; } } } return 0; }
#include <bits/stdc++.h> using namespace std; int n; set<pair<int, int>> s; int main() { ios::sync_with_stdio(false); cin >> n; if (n & 1) { for (int i = 1; i < n; i++) { int x = i; int y = n - i; if (x > y) swap(x, y); s.insert(make_pair(x, y)); } } else { for (int i = 1; i <= n; i++) { int x = i; int y = n - i + 1; if (x > y) swap(x, y); s.insert(make_pair(x, y)); } } cout << n * (n - 1) / 2 - (int)s.size() << endl; for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) { if (s.find(make_pair(i, j)) == s.end()) { cout << i << " " << j << endl; } } } return 0; }
[ "assignment.change" ]
904,529
904,530
u353573192
cpp
p03090
#include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> g(n); if (n % 2 == 0) { for (int i = 0; i < n / 2; ++i) { g[i] = i; g[n - i - 1] = i; } } else { for (int i = 0; i < n / 2; ++i) { g[i] = i; g[n - i - 2] = i; } g[n - 1] = n / 2; } vector<pair<int, int>> e; for (int i = 0; i < n; ++i) { for (int j = i + 1; j < n; ++j) { if (g[i] != g[j]) { e.push_back(make_pair(i, j)); } } } cout << e.size() << endl; for (pair<int, int> i : e) { cout << i.first << ' ' << i.second << endl; } return 0; }
#include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> g(n); if (n % 2 == 0) { for (int i = 0; i < n / 2; ++i) { g[i] = i; g[n - i - 1] = i; } } else { for (int i = 0; i < n / 2; ++i) { g[i] = i; g[n - i - 2] = i; } g[n - 1] = n / 2; } vector<pair<int, int>> e; for (int i = 0; i < n; ++i) { for (int j = i + 1; j < n; ++j) { if (g[i] != g[j]) { e.push_back(make_pair(i, j)); } } } cout << e.size() << endl; for (pair<int, int> i : e) { cout << i.first + 1 << ' ' << i.second + 1 << endl; } return 0; }
[ "expression.operation.binary.add" ]
904,533
904,534
u837745858
cpp
p03090
#include <algorithm> #include <iostream> #include <list> #include <numeric> #include <queue> #include <string> #include <vector> using namespace std; #define REP(i, a, n) for (int i = ((int)a); i < ((int)n); i++) #define lli long long int #define MAX 100000000 #define DEBUG int dx[] = {0, 0, 1, -1}; int dy[] = {1, -1, 0, 0}; int N; vector<pair<int, int>> ans; void read() { cin >> N; } void solve() { REP(i, 1, N + 1) REP(j, i + 1, N + 1) { if ((i + j) != (N + 1 - (N & 1))) { ans.push_back(make_pair(i, j)); } } } void print() { cout << ans.size() << endl; for (auto &&i : ans) { cout << i.first << " " << i.second << endl; } } int main() { #ifdef DEBUG cout << "DEBUG MODE" << endl; #else cin.tie(0); cout.tie(0); ios::sync_with_stdio(false); #endif read(); solve(); print(); return 0; } /* 注意すべき点 グローバル以外の配列は初期化すべし */
#include <algorithm> #include <iostream> #include <list> #include <numeric> #include <queue> #include <string> #include <vector> using namespace std; #define REP(i, a, n) for (int i = ((int)a); i < ((int)n); i++) #define lli long long int #define MAX 100000000 //#define DEBUG int dx[] = {0, 0, 1, -1}; int dy[] = {1, -1, 0, 0}; int N; vector<pair<int, int>> ans; void read() { cin >> N; } void solve() { REP(i, 1, N + 1) REP(j, i + 1, N + 1) { if ((i + j) != (N + 1 - (N & 1))) { ans.push_back(make_pair(i, j)); } } } void print() { cout << ans.size() << endl; for (auto &&i : ans) { cout << i.first << " " << i.second << endl; } } int main() { #ifdef DEBUG cout << "DEBUG MODE" << endl; #else cin.tie(0); cout.tie(0); ios::sync_with_stdio(false); #endif read(); solve(); print(); return 0; } /* 注意すべき点 グローバル以外の配列は初期化すべし */
[]
904,535
904,536
u992432716
cpp
p03090
#include <bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #define mp make_pair #define pb push_back #define eb emplace_back #define xx first.first #define yy first.second #define __V vector #define all(x) x.begin(), x.end() #define mod 998244353ll // using namespace __gnu_pbds; using namespace std; void doin() { cin.tie(); cout.tie(); ios::sync_with_stdio(0); //#ifdef LOCAL // freopen("input.txt", "r", stdin); //#endif } //-1 -1 1 3 -1 typedef long long ll; typedef double ld; typedef pair<ll, ll> pi; typedef pair<ld, ld> pd; typedef map<int, int> mii; typedef __V<ll> vi; typedef __V<pi> vpi; typedef __V<pi> vvi; typedef __V<__V<pi>> vvpi; int n; vpi ans; bool can(int i, int j) { if ((i + j) == (n + 1)) return false; return true; } int main() { doin(); cin >> n; for (int i = 1; i <= n; i++) for (int j = i + 1; j <= n; j++) if (can(i, j)) ans.pb({i, j}); cout << ans.size() << "\n"; for (auto &i : ans) cout << i.first << " " << i.second << "\n"; }
#include <bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #define mp make_pair #define pb push_back #define eb emplace_back #define xx first.first #define yy first.second #define __V vector #define all(x) x.begin(), x.end() #define mod 998244353ll // using namespace __gnu_pbds; using namespace std; void doin() { cin.tie(); cout.tie(); ios::sync_with_stdio(0); //#ifdef LOCAL // freopen("input.txt", "r", stdin); //#endif } //-1 -1 1 3 -1 typedef long long ll; typedef double ld; typedef pair<ll, ll> pi; typedef pair<ld, ld> pd; typedef map<int, int> mii; typedef __V<ll> vi; typedef __V<pi> vpi; typedef __V<pi> vvi; typedef __V<__V<pi>> vvpi; int n; vpi ans; bool can(int i, int j) { if ((i + j) == (n + 1 - (n & 1))) return false; return true; } int main() { doin(); cin >> n; for (int i = 1; i <= n; i++) for (int j = i + 1; j <= n; j++) if (can(i, j)) ans.pb({i, j}); cout << ans.size() << "\n"; for (auto &i : ans) cout << i.first << " " << i.second << "\n"; }
[ "control_flow.branch.if.condition.change" ]
904,537
904,538
u084411645
cpp
p03090
#include <algorithm> #include <complex> #include <ctype.h> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string> #include <vector> using namespace std; typedef long long ll; #define FOR(i, a, b) for (ll i = (a); i < (b); ++i) #define ALL(v) (v).begin(), (v).end() #define p(s) cout << (s) << endl #define p2(s, t) cout << (s) << " " << (t) << endl #define br() p("") #define pn(s) cout << (#s) << " " << (s) << endl #define p_yes() p("Yes") #define p_no() p("No") const ll mod = 1e9 + 7; const ll inf = 1e18; template <typename T> void vprint(T &V) { for (auto v : V) { cout << v << " "; } cout << endl; } struct Edge { ll a; ll b; Edge(ll _a, ll _b) { a = _a; b = _b; } }; int main() { cin.tie(0); ios::sync_with_stdio(false); // input ll N; cin >> N; vector<Edge> answer; if (N % 2 == 1) { FOR(i, 1, N + 1) { FOR(j, i + 1, N + 1) { if (i + j != N) { answer.push_back(Edge(i, j)); } } } } else { FOR(i, 1, N + 1) { FOR(j, i + 1, N + 1) { if (i + 1 != N + 1) { answer.push_back(Edge(i, j)); } } } } p(answer.size()); for (auto edge : answer) { cout << edge.a << " " << edge.b << endl; } return 0; }
#include <algorithm> #include <complex> #include <ctype.h> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string> #include <vector> using namespace std; typedef long long ll; #define FOR(i, a, b) for (ll i = (a); i < (b); ++i) #define ALL(v) (v).begin(), (v).end() #define p(s) cout << (s) << endl #define p2(s, t) cout << (s) << " " << (t) << endl #define br() p("") #define pn(s) cout << (#s) << " " << (s) << endl #define p_yes() p("Yes") #define p_no() p("No") const ll mod = 1e9 + 7; const ll inf = 1e18; template <typename T> void vprint(T &V) { for (auto v : V) { cout << v << " "; } cout << endl; } struct Edge { ll a; ll b; Edge(ll _a, ll _b) { a = _a; b = _b; } }; int main() { cin.tie(0); ios::sync_with_stdio(false); // input ll N; cin >> N; vector<Edge> answer; if (N % 2 == 1) { FOR(i, 1, N + 1) { FOR(j, i + 1, N + 1) { if (i + j != N) { answer.push_back(Edge(i, j)); } } } } else { FOR(i, 1, N + 1) { FOR(j, i + 1, N + 1) { if (i + j != N + 1) { answer.push_back(Edge(i, j)); } } } } p(answer.size()); for (auto edge : answer) { cout << edge.a << " " << edge.b << endl; } return 0; }
[ "identifier.replace.add", "literal.replace.remove", "control_flow.branch.if.condition.change" ]
904,541
904,542
u432688695
cpp
p03090
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; long long d = n / 2 * 2; vector<pair<long long, long long>> vp; for (long long i = 0; i < n; i++) { for (long long j = i + 1; j < n; j++) { if (i + j == d + 1) continue; vp.push_back(make_pair(i, j)); } } cout << vp.size() << '\n'; for (auto e : vp) cout << e.first << " " << e.second << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; long long d = n / 2 * 2; vector<pair<long long, long long>> vp; for (long long i = 0; i < n; i++) { for (long long j = i + 1; j < n; j++) { if (i + j + 2 == d + 1) continue; vp.push_back(make_pair(i, j)); } } cout << vp.size() << '\n'; for (auto e : vp) cout << e.first + 1 << " " << e.second + 1 << '\n'; return 0; }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change" ]
904,543
904,544
u717021668
cpp
p03089
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> b(N); for (int i = 0; i < N; i++) { cin >> b[i]; } bool can = true; vector<int> ans(N); while (b.size() > 0) { int tmpb = 0; int tmp = 100000; for (int i = 0; i < b.size(); i++) { if (i + 1 == b[i]) { tmpb = b[i]; tmp = i; } } if (tmp == 100000) { can = false; break; } ans.push_back(tmpb); b.erase(b.begin() + tmp); } if (can) { for (int i = N - 1; i >= 0; i--) { cout << ans[i] << endl; } } else cout << -1 << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> b(N); for (int i = 0; i < N; i++) { cin >> b[i]; } bool can = true; vector<int> ans; while (b.size() > 0) { int tmpb = 0; int tmp = 100000; for (int i = 0; i < b.size(); i++) { if (i + 1 == b[i]) { tmpb = b[i]; tmp = i; } } if (tmp == 100000) { can = false; break; } ans.push_back(tmpb); b.erase(b.begin() + tmp); } if (can) { for (int i = N - 1; i >= 0; i--) { cout << ans[i] << endl; } } else cout << -1 << endl; }
[]
904,549
904,550
u665871498
cpp
p03089
#include <bits/stdc++.h> typedef long long ll; using namespace std; #define all(a) (a).begin(), (a).end() #define rep(i, j) for (ll i = 0; i < j; i++) #define repf(i, m, j) for (ll i = m; i < j; i++) #define pb push_back #define sort(a) sort(all(a)) int main() { vector<int> a(100); vector<int> b(100); ll N; ll num; cin >> N; rep(i, N) cin >> b.at(i); rep(i, N) { if (i + 1 >= b.at(1)) a.insert(a.begin() + b.at(i) - 1, b.at(i)); else { cout << -1 << endl; return EXIT_SUCCESS; } } rep(i, N) cout << a.at(i) << endl; }
#include <bits/stdc++.h> typedef long long ll; using namespace std; #define all(a) (a).begin(), (a).end() #define rep(i, j) for (ll i = 0; i < j; i++) #define repf(i, m, j) for (ll i = m; i < j; i++) #define pb push_back #define sort(a) sort(all(a)) int main() { vector<int> a(100); vector<int> b(100); ll N; ll num; cin >> N; rep(i, N) cin >> b.at(i); rep(i, N) { if (i + 1 >= b.at(i)) a.insert(a.begin() + (b.at(i) - 1), b.at(i)); else { cout << -1 << endl; return EXIT_SUCCESS; } } rep(i, N) cout << a.at(i) << endl; }
[ "identifier.replace.add", "literal.replace.remove", "control_flow.branch.if.condition.change", "call.arguments.change" ]
904,551
904,552
u530497183
cpp
p03089
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; typedef pair<int, int> P; int main() { int n; cin >> n; vector<int> b(n); rep(i, n) cin >> b[i]; vector<int> v; while (!b.empty()) { bool ok = false; for (int i = b.size() - 1; i >= 0; i--) { if (b[i] == i + 1) { ok = true; v.push_back(b[i]); b.erase(b.begin() + i); break; } } if (!ok) { puts("=1"); return 0; } } reverse(v.begin(), v.end()); for (int i : v) { cout << i << endl; } }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; typedef pair<int, int> P; int main() { int n; cin >> n; vector<int> b(n); rep(i, n) cin >> b[i]; vector<int> v; while (!b.empty()) { bool ok = false; for (int i = b.size() - 1; i >= 0; i--) { if (b[i] == i + 1) { ok = true; v.push_back(b[i]); b.erase(b.begin() + i); break; } } if (!ok) { puts("-1"); return 0; } } reverse(v.begin(), v.end()); for (int i : v) { cout << i << endl; } }
[ "literal.string.change", "call.arguments.change", "io.output.change" ]
904,559
904,560
u781091740
cpp
p03089
#include <algorithm> #include <bitset> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define rep(i, n) repr(i, 0, n) #define INF 2e9 #define MOD 1000000007 #define LINF (long long)4e18 using ll = long long; int main() { int N; cin >> N; vector<int> b(N); rep(i, N) { cin >> b[i]; if (b[i] > i + 1) { cout << -1 << endl; return 0; } } vector<int> ans; rep(i, N) { for (int j = N - 1; j >= 0; j--) { if (b[j] == j + 1) { ans.push_back(b[j]); b.erase(b.begin() + j); break; } } } for (int i = N - 1; i >= 0; i--) { cout << ans[i] << endl; } }
#include <algorithm> #include <bitset> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define rep(i, n) repr(i, 0, n) #define INF 2e9 #define MOD 1000000007 #define LINF (long long)4e18 using ll = long long; int main() { int N; cin >> N; vector<int> b(N); rep(i, N) { cin >> b[i]; if (b[i] > i + 1) { cout << -1 << endl; return 0; } } vector<int> ans; rep(i, N) { for (int j = b.size() - 1; j >= 0; j--) { if (b[j] == j + 1) { ans.push_back(b[j]); b.erase(b.begin() + j); break; } } } for (int i = N - 1; i >= 0; i--) { cout << ans[i] << endl; } }
[ "control_flow.loop.for.initializer.change", "expression.operation.binary.change", "call.add" ]
904,561
904,562
u314008046
cpp