結果
問題 | No.2207 pCr検査 |
ユーザー | 👑 emthrm |
提出日時 | 2023-02-04 14:12:34 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 2,551 bytes |
コンパイル時間 | 3,323 ms |
コンパイル使用メモリ | 249,872 KB |
実行使用メモリ | 124,008 KB |
最終ジャッジ日時 | 2023-09-16 11:01:16 |
合計ジャッジ時間 | 45,978 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 12 ms
42,484 KB |
testcase_01 | AC | 12 ms
42,484 KB |
testcase_02 | AC | 705 ms
120,752 KB |
testcase_03 | AC | 523 ms
86,176 KB |
testcase_04 | AC | 435 ms
101,036 KB |
testcase_05 | AC | 1,125 ms
116,980 KB |
testcase_06 | AC | 206 ms
112,676 KB |
testcase_07 | AC | 282 ms
85,604 KB |
testcase_08 | AC | 263 ms
66,448 KB |
testcase_09 | AC | 808 ms
99,868 KB |
testcase_10 | AC | 67 ms
85,792 KB |
testcase_11 | AC | 683 ms
98,604 KB |
testcase_12 | AC | 2,433 ms
109,404 KB |
testcase_13 | AC | 1,373 ms
81,112 KB |
testcase_14 | AC | 328 ms
51,952 KB |
testcase_15 | AC | 2,901 ms
120,928 KB |
testcase_16 | AC | 1,247 ms
76,772 KB |
testcase_17 | AC | 2,243 ms
103,160 KB |
testcase_18 | AC | 1,726 ms
90,356 KB |
testcase_19 | AC | 820 ms
66,072 KB |
testcase_20 | AC | 1,468 ms
80,104 KB |
testcase_21 | AC | 2,922 ms
120,736 KB |
testcase_22 | TLE | - |
testcase_23 | TLE | - |
testcase_24 | AC | 472 ms
55,748 KB |
testcase_25 | AC | 1,221 ms
75,728 KB |
testcase_26 | AC | 1,105 ms
73,696 KB |
testcase_27 | AC | 2,255 ms
104,104 KB |
testcase_28 | AC | 1,611 ms
123,084 KB |
testcase_29 | AC | 1,590 ms
122,896 KB |
testcase_30 | AC | 1,608 ms
122,984 KB |
testcase_31 | AC | 1,607 ms
123,624 KB |
ソースコード
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; #define FOR(i,m,n) for(int i=(m);i<(n);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() using ll = long long; constexpr int INF = 0x3f3f3f3f; constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL; constexpr double EPS = 1e-8; constexpr int MOD = 998244353; // constexpr int MOD = 1000000007; constexpr int DY4[]{1, 0, -1, 0}, DX4[]{0, -1, 0, 1}; constexpr int DY8[]{1, 1, 0, -1, -1, -1, 0, 1}; constexpr int DX8[]{0, -1, -1, -1, 0, 1, 1, 1}; template <typename T, typename U> inline bool chmax(T& a, U b) { return a < b ? (a = b, true) : false; } template <typename T, typename U> inline bool chmin(T& a, U b) { return a > b ? (a = b, true) : false; } struct IOSetup { IOSetup() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << fixed << setprecision(20); } } iosetup; std::vector<int> prime_sieve(const int n, const bool get_only_prime) { std::vector<int> smallest_prime_factor(n + 1), prime; std::iota(smallest_prime_factor.begin(), smallest_prime_factor.end(), 0); for (int i = 2; i <= n; ++i) { if (smallest_prime_factor[i] == i) [[unlikely]] prime.emplace_back(i); for (const int p : prime) { if (i * p > n || p > smallest_prime_factor[i]) break; smallest_prime_factor[i * p] = p; } } return get_only_prime ? prime : smallest_prime_factor; } struct OsaK { const std::vector<int> smallest_prime_factor; explicit OsaK(const int n) : smallest_prime_factor(prime_sieve(n, false)) {} std::vector<std::pair<int, int>> query(int n) const { std::vector<std::pair<int, int>> res; while (n > 1) { const int prime = smallest_prime_factor[n]; int exponent = 0; for (; smallest_prime_factor[n] == prime; n /= prime) { ++exponent; } res.emplace_back(prime, exponent); } return res; } }; int main() { constexpr int P = 10000000; int k; cin >> k; int nums[P]{}, p_k = 0, nonzero = 0; while (k--) { int p, e; cin >> p >> e; nums[p] = -e; ++nonzero; chmax(p_k, p); } const OsaK osa_k(p_k); FOR(r, 1, p_k) { for (const auto& [p, e] : osa_k.query(p_k - r + 1)) { if (nums[p] == 0) ++nonzero; if ((nums[p] += e) == 0) --nonzero; } for (const auto& [p, e] : osa_k.query(r)) { if (nums[p] == 0) ++nonzero; if ((nums[p] -= e) == 0) --nonzero; } if (nonzero == 0) { cout << p_k << ' ' << r << '\n'; return 0; } } cout << "-1 -1\n"; return 0; }