結果
| 問題 |
No.142 単なる配列の操作に関する実装問題
|
| コンテスト | |
| ユーザー |
codershifth
|
| 提出日時 | 2015-12-14 22:15:03 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 3,178 bytes |
| コンパイル時間 | 1,277 ms |
| コンパイル使用メモリ | 163,572 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-15 12:43:52 |
| 合計ジャッジ時間 | 11,394 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 5 |
ソースコード
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int (i)=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define RANGE(vec) (vec).begin(),(vec).end()
using namespace std;
class ArrayImplementationSimply {
public:
typedef unsigned long long ull;
const int Block = 64;
pair<int,int> i2b(int idx)
{
return make_pair(idx/Block, idx%Block);
}
ull shift(ull arry[3], int move)
{
if ( move == 0 )
return arry[1];
if ( move > 0 )
{
return (arry[1]<<move)|(arry[0]>>(Block-1-move));
}
else
{
move *= -1;
return (arry[1]>>move)|(arry[2]<<(Block-1-move));
}
}
void solve(void)
{
int N,S,X,Y,Z;
int Q;
cin>>N>>S>>X>>Y>>Z;
cin>>Q;
vector<ull> A(N/Block+1, 0);
vector<ull> B(N/Block+1, 0);
ull a;
a = S;
REP(i,N)
{
int p,b;
tie(b,p) = i2b(i);
if ( a%2 )
A[b] |= (1ULL<<p);
a = (X*a+Y) % Z;
}
while (Q--)
{
int S,T,U,V;
int sb,tb,ub,vb;
int sp,tp,up,vp;
cin>>S>>T>>U>>V;
--S,--T,--U,--V;
tie(sb,sp) = i2b(S);
tie(tb,tp) = i2b(T);
tie(ub,up) = i2b(U);
tie(vb,vp) = i2b(V);
// B=A[S,T]
// A[k] = A[k] + B[k-U] (U<=k<=V)
int move = up-sp;
for (int k = 0, j = sb; k <= vb-ub; ++k, ++j)
{
ull C[3] = {0,0,0};
// 一旦そのまま copy
// 対象 block が C[1] にくるようにする。
for (int i = -1; i <= 1; ++i)
{
if ( 0 <= sb+i && sb+i < (int)A.size() )
C[i+1] = A[sb+i];
}
if ( j == sb )
{ // 頭の不要な部分は削る
C[0] = 0;
C[1] = C[1] & ~((1ULL<<sp)-1);
}
if ( j == tb )
{ // 末尾の不要な部分は削る
C[1] = C[1] & ((1ULL<<tp)|((1ULL<<tp)-1));
C[2] = 0;
}
B[k] = shift(C, move);
}
for (int k = ub; k <= vb; ++k)
{
A[k] ^= B[k-ub];
}
}
REP(i,N)
{
int p,b;
tie(b,p) = i2b(i);
if ( A[b] & (1ULL<<p) )
cout<<"O";
else
cout<<"E";
}
cout<<endl;
}
};
#if 1
int main(int argc, char *argv[])
{
ios::sync_with_stdio(false);
auto obj = new ArrayImplementationSimply();
obj->solve();
delete obj;
return 0;
}
#endif
codershifth