結果
問題 | No.1999 Lattice Teleportation |
ユーザー | cologne |
提出日時 | 2022-03-22 18:23:59 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 3,188 bytes |
コンパイル時間 | 1,901 ms |
コンパイル使用メモリ | 117,120 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-08 11:08:41 |
合計ジャッジ時間 | 8,033 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | RE | - |
testcase_01 | RE | - |
testcase_02 | RE | - |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | RE | - |
testcase_19 | RE | - |
testcase_20 | RE | - |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | RE | - |
testcase_24 | RE | - |
testcase_25 | RE | - |
testcase_26 | RE | - |
testcase_27 | RE | - |
testcase_28 | RE | - |
testcase_29 | RE | - |
testcase_30 | RE | - |
testcase_31 | RE | - |
testcase_32 | RE | - |
ソースコード
#pragma GCC optimize("Ofast") #pragma GCC target("avx2,bmi2,popcnt,lzcnt") #include <cassert> #include <cstdio> #include <cinttypes> #include <unistd.h> #include <sys/stat.h> #include <sys/mman.h> class strictInput { char *p; off_t cur = 0; off_t len = 0; public: explicit strictInput(int fd = 0) { struct stat st; len = fstat(fd, &st); p = (char *)mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0); } char readChar() { assert(cur != len); return p[cur++]; } void unreadChar() { assert(cur != 0); --cur; } bool isEOF() { return cur == len; } void readEOF() { assert(isEOF()); } void readSpace() { assert(readChar() == ' '); } void readEoln() { assert(readChar() == '\n'); } // reads uint64_t in range [from, to] uint64_t readU64(uint64_t from = 0, uint64_t to = UINT64_MAX) { uint64_t cur = 0; off_t read_cnt = 0; bool leading_zero = false; while (!isEOF()) { char p = readChar(); if (!('0' <= p && p <= '9')) { unreadChar(); break; } uint64_t v = p - '0'; assert(cur <= UINT64_MAX / 10); cur *= 10; assert(cur <= UINT64_MAX - v); cur += v; if (read_cnt == 0 && v == 0) leading_zero = true; ++read_cnt; } if (cur == 0) assert(read_cnt == 1); else assert(!leading_zero); assert(from <= cur && cur <= to); return cur; } // reads int64_t in range [from, to] int64_t readI64(int64_t from = INT64_MIN, int64_t to = INT64_MAX) { uint64_t cur = 0; off_t read_cnt = 0; bool leading_zero = false; bool leading_minus = readChar() == '-'; if (!leading_minus) unreadChar(); while (!isEOF()) { char p = readChar(); if (!('0' <= p && p <= '9')) { unreadChar(); break; } uint64_t v = p - '0'; assert(cur <= UINT64_MAX / 10); cur *= 10; assert(cur <= UINT64_MAX - v); cur += v; if (read_cnt == 0 && v == 0) leading_zero = true; ++read_cnt; } if (cur == 0) assert(read_cnt == 1 && !leading_minus); else assert(!leading_zero); if (cur <= INT64_MAX) { int64_t ret = cur; if (leading_minus) ret = -ret; assert(from <= ret && ret <= to); return ret; } else { assert(leading_minus && cur == INT64_MIN); assert(from == INT64_MIN); return INT64_MIN; } } }; #include <algorithm> #include <iostream> #include <numeric> #include <tuple> #include <vector> using namespace std; int main() { strictInput Inp; int N; N = Inp.readI64(1, 100'000); Inp.readEoln(); vector<pair<int, int>> V; for (int i = 0; i < N; ++i) { int a, b; a = Inp.readI64(-1'000'000'000, 1'000'000'000); Inp.readSpace(); b = Inp.readI64(-1'000'000'000, 1'000'000'000); Inp.readEoln(); if (a == 0 && b == 0) continue; if (a < 0) a = -a, b = -b; V.emplace_back(a, b); } Inp.readEOF(); sort(V.begin(), V.end(), [&](auto a, auto b) { return (long long)a.first * b.second > (long long)b.first * a.second; }); long long x = 0, y = 0; __int128 ans = 1; for (auto [dx, dy] : V) { ans += (__int128)x * dy - (__int128)y * dx; ans += gcd(dx, dy); x += dx; y += dy; } const int MOD = 1'000'000'007; int ret = ans % MOD; if (ret < 0) ret += MOD; cout << ret << endl; }