QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#242221#7047. Pot!!Anwar#WA 1ms9548kbC++202.4kb2023-11-07 01:45:592023-11-07 01:46:00

Judging History

你现在查看的是最新测评结果

  • [2023-11-07 01:46:00]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:9548kb
  • [2023-11-07 01:45:59]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

const int N = 1e5 + 3 , MOD =  1e9 + 7;

array<int , 4> T[1 << 18] , lazy[1 << 18];
int n;

void prop(int id , int tl , int tr)
{
    if(tl == tr) return;

    for (int i = 0; i < 4; ++i) {
        T[2*id + 1][i] += lazy[id][i] ;
        T[2*id + 2][i] += lazy[id][i] ;
        lazy[2*id + 1][i] += lazy[id][i] ;
        lazy[2*id + 1][i] += lazy[id][i] ;

        lazy[id][i] =0 ;
    }
}

int v[11][4] ;

void update(int l , int r ,int x , int id =0 , int tl =0 ,int tr = n-1 )
{
    if(l > tr || tl > r) return;

    prop(id , tl ,tr) ;

    if(l <= tl && tr <= r)
    {
        for (int i = 0; i < 4; ++i) {
            T[id][i] += v[x][i] ;
            lazy[id][i] += v[x][i] ;
            return;
        }
    }

    int md = (tl + tr) /2 ;

    update(l ,r, x ,2*id + 1 , tl , md) ;
    update(l ,r, x , 2*id + 2 ,md+1 ,tr ) ;

    for (int i = 0; i < 4; ++i) {
        T[id][i] = max( T[2*id  +1][i] , T[2*id + 2][i]  ) ;
    }
}

array<int , 4> o ;

array<int , 4> get(int l , int r , int id =0 , int tl =0 , int tr = n-1)
{
    if(l > tr || tl > r) return o ;

    prop(id , tl ,  tr) ;

    if(l <= tl && tr <= r) return T[id] ;

    int md = (tl  + tr ) /2 ;

    array<int , 4 > le = get(l ,r , 2*id + 1 , tl , md ) ;
    array<int , 4 > ri = get(l ,r , 2*id + 2 , md+1 , tr ) ;

    array<int , 4> res ;

    for (int i = 0; i < 4 ; ++i) {
        res[i] = max( le[i] , ri[i] ) ;
    }

    return res;
}

int32_t main() {

    cin.tie(0);cin.sync_with_stdio(0);
    cout.tie(0);cout.sync_with_stdio(0);

    v[2][0] = 1;
    v[3][1] = 2;
    v[4][0] = 2;
    v[5][2] = 1;
    v[6][0] = v[6][1] = 1;
    v[7][3] = 1;
    v[8][0] = 3;
    v[9][1] = 2;
    v[10][0] = v[10][2] = 1;

    o[0] = o[1] = o[2] = o[4] ;

    fill( T , T + (1 << 18) , o ) ;

    cin >> n;
    int q;
    cin >> q;

    while (q--)
    {
        string s;
        cin >> s;

        int l ,r ;
        cin >> l >> r;

        if(s[1] == 'U')
        {
            int x;
            cin >> x;

            update( l-1 , r-1 , x ) ;
        }
        else
        {
            cout << "ANSWER " ;

           auto a = get(l-1 , r-1) ;

           cout << max( { a[0] , a[1] , a[2] , a[3] } ) << "\n" ;
        }
    }

    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 8332kb

input:

5 6
MULTIPLY 3 5 2
MULTIPLY 2 5 3
MAX 1 5
MULTIPLY 1 4 2
MULTIPLY 2 5 5
MAX 3 5

output:

ANSWER 1
ANSWER 2

result:

ok 2 lines

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 9548kb

input:

100 1000
MULTIPLY 3 13 8
MULTIPLY 35 86 9
MAX 5 92
MAX 30 86
MAX 4 99
MAX 36 66
MULTIPLY 27 41 5
MAX 21 40
MULTIPLY 5 20 10
MAX 7 98
MAX 10 10
MAX 40 44
MAX 27 47
MAX 37 54
MAX 61 72
MULTIPLY 10 13 8
MAX 19 30
MAX 27 96
MULTIPLY 54 94 9
MAX 29 88
MAX 7 45
MULTIPLY 21 96 7
MULTIPLY 77 98 9
MULTIPLY 3...

output:

ANSWER 3
ANSWER 0
ANSWER 3
ANSWER 0
ANSWER 0
ANSWER 4
ANSWER 8
ANSWER 0
ANSWER 0
ANSWER 0
ANSWER 0
ANSWER 1
ANSWER 0
ANSWER 0
ANSWER 11
ANSWER 16
ANSWER 0
ANSWER 11
ANSWER 0
ANSWER 1
ANSWER 0
ANSWER 0
ANSWER 4
ANSWER 2
ANSWER 49
ANSWER 21
ANSWER 19
ANSWER 19
ANSWER 16
ANSWER 3
ANSWER 12
ANSWER 12
AN...

result:

wrong answer 2nd lines differ - expected: 'ANSWER 2', found: 'ANSWER 0'