結果

問題 No.750 Frac #1
ユーザー Shuz*Shuz*
提出日時 2018-11-09 21:42:48
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,318 bytes
コンパイル時間 1,829 ms
コンパイル使用メモリ 180,980 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-13 11:21:47
合計ジャッジ時間 3,053 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

//#include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// using cint = cpp_int;
//#define input(a) scanf("%lld", &(a))
//#define output(a) printf("%lld\n", (a))

// Define
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ull MAX = ULONG_MAX;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define x first
#define y second
#define endl '\n'
#define space ' '
#define def inline auto
#define func inline constexpr ll
#define run __attribute__((constructor)) def _
#define all(v) begin(v), end(v)

// Debug
#define debug(...)                                                             \
    {                                                                          \
        cerr << __LINE__ << ": " << #__VA_ARGS__ << " = ";                     \
        for (auto &&X : {__VA_ARGS__}) cerr << "[" << X << "] ";               \
        cerr << endl;                                                          \
    }

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i <= _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i >= _##i; --i)
#define each(i, a) for (auto &&i : a)
#define rep(i, n) inc(i, 0, n - 1)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("O3")
#pragma GCC optimization_level 3
#pragma GCC target("avx")

// Math
func gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
func lcm(ll a, ll b) { return a * b / gcd(a, b); }

def input() {
    ll A;
    cin >> A;
    return A;
}

ll N;
vector<pair<ll, ll>> A;
vector<pair<double, ll>> B;
deque<pair<ll, ll>> P, Q;

signed main() {
    cin >> N;
    rep(i, N) A.pb(mp(input(), input()));
    rep(i, N) B.pb(mp(abs(double(A[i].x) / A[i].y), i));
    sort(all(B));
    rep(i, N) {
        if (A[B[i].y].x < 0LL) {
            Q.pb(mp(A[B[i].y].x, A[B[i].y].y));
        } else {
            P.push_front(mp(A[B[i].y].x, A[B[i].y].y));
        }
    }
    for (auto i : P) cout << i.x << ' ' << i.y << endl;
    for (auto i : Q) cout << i.x << ' ' << i.y << endl;
}

// for compilation: g++ -Ofast -march=native -o _ _.cpp -std=c++17
0