QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#725029#9409. Sensors1205691775AC ✓1439ms109028kbC++202.9kb2024-11-08 15:56:532024-11-08 15:57:00

Judging History

This is the latest submission verdict.

  • [2024-11-08 15:57:00]
  • Judged
  • Verdict: AC
  • Time: 1439ms
  • Memory: 109028kb
  • [2024-11-08 15:56:53]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
template<class... A> void odn(A&&... a) {(int[]){(cout<<a<<' ',0)...}; cout<< '\n';}
#define dbg(x... ) odn(__LINE__, #x, ":", x)
using ll = long long;
const int B = 256, N = 5e5+5;

inline int BID(int x) {return x>>8;}
struct Node {
    vector<int> id;
    int num0;
};

struct Info {
    int ge1, num1;
};

#define M (L+R)>>1
#define lc (o<<1)
#define rc (o<<1|1)
void solve() {
    int n, m; cin>> n>> m;
    // vector<Node> T(4*n);
    vector<Node> T(1<<(__lg(n-1) + 2));
    // vector<pair<int,int>> sen(m);
    vector<Info> info(m);    

    auto updateR = [&](auto self, int o, int l, int r, int id, int L, int R, int& sum, int& sum2) {
        if (l <= L && R <= r) {
            T[o].id.push_back(id);
            // dbg(o, l, r, id, L, R);
            sum++;
            if (L+1 == R) sum2++;
            return;
        }
        if (l < M) self(self, lc, l, r, id, L, M, sum, sum2);
        if (r > M) self(self, rc, l, r, id, M, R, sum, sum2);
    };
    ll ans =0;
    auto queryP = [&](auto self, int o, int p, int L, int R) {
        T[o].num0++;
        // dbg(o, p, L, R, T[o].num0);
        if (T[o].num0 == R-L) {
            for (int v : T[o].id) {
                info[v].num1--;
                info[v].ge1--;
                // dbg(v, info[v].num1, info[v].ge1);
                if (info[v].num1 == 1 && info[v].ge1 == 1) {
                    ans += 1ll * (v+1)*(v+1);
                }
                if (info[v].ge1 == 0) {
                    ans -= 1ll * (v+1)*(v+1);
                }
            }
        } else if (T[o].num0 + 1 == R-L) {
            for (int v : T[o].id) {
                info[v].num1++;
                if (info[v].num1 == 1 && info[v].ge1 == 1) {
                    ans += 1ll * (v+1)*(v+1);
                }
            }
        }

        if (L+1 == R) {
            return;
        }
        if (p < M) self(self, lc, p, L, M);
        else self(self, rc, p, M, R);
    };

    for (int i = 0; i < m; i++) {
        int x, y; cin>> x>> y; // x--, y--;
        // sen[i] = make_pair(x, y);
        int sum=0, sum2=0;
        updateR(updateR, 1, x, y+1, i, 0, n, sum, sum2);
        info[i].ge1 = sum;
        info[i].num1 = sum2;
        if (x == y) {
            ans += 1ll*(i+1)*(i+1);
        }
    }
    // odn(1);
    for (int i = 0; i < n; i++) {
        cout<< ans<< ' ';
        int a; cin>> a;
        a = (a + ans) % n;
        queryP(queryP, 1, a, 0, n);
    }
    cout<< ans;
    cout<< '\n';
}
/*
9 # 2 1 1 0 # 
# 2 3 2 0 # 
13 # 0 3 1 0 # 
29 # 3 1 0 0 # 
# 3 2 0 0 # 
16 # 3 1 -1 0 # 
# 3 2 -1 0 # 
16 # 1 3 0 0 # 
0
*/

