제출 #1369675

#제출 시각아이디문제언어결과실행 시간메모리
1369675dragonlyz123A String Problem (EGOI25_stringproblem)C++20
22 / 100
60 ms18188 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<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 (ab[i][2] != d) {
			ll k = (d - g + j + 2 * n) % (2 * n);
			if (k != h) {
				vector<ll> m = {i, h, 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) 메시지

Main.cpp: In function 'void set_io(std::string)':
Main.cpp:26:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |                 freopen((name + ".in").c_str(), "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:27:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |                 freopen((name + ".out").c_str(), "w", stdout);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…