結果
| 問題 |
No.142 単なる配列の操作に関する実装問題
|
| コンテスト | |
| ユーザー |
koyumeishi
|
| 提出日時 | 2015-02-02 01:45:22 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1,376 ms / 5,000 ms |
| コード長 | 2,502 bytes |
| コンパイル時間 | 1,141 ms |
| コンパイル使用メモリ | 89,040 KB |
| 実行使用メモリ | 19,072 KB |
| 最終ジャッジ日時 | 2024-06-23 06:20:00 |
| 合計ジャッジ時間 | 6,835 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 5 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:64:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
64 | scanf("%d %d %d %d", &s_, &t, &u, &v);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <set>
#include <bitset>
using namespace std;
#define SZ 1200
//#define DBG_
void init(vector<bitset<SZ>> &v, int n, int s, long long x, long long y, long long z){
vector<long long> a(n, 1);
a[0] = s;
v[0/SZ].set(0%SZ, a[0]&1);
for(int i=1; i<n; i++){
a[i] = (x*a[i-1] + y) % z;
v[i/SZ].set(i%SZ, a[i]&1);
}
#ifdef DBG_
for(int i=0; i<n; i++){
cerr << a[i] << " " ;
}
cerr << endl;
#endif
}
void dbg(bitset<SZ> x){
string s = x.to_string<char,std::string::traits_type,std::string::allocator_type>();
cerr << s << endl;
}
int main(){
int n,s,x,y,z;
cin >> n >> s >> x >> y >> z;
int k = n/SZ + 1;
vector<bitset<SZ>> vec(k);
init(vec,n,s,x,y,z);
#ifdef DBG_
for(int i=0; i<k; i++){
dbg(vec[i]);
}
#endif
int q;
cin >> q;
while(q-->0){
int s_, t, u, v;
scanf("%d %d %d %d", &s_, &t, &u, &v);
s_--;
t--;
u--;
v--;
vector<bitset<SZ>> tmp(vec.begin() + s_/SZ , vec.begin() + (t+1)/SZ + 1);
#ifdef DBG_
cerr << "tmp " << endl;
for(int i=0; i<tmp.size(); i++){
dbg(tmp[i]);
}
#endif
tmp[0] >>= s_%SZ;
tmp[0] <<= s_%SZ;
#ifdef DBG_
cerr << "tmp s " << endl;
for(int i=0; i<tmp.size(); i++){
dbg(tmp[i]);
}
#endif
tmp[tmp.size()-1] <<= SZ-((t+1)%SZ);
tmp[tmp.size()-1] >>= SZ-((t+1)%SZ);
#ifdef DBG_
cerr << "tmp t " << endl;
for(int i=0; i<tmp.size(); i++){
dbg(tmp[i]);
}
#endif
int d = (u%SZ) - (s_%SZ);
for(int i=0; i<tmp.size(); i++){
#ifdef DBG_
cerr << "rewrite from :" << endl;
dbg(vec[u/SZ+i]);
#endif
if(d==0){
vec[u/SZ + i] ^= tmp[i];
}
if(d<0){
vec[u/SZ + i] ^= (tmp[i] >> abs(d));
if(i+1<tmp.size()){
vec[u/SZ + i] ^= ( tmp[i+1] << (SZ - abs(d)) );
}
}else if(d>0){
vec[u/SZ + i] ^= (tmp[i] << abs(d));
if(i>0){
vec[u/SZ + i] ^= ( tmp[i-1] >> (SZ - abs(d)) );
}
}
#ifdef DBG_
cerr << "to :" << endl;
dbg(vec[u/SZ+i]);
cerr << endl;
#endif
}
if(d>0 && u/SZ + tmp.size() < vec.size() ){
vec[u/SZ + tmp.size()] ^= ( tmp[tmp.size()-1] >> (SZ - abs(d)) );
}
#ifdef DBG_
cerr << "res " << endl;
for(int i=0; i<k; i++){
dbg(vec[i]);
}
#endif
}
#ifdef DBG_
for(int i=0; i<k; i++){
dbg(vec[i]);
}
#endif
string ss;
for(int i=0; i<n; i++){
ss.push_back(vec[i/SZ][i%SZ]?'O':'E');
}
cout << ss << endl;
return 0;
}
koyumeishi