int main(){
    //freopen("i", "r", stdin);
    // std::ios::sync_with_stdio(false);
    // std::cin.tie(nullptr);
    int T;
    std::cin >>T;
    // T = 1;
    while(T--){
        solve();
    }
    return 0;
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

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

input:

3
5 4
2 4
2 3
3 3
0 2
3 2 4 2 0
2 1
1 1
1 0
2 1
0 1
0 0

output:

9 13 29 17 16 0
1 1 0
0 1 0

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 599ms
memory: 22832kb

input:

2227
2 9
0 1
1 1
0 1
0 0
0 1
0 1
0 0
1 1
0 1
1 1
3 1
0 2
1 2 2
8 2
0 2
3 5
7 4 0 3 2 6 4 1
6 2
1 3
0 1
0 0 5 1 4 2
1 6
0 0
0 0
0 0
0 0
0 0
0 0
0
5 1
1 4
0 1 2 3 3
5 3
0 3
4 4
2 2
0 4 0 0 0
5 10
0 2
3 3
1 3
1 4
1 3
0 4
2 4
0 0
0 1
4 4
3 1 3 4 1
8 4
0 5
0 1
6 7
3 4
1 3 3 5 2 3 5 3
2 7
1 1
0 0
0 0
1 1
...

output:

133 220 0
0 0 1 0
0 0 0 0 4 4 5 4 0
0 4 4 4 4 5 0
91 0
0 0 0 0 1 0
13 13 4 0 1 0
168 249 105 135 136 0
0 4 13 9 0 0 16 17 0
79 127 0
1 54 0
0 0 25 25 25 61 40 57 21 14 0
385 0
0 0 9 71 9 53 69 0
0 0 9 9 9 46 0
35 39 203 0
1 10 9 9 9 54 0
5 5 5 0 0
5 13 13 4 16 16 16 0
4 4 5 5 5 4 0
0 1 1 1 1 0 0 0 0...

result:

ok 2227 lines

Test #3:

score: 0
Accepted
time: 1439ms
memory: 96188kb

input:

1
500000 500000
369902 382967
262235 295509
296241 456925
21398 104992
37225 97384
380549 388723
338331 494405
150247 262207
70049 286642
214690 432702
268101 392964
99683 217894
89569 351594
126467 380939
152103 169827
171887 422097
166531 416410
44667 160325
210347 371355
47557 119914
74437 200422...

output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok single line: '0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...09642788310 20801182804434259 0'

Test #4:

score: 0
Accepted
time: 495ms
memory: 42064kb

input:

1
500000 500000
0 499999
0 499999
0 499999
0 499999
0 499999
0 499999
0 499999
0 499999
0 499999
0 499999
0 499999
0 499999
0 499999
0 499999
0 499999
0 499999
0 499999
0 499999
0 499999
0 499999
0 499999
0 499999
0 499999
0 499999
0 499999
0 499999
0 499999
0 499999
0 499999
0 499999
0 499999
0 499...

output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok single line: '0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...0 0 0 0 0 0 41666791666750000 0'

Test #5:

score: 0
Accepted
time: 711ms
memory: 109028kb

input:

1
500000 500000
1 499998
1 499998
1 499998
1 499998
1 499998
1 499998
1 499998
1 499998
1 499998
1 499998
1 499998
1 499998
1 499998
1 499998
1 499998
1 499998
1 499998
1 499998
1 499998
1 499998
1 499998
1 499998
1 499998
1 499998
1 499998
1 499998
1 499998
1 499998
1 499998
1 499998
1 499998
1 499...

output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok single line: '0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...0 0 0 0 0 0 41666791666750000 0'

Test #6:

score: 0
Accepted
time: 582ms
memory: 67860kb

input:

1
500000 250000
0 250000
1 250001
2 250002
3 250003
4 250004
5 250005
6 250006
7 250007
8 250008
9 250009
10 250010
11 250011
12 250012
13 250013
14 250014
15 250015
16 250016
17 250017
18 250018
19 250019
20 250020
21 250021
22 250022
23 250023
24 250024
25 250025
26 250026
27 250027
28 250028
29 2...

output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok single line: '0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...918019441588 4838325779633316 0'

Extra Test:

score: 0
Extra Test Passed