結果
問題 | No.896 友達以上恋人未満 |
ユーザー | 👑 emthrm |
提出日時 | 2020-08-09 01:41:36 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 2,286 ms / 3,500 ms |
コード長 | 2,807 bytes |
コンパイル時間 | 2,225 ms |
コンパイル使用メモリ | 207,316 KB |
実行使用メモリ | 134,356 KB |
最終ジャッジ日時 | 2024-10-02 12:38:11 |
合計ジャッジ時間 | 10,238 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,816 KB |
testcase_02 | AC | 2 ms
6,820 KB |
testcase_03 | AC | 2 ms
6,820 KB |
testcase_04 | AC | 2 ms
6,816 KB |
testcase_05 | AC | 755 ms
36,080 KB |
testcase_06 | AC | 1,111 ms
35,956 KB |
testcase_07 | AC | 762 ms
36,044 KB |
testcase_08 | AC | 776 ms
36,000 KB |
testcase_09 | AC | 1,425 ms
68,788 KB |
testcase_10 | AC | 2,286 ms
134,356 KB |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:38:12: warning: 'x' may be used uninitialized [-Wmaybe-uninitialized] 38 | x = (x * mulX + addX) & mod_1; | ~~^~~~~~ main.cpp:31:6: note: 'x' was declared here 31 | ll x, y; | ^
ソースコード
#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; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fLL; const double EPS = 1e-8; const int MOD = 1000000007; // const int MOD = 998244353; const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1}; const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, 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() { cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << fixed << setprecision(20); } } iosetup; int main() { int m, n, mulX, addX, mulY, addY, mod; cin >> m >> n >> mulX >> addX >> mulY >> addY >> mod; int mod_1 = mod - 1; vector mp(mod, 0LL); vector<int> X(m); REP(i, m) cin >> X[i]; ll x, y; REP(i, m) { x = X[i]; cin >> y; mp[x] += y; } FOR(i, m, n) { x = (x * mulX + addX) & mod_1; y = (y * mulY + addY) & mod_1; mp[x] += y; } ll ans = 0; int cri = sqrt(mod); vector memo(cri, -1LL); REP(i, m) cin >> X[i]; REP(i, m) { x = X[i]; cin >> y; if (x == 0 || y == 0) { cout << 0 << '\n'; continue; } ll cnt = 0; if (x >= cri) { for (int i = x; i < mod; i += x) cnt += mp[i]; } else { if (memo[x] == -1) { memo[x] = 0; for (int i = x; i < mod; i += x) memo[x] += mp[i]; } cnt += memo[x]; } if (x * y < mod) { int mul = x * y; if (mul >= cri) { for (int i = mul; i < mod; i += mul) cnt -= mp[i]; } else { if (memo[mul] == -1) { memo[mul] = 0; for (int i = mul; i < mod; i += mul) memo[mul] += mp[i]; } cnt -= memo[mul]; } } cout << cnt << '\n'; ans ^= cnt; } FOR(i, m, n) { x = ((x * mulX + addX + mod_1) & mod_1) + 1; y = ((y * mulY + addY + mod_1) & mod_1) + 1; if (x == 0 || y == 0) continue; ll cnt = 0; if (x >= cri) { for (int i = x; i < mod; i += x) cnt += mp[i]; } else { if (memo[x] == -1) { memo[x] = 0; for (int i = x; i < mod; i += x) memo[x] += mp[i]; } cnt += memo[x]; } if (x * y < mod) { int mul = x * y; if (mul >= cri) { for (int i = mul; i < mod; i += mul) cnt -= mp[i]; } else { if (memo[mul] == -1) { memo[mul] = 0; for (int i = mul; i < mod; i += mul) memo[mul] += mp[i]; } cnt -= memo[mul]; } } ans ^= cnt; } cout << ans << '\n'; return 0; }