| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1369682 | dragonlyz123 | A String Problem (EGOI25_stringproblem) | C++20 | 44 ms | 16420 KiB |
/*
─────────────────────────────────────────────────────────────────────────────────────
██╗ ███████╗███████╗ ██╗ ██╗███████╗███╗ ██╗ ███████╗███████╗███████╗
██║ ██╔════╝██╔════╝ ╚██╗ ██╔╝██╔══██╗████╗ ██║ ╚══███╔╝██╔════╝██╔════╝
██║ █████╗ █████╗ ╚████╔╝ ███████║██╔██╗ ██║ ███╔╝ █████╗ █████╗
██║ ██╔══╝ ██╔══╝ ╚██╔╝ ██╔══██║██║╚██╗██║ ███╔╝ ██╔══╝ ██╔══╝
███████╗███████╗███████╗ ██║ ██║ ██║██║ ╚████║ ███████╗███████╗███████╗
╚══════╝╚══════╝╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═══╝ ╚══════╝╚══════╝╚══════╝
─────────────────────────────────────────────────────────────────────────────────────
» Stay hungry, stay foolish. «
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
ll ll_max = 2e18;
ll ll_min = -2e18;
void set_io(string name = "") {
ios_base::sync_with_stdio(0);
cin.tie(0);
if (!name.empty()) {
freopen((name + ".in").c_str(), "r", stdin);
freopen((name + ".out").c_str(), "w", stdout);
}
}
void solve() {
ll n; cin >> n;
vector<vector<ll>> ab(n, vector<ll>(3));
ll d = -1, e = -1;
map<ll, ll> c;
ll j = n - 1;
for (ll i = 0; i < n; i++) {
cin >> ab[i][0] >> ab[i][1];
if ((ab[i][1] - ab[i][0]) % 2 != 0) {
ab[i][2] = (ab[i][0] + ab[i][1] - j + 2 * n) % (2 * n);
c[ab[i][2]]++;
if (c[ab[i][2]] > e) {
d = ab[i][2];
e = c[ab[i][2]];
}
} else {
ab[i][2] = -1;
}
}
if (d == -1 && e == -1) {
d = n;
e = 0;
}
vector<bool> vis(2 * n);
vector<vector<ll>> ans;
for (ll i = 0; i < n; i++) {
ll g = ab[i][0], h = ab[i][1];
if (g > h) swap(g, h);
if (vis[g]) swap(g, h);
if (ab[i][2] != d) {
ll k = (d - g + j + 2 * n) % (2 * n);
vector<ll> m = {i, h, k};
ans.emplace_back(m);
vis[g] = true;
vis[k] = true;
} else {
vis[g] = true;
vis[h] = true;
}
}
cout << ans.size() << "\n";
for (vector<ll> l : ans) {
cout << l[0] << " " << l[1] << " " << l[2] << "\n";
}
}
int main() {
set_io();
// ll t; cin >> t;
// while (t--) {
// solve();
// }
solve();
return 0;
}
// g++-15 -std=c++23 -O2 solution.cpp -o solution
// ./solution
컴파일 시 표준 에러 (stderr) 메시지
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
