結果
問題 | No.896 友達以上恋人未満 |
ユーザー | lumc_ |
提出日時 | 2019-09-27 22:46:57 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 5,827 bytes |
コンパイル時間 | 1,197 ms |
コンパイル使用メモリ | 113,552 KB |
実行使用メモリ | 108,156 KB |
最終ジャッジ日時 | 2024-09-25 00:04:43 |
合計ジャッジ時間 | 8,738 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 46 ms
68,888 KB |
testcase_01 | AC | 39 ms
68,896 KB |
testcase_02 | AC | 57 ms
68,948 KB |
testcase_03 | AC | 68 ms
68,888 KB |
testcase_04 | AC | 55 ms
68,888 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
ソースコード
// includes {{{ #include<iostream> #include<iomanip> #include<algorithm> #include<vector> #include<stack> #include<queue> #include<map> #include<set> #include<tuple> #include<cmath> #include<random> #include<cassert> #include<bitset> #include<cstdlib> // #include<deque> // #include<multiset> // #include<cstring> // #include<bits/stdc++.h> // }}} using namespace std; using ll = long long; // #undef DEBUG // #define DEBUG // DEBUG {{{ #include <array> #include <deque> #include <iostream> #include <list> #include <queue> #include <stack> #include <tuple> #include <valarray> #include <vector> template < int n, class... T > typename std::enable_if< (n >= sizeof...(T)) >::type __output_tuple( std::ostream &, std::tuple< T... > const &) {} template < int n, class... T > typename std::enable_if< (n < sizeof...(T)) >::type __output_tuple( std::ostream &os, std::tuple< T... > const &t) { os << (n == 0 ? "" : ", ") << std::get< n >(t); __output_tuple< n + 1 >(os, t); } template < class... T > std::ostream &operator<<(std::ostream &os, std::tuple< T... > const &t) { os << "("; __output_tuple< 0 >(os, t); os << ")"; return os; } template < class T, class U > std::ostream &operator<<(std::ostream &os, std::pair< T, U > const &p) { os << "(" << p.first << ", " << p.second << ")"; return os; } template < class T > std::ostream &operator<<(std::ostream &os, const std::stack< T > &a) { os << "{"; for(auto tmp = a; tmp.size(); tmp.pop()) os << (a.size() == tmp.size() ? "" : ", ") << tmp.top(); os << "}"; return os; } template < class T, class Container, class Compare > std::ostream &operator<<(std::ostream &os, std::priority_queue< T, Container, Compare > a) { os << "{ (top) "; while(a.size()) os << a.top() << (a.size() == 1 ? "" : ", "), a.pop(); os << " }"; return os; } template < class T, class Container > std::ostream &operator<<(std::ostream &os, std::queue< T, Container > a) { os << "{ "; while(a.size()) os << a.front() << (a.size() == 1 ? "" : ", "), a.pop(); os << " }"; return os; } #ifdef DEBUG #if !defined(DEBUG_OUT) #define DEBUG_OUT std::cerr #endif #define dump(...) \ [&]() { \ auto __debug_tap = std::make_tuple(__VA_ARGS__); \ DEBUG_OUT << "[" << __LINE__ << "] " << #__VA_ARGS__ << " = " << __debug_tap \ << std::endl; \ }() template < class T > inline void dump2D(T &d, size_t sizey, size_t sizex) { for(size_t i = 0; i < sizey; i++) { DEBUG_OUT << "\t"; for(size_t j = 0; j < sizex; j++) DEBUG_OUT << d[i][j] << (j + 1 == sizex ? "" : "\t"); DEBUG_OUT << std::endl; } } template < class T > inline void dump1D(T &d, size_t sizey) { for(size_t i = 0; i < sizey; i++) { DEBUG_OUT << d[i] << (i + 1 == sizey ? "" : " "); } DEBUG_OUT << std::endl; } template < class T, class = typename std::iterator_traits< decltype(begin(T())) >::value_type, class = typename std::enable_if< !std::is_same< T, std::string >::value >::type > std::ostream &operator<<(std::ostream &os, const T &a) { os << "{"; for(auto ite = begin(a); ite != end(a); ++ite) os << (ite == begin(a) ? "" : ", ") << *ite; os << "}"; return os; } #else #define dump(...) ((void) 42) #define dump2D(...) ((void) 42) #define dump1D(...) ((void) 42) template < class T, class = typename std::iterator_traits< decltype(begin(T())) >::value_type, class = typename std::enable_if< !std::is_same< T, std::string >::value >::type > std::ostream &operator<<(std::ostream &os, const T &a) { for(auto ite = begin(a); ite != end(a); ++ite) os << (ite == begin(a) ? "" : " ") << *ite; return os; } #endif // }}} ll m, n, mulX, addX, mulY, addY; ll mod; // <= 2^24 constexpr int M = 1000; constexpr int N = 1e7; constexpr int F = 1 << 24; ll X[M], Y[M], A[M], B[M]; int z[F]; int memo[F+1]; int main() { std::ios::sync_with_stdio(false), std::cin.tie(0); cin >> m >> n >> mulX >> addX >> mulY >> addY >> mod; ll mask = mod - 1; ll sum = 0; for(int i = 0; i < m; i++) cin >> X[i]; for(int i = 0; i < m; i++) cin >> Y[i]; for(int i = 0; i < m; i++) cin >> A[i]; for(int i = 0; i < m; i++) cin >> B[i]; for(int i = 0; i < m; i++) (z[X[i]] += Y[i]) &= mask; for(int i = m; i < n; i++) { (((X[m-1] *= mulX) &= mask) += addX) &= mask; (((Y[m-1] *= mulY) &= mask) += addY) &= mask; (z[X[m-1]] += Y[m-1]) &= mask; // dump(X[m-1], Y[m-1]); } for(int i = 0; i <= F; i++) memo[i] = -1; // dump1D(z, 10); for(int i = 0; i < m; i++) { ll a = A[i], b = B[i]; if(memo[a] == -1) { memo[a] = 0; for(int j = a; j < F; j += a) { (memo[a] += z[j]) &= mask; } } ll c = a * b; if(c<F && memo[c] == -1) { memo[c] = 0; for(int j = c; j < F; j += c) { (memo[c] += z[j]) &= mask; } } // dump(a,c); // dump(memo[a], memo[c]); ll ans = (mod + memo[a] - (c<F ? memo[c] : 0)) & mask; cout << ans << "\n"; sum ^= ans; } for(int i = m; i < n; i++) { (((A[m-1] *= mulX) += addX-1) &= mask) += 1; (((B[m-1] *= mulY) += addY-1) &= mask) += 1; ll a = A[m-1], b = B[m-1]; if(memo[a] == -1) { memo[a] = 0; for(int j = a; j < F; j += a) { (memo[a] += z[j]) &= mask; } } ll c = a * b; if(c<F && memo[c] == -1) { memo[c] = 0; for(int j = c; j < F; j += c) { (memo[c] += z[j]) &= mask; } } ll ans = (mod + memo[a] - (c<F ? memo[c] : 0)) & mask; // dump(ans); sum ^= ans; } cout << sum << "\n"; return 0; }