| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1369684 | dragonlyz123 | A String Problem (EGOI25_stringproblem) | C++20 | 14 ms | 9048 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;
vector<pair<ll, ll>> z(2 * n);
for (ll i = 0; i < n; i++) {
cin >> ab[i][0] >> ab[i][1];
z[ab[i][0]].first = ab[i][1];
z[ab[i][1]].first = ab[i][0];
z[ab[i][0]].second = i;
z[ab[i][1]].second = i;
if ((ab[i][1] - ab[i][0]) % 2 != 0) {
ll y = (ab[i][0] + ab[i][1] - j + 2 * n) % (2 * n);
c[y]++;
if (c[y] > e) {
d = y;
e = c[y];
}
}
}
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 k = (d - i + j + 2 * n) % (2 * n);
if (k != z[i].first) {
vector<ll> m = {z[i].second, z[i].first, k};
ans.emplace_back(m);
}
}
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) 메시지
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
