結果
問題 |
No.142 単なる配列の操作に関する実装問題
|
ユーザー |
![]() |
提出日時 | 2025-05-14 13:20:22 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,081 bytes |
コンパイル時間 | 789 ms |
コンパイル使用メモリ | 72,548 KB |
実行使用メモリ | 12,928 KB |
最終ジャッジ日時 | 2025-05-14 13:21:16 |
合計ジャッジ時間 | 11,214 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 1 TLE * 1 -- * 3 |
ソースコード
#include <iostream> #include <vector> #include <string> // Fast I/O void fast_io() { std::ios_base::sync_with_stdio(false); std::cin.tie(NULL); } int main() { fast_io(); int n; long long s_seed_ll, x_param_ll, y_param_ll, z_param_ll; std::cin >> n >> s_seed_ll >> x_param_ll >> y_param_ll >> z_param_ll; std::vector<char> parities(n); long long current_a_val = s_seed_ll; // parities[i] stores parity of (i+1)-th element of A (A is 1-indexed) // current_a_val % 2 gives 0 for even, 1 for odd. // We store 1 if odd, 0 if even. parities[0] = (char)(current_a_val % 2 != 0); for (int i = 1; i < n; ++i) { current_a_val = (x_param_ll * current_a_val + y_param_ll) % z_param_ll; parities[i] = (char)(current_a_val % 2 != 0); } int q_count; std::cin >> q_count; for (int k_query = 0; k_query < q_count; ++k_query) { int s_idx_1based, t_idx_1based, u_idx_1based, v_idx_1based; std::cin >> s_idx_1based >> t_idx_1based >> u_idx_1based >> v_idx_1based; // Adjust to 0-based indexing int s0 = s_idx_1based - 1; int u0 = u_idx_1based - 1; int len = t_idx_1based - s_idx_1based + 1; if (u0 > s0) { // Destination start is to the right of source start. // Iterate backwards to use original source values if ranges overlap. for (int i = len - 1; i >= 0; --i) { parities[u0 + i] ^= parities[s0 + i]; } } else { // u0 <= s0 // Destination start is to the left of or same as source start. // Iterate forwards. for (int i = 0; i < len; ++i) { parities[u0 + i] ^= parities[s0 + i]; } } } std::string result_str; result_str.reserve(n); for (int i = 0; i < n; ++i) { if (parities[i] == 0) { // 0 means even result_str += 'E'; } else { // 1 means odd result_str += 'O'; } } std::cout << result_str << "\n"; return 0; }