結果

問題 No.1386 Range add Simulation
ユーザー 蜜蜂
提出日時 2021-02-05 19:20:49
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 3,333 bytes
コンパイル時間 1,897 ms
コンパイル使用メモリ 172,768 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-04 13:09:11
合計ジャッジ時間 23,424 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other AC * 30 WA * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define fi first
#define se second
#define pb push_back
vector<int> operation;
random_device seed;
mt19937 randint(seed());
int grr(int mi, int ma) { // [mi, ma)
return mi + randint() % (ma - mi);
}
void op(ll x){
if(x==0){
return;
}
if(x>0){
if(x%2==0){
operation.pb(3);
op(x/2);
}
else{
operation.pb(1);
op(x-1);
}
return;
}
if(x<0){
if(x%2==0){
operation.pb(3);
op(x/2);
}
else{
operation.pb(2);
op(x+1);
}
}
}
int main(){
int n,q;
cin>>n>>q;
ll first[n]={};
ll second[n]={};
for(int i=0;i<q;i++){
int c;
cin>>c;
if(c==1){
int s;
cin>>s;
if(s==1){
first[0]+=1,first[1]+=3,first[2]+=2;
}
if(s==2){
first[1]+=1,first[2]+=2;
}
if(s>=3){
if(s<n){
first[s]+=1;
}
first[s-1]+=1;
}
}
if(c==2){
int s;
cin>>s;
if(s==1){
first[0]+=1;
}
if(s>=2){
ll z=s;
z*=z;
first[0]+=s*s;
first[1]-=2*s-1;
first[2]+=2;
if(s+1<n){
first[s+1]-=1;
}
if(s+2<n){
first[s+2]-=1;
}
}
}
}
for(int i=0;i<n;i++){
//cout<<first[i]<<" ";
}
//cout<<endl;
//
/*for(int i=3;i<n;i++){
first[i]+=first[i-1];
}
for(int i=0;i<n;i++){
cout<<first[i]<<" ";
}
cout<<endl;*/
//imos1
/*for(int i=0;i<n;i++){
first[i]+=second[i];
}*/
/*for(int i=0;i<n;i++){
cout<<first[i]<<" ";
}
cout<<endl;*/
//imos1調
/*for(int i=2;i<n;i++){
first[i]+=first[i-1];
}
for(int i=0;i<n;i++){
cout<<first[i]<<" ";
}
cout<<endl;*/
/*for(int i=1;i<n;i++){
first[i]+=first[i-1];
}
for(int i=0;i<n;i++){
cout<<first[i]<<" ";
}
cout<<endl;*/
//cout<<"/////////////////"<<endl;
int count=0;
for(int i=0;i<n;i++){
//cout<<i<<":";
operation.clear();
op(first[i]);
count+=operation.size();
reverse(operation.begin(),operation.end());
for(int x:operation){
if(x==1||x==2){
//cout<<x<<" "<<i+1<<"\n";
}
else{
//cout<<x<<" "<<i+1<<" "<<i+1<<"\n";
}
//cout<<x<<" ";
}
}
//cout<<endl;
for(int i=3;i<n;i++){
count++;
//cout<<3<<" "<<i+1<<" "<<i<<"\n";
}
for(int i=2;i<n;i++){
count++;
//cout<<3<<" "<<i+1<<" "<<i<<"\n";
}
for(int i=1;i<n;i++){
count++;
//cout<<3<<" "<<i+1<<" "<<i<<"\n";
}
cout<<count<<endl;
for(int i=0;i<n;i++){
//cout<<i<<":";
operation.clear();
op(first[i]);
//count+=operation.size();
reverse(operation.begin(),operation.end());
for(int x:operation){
if(x==1||x==2){
cout<<x<<" "<<i+1<<"\n";
}
else{
cout<<x<<" "<<i+1<<" "<<i+1<<"\n";
}
//cout<<x<<" ";
}
}
//cout<<endl;
for(int i=3;i<n;i++){
//count++;
cout<<3<<" "<<i+1<<" "<<i<<"\n";
}
for(int i=2;i<n;i++){
//count++;
cout<<3<<" "<<i+1<<" "<<i<<"\n";
}
for(int i=1;i<n;i++){
//count++;
cout<<3<<" "<<i+1<<" "<<i<<"\n";
}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0