QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#242222 | #7047. Pot!! | Anwar# | WA | 1ms | 3604kb | C++20 | 2.1kb | 2023-11-07 01:50:56 | 2023-11-07 01:50:56 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 3 , MOD = 1e9 + 7;
int T[1 << 18][4] , lazy[1 << 18][4];
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] ) ;
}
}
int get(int l , int r , int id =0 , int tl =0 , int tr = n-1) {
if (l > tr || tl > r) return 0;
prop(id, tl, tr);
if (l <= tl && tr <= r) return max({T[id][0], T[id][1], T[id][2], T[id][3]});
int md = (tl + tr) / 2;
return max(get(l, r, 2 * id + 1, tl, md), get(l, r, 2 * id + 2, md + 1, tr));
}
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] = 1;
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;
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 " ;
cout << get(l-1 , r-1) << "\n";
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3520kb
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: 1ms
memory: 3604kb
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 2 ANSWER 3 ANSWER 2 ANSWER 8 ANSWER 4 ANSWER 8 ANSWER 16 ANSWER 4 ANSWER 8 ANSWER 0 ANSWER 2 ANSWER 4 ANSWER 16 ANSWER 11 ANSWER 16 ANSWER 26 ANSWER 16 ANSWER 26 ANSWER 8 ANSWER 16 ANSWER 16 ANSWER 16 ANSWER 8 ANSWER 49 ANSWER 26 ANSWER 26 ANSWER 19 ANSWER 27 ANSWER 28 ANSWER 18 ANSW...
result:
wrong answer 5th lines differ - expected: 'ANSWER 2', found: 'ANSWER 8'