結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 3 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 WA -
testcase_07 AC 58 ms
4,380 KB
testcase_08 WA -
testcase_09 AC 59 ms
4,376 KB
testcase_10 AC 58 ms
4,376 KB
testcase_11 WA -
testcase_12 AC 116 ms
4,952 KB
testcase_13 WA -
testcase_14 AC 114 ms
4,896 KB
testcase_15 WA -
testcase_16 AC 114 ms
4,852 KB
testcase_17 AC 116 ms
4,952 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 115 ms
4,896 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 115 ms
4,924 KB
testcase_24 AC 115 ms
4,900 KB
testcase_25 AC 115 ms
5,060 KB
testcase_26 AC 115 ms
4,848 KB
testcase_27 AC 114 ms
4,964 KB
testcase_28 AC 115 ms
5,060 KB
testcase_29 AC 115 ms
4,952 KB
testcase_30 AC 116 ms
4,992 KB
testcase_31 AC 116 ms
4,848 KB
testcase_32 WA -
testcase_33 AC 117 ms
4,896 KB
testcase_34 AC 117 ms
5,064 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 RE -
testcase_38 WA -
testcase_39 RE -
testcase_40 AC 122 ms
4,892 KB
testcase_41 AC 121 ms
4,888 KB
testcase_42 AC 122 ms
5,064 KB
testcase_43 AC 123 ms
5,060 KB
testcase_44 AC 121 ms
4,996 KB
testcase_45 AC 124 ms
5,116 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 AC 125 ms
5,188 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(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