結果
| 問題 |
No.142 単なる配列の操作に関する実装問題
|
| コンテスト | |
| ユーザー |
maine_honzuki
|
| 提出日時 | 2020-05-21 11:02:52 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 2,394 bytes |
| コンパイル時間 | 716 ms |
| コンパイル使用メモリ | 76,212 KB |
| 実行使用メモリ | 30,252 KB |
| 最終ジャッジ日時 | 2024-10-01 23:54:30 |
| 合計ジャッジ時間 | 13,683 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | TLE * 1 -- * 4 |
ソースコード
#include <algorithm>
#include <bitset>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
using ull = unsigned long long;
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int N, S, X, Y, Z;
cin >> N >> S >> X >> Y >> Z;
vector<ull> A(N);
A[0] = S;
for (int i = 1; i < N; i++) {
(A[i] = (X * A[i - 1] + Y)) %= Z;
}
ull bit[40010] = {}, mask[40010] = {};
for (int i = 0; i < N; i++) {
bit[i / 64] |= (A[i] % 2) << (i % 64);
}
int Q;
cin >> Q;
while (Q--) {
int S, T, U, V;
cin >> S >> T >> U >> V;
S--;
T--;
U--;
V--;
//mask.reset();
//mask >>= (len - (T - S + 1));
//mask <<= S - 1;
string ans;
for (int i = 0; i < N; i++) {
ans.push_back(char(bit[i / 64] & (1ll << (i % 64)) ? 'O' : 'E'));
}
int z = U - S;
if (z >= 0) {
for (int i = U / 64; i <= V / 64; i++) {
ull tmp = bit[i - z / 64] << (z % 64);
if (i - z / 64 - 1 >= 0)
tmp |= bit[i - z / 64 - 1] >> (64 - z % 64);
if (i == U / 64) {
for (int x = 0; x < U % 64; x++) {
tmp &= ~(1ull << x);
}
}
if (i == V / 64) {
for (int x = 63; x > V % 64; x--) {
tmp &= ~(1ull << x);
}
}
bit[i] ^= tmp;
}
} else {
z = abs(z);
for (int i = U / 64; i <= V / 64; i++) {
ull tmp = bit[i - z / 64] >> (z % 64);
tmp |= bit[i - z / 64 + 1] << (64 - z % 64);
if (i == U / 64) {
for (int x = 0; x < U % 64; x++) {
tmp &= ~(1ull << x);
}
}
if (i == V / 64) {
for (int x = 63; x > V % 64; x--) {
tmp &= ~(1ull << x);
}
}
bit[i] ^= tmp;
}
}
}
string ans;
for (int i = 0; i < N; i++) {
ans.push_back(char(bit[i / 64] & (1ll << (i % 64)) ? 'O' : 'E'));
}
reverse(ans.begin(), ans.end());
cout << ans << endl;
}
maine_honzuki