結果

問題 No.749 クエリ全部盛り
ユーザー syutarosyutaro
提出日時 2018-10-29 05:16:44
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 3,382 bytes
コンパイル時間 645 ms
コンパイル使用メモリ 91,968 KB
実行使用メモリ 27,016 KB
最終ジャッジ日時 2024-04-29 22:40:21
合計ジャッジ時間 5,896 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
13,756 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 4 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 79 ms
5,376 KB
testcase_11 AC 82 ms
5,376 KB
testcase_12 AC 83 ms
5,376 KB
testcase_13 AC 83 ms
5,376 KB
testcase_14 AC 86 ms
5,376 KB
testcase_15 TLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <tuple>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


const int M = 1000000000+7;
struct Int {
    uint64_t i;
    Int()      {i = 0;}
    Int(uint64_t x) {i = x % M;}
    Int operator+(Int other) {
        return Int(this->i + other.i);
    }
    Int operator*(Int other) {
        return Int(this->i * other.i);
    }
};

struct Fibo {
    vector<Int> f;

    Fibo() {
        f = vector<Int>(2);
        f[0] = Int(0);
        f[1] = Int(1);
    }

    Int fibo(uint64_t n) {
        if(n >= f.size()) {
            FOR(i, f.size(), n+1) {
                f.push_back(f[f.size()-1] + f[f.size()-2]);
            }
        }
        return f[n];
    }
};

int main() {
    Fibo f = Fibo();
    uint64_t N, Q;
    cin >> N >> Q;
    vector<Int> a = vector<Int>(N);
    REP(i, N) {
        a[i] = Int(0);
    }
    REP(i, Q) {
        uint64_t _q, _l, _r, _k;
        cin >> _q >> _l >> _r >> _k;
        Int q(_q), l(_l), r(_r), k(_k);

        if(_q == 0) {
            Int sum = Int(0);
            FOR(i, _l, _r+1) {
                sum = sum + a[i];
            }
            Int ret = sum * k;
            cout << ret.i << endl;

        } else if(_q == 1) {
            FOR(i, _l, _r+1) {
                a[i] = k;
            }
        } else if(_q == 2) {
             FOR(i, _l, _r+1) {
                a[i] = a[i] + k;
            }           
        } else if(_q == 3) {
             FOR(i, _l, _r+1) {
                a[i] = a[i] * k;
            }
        } else {
             FOR(i, _l, _r+1) {
                a[i] = a[i] + k * f.fibo(i);
            }
        }
    }
    return 0;
}
0