結果

問題 No.1386 Range add Simulation
ユーザー 蜜蜂蜜蜂
提出日時 2021-02-05 19:31:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 3,483 bytes
コンパイル時間 1,815 ms
コンパイル使用メモリ 170,492 KB
実行使用メモリ 5,172 KB
最終ジャッジ日時 2023-09-17 18:41:20
合計ジャッジ時間 21,149 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 59 ms
4,376 KB
testcase_07 AC 58 ms
4,376 KB
testcase_08 AC 58 ms
4,380 KB
testcase_09 AC 59 ms
4,376 KB
testcase_10 AC 58 ms
4,380 KB
testcase_11 AC 114 ms
4,924 KB
testcase_12 AC 115 ms
4,848 KB
testcase_13 AC 115 ms
4,976 KB
testcase_14 AC 115 ms
4,972 KB
testcase_15 AC 115 ms
5,172 KB
testcase_16 AC 114 ms
4,912 KB
testcase_17 AC 114 ms
4,900 KB
testcase_18 AC 115 ms
4,896 KB
testcase_19 AC 115 ms
4,928 KB
testcase_20 AC 115 ms
4,928 KB
testcase_21 AC 115 ms
5,044 KB
testcase_22 AC 115 ms
4,852 KB
testcase_23 AC 116 ms
4,864 KB
testcase_24 AC 115 ms
4,900 KB
testcase_25 AC 115 ms
4,976 KB
testcase_26 AC 114 ms
5,172 KB
testcase_27 AC 116 ms
4,864 KB
testcase_28 AC 116 ms
4,988 KB
testcase_29 AC 115 ms
4,968 KB
testcase_30 AC 115 ms
4,928 KB
testcase_31 AC 116 ms
4,896 KB
testcase_32 AC 117 ms
4,988 KB
testcase_33 AC 117 ms
4,924 KB
testcase_34 AC 116 ms
4,900 KB
testcase_35 WA -
testcase_36 AC 9 ms
4,380 KB
testcase_37 RE -
testcase_38 AC 11 ms
4,384 KB
testcase_39 RE -
testcase_40 AC 122 ms
4,920 KB
testcase_41 AC 122 ms
5,056 KB
testcase_42 AC 122 ms
4,920 KB
testcase_43 AC 122 ms
5,112 KB
testcase_44 AC 122 ms
4,984 KB
testcase_45 AC 122 ms
5,044 KB
testcase_46 AC 122 ms
4,996 KB
testcase_47 AC 121 ms
4,996 KB
testcase_48 AC 123 ms
4,920 KB
testcase_49 AC 130 ms
5,044 KB
権限があれば一括ダウンロードができます

ソースコード

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(1<n){
          first[1]-=1;
        }
        if(2<n){
          first[2]+=1;
        }
        if(3<n){
          first[3]-=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";
  }

}
0