/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Wrong Answer 2ms 324.0 KiB
#3 Wrong Answer 2ms 324.0 KiB
#4 Accepted 33ms 3.062 MiB
#5 Time Exceeded ≥2092ms ≥2.816 MiB
#6 Accepted 32ms 3.07 MiB
#7 Accepted 33ms 3.059 MiB
#8 Accepted 38ms 3.824 MiB
#9 Accepted 43ms 4.062 MiB
#10 Time Exceeded ≥2067ms ≥2.809 MiB
#11 Time Exceeded ≥2087ms ≥2.816 MiB
#12 Time Exceeded ≥2088ms ≥2.812 MiB
#13 Time Exceeded ≥2081ms ≥2.812 MiB
#14 Time Exceeded ≥2082ms ≥2.812 MiB
#15 Time Exceeded ≥2074ms ≥2.562 MiB
#16 Time Exceeded ≥2089ms ≥2.77 MiB
#17 Time Exceeded ≥2092ms ≥2.68 MiB
#18 Time Exceeded ≥2078ms ≥2.641 MiB
#19 Wrong Answer 1734ms 3.828 MiB
#20 Wrong Answer 184ms 3.816 MiB

Code

// I AM A MUSLIM

#include "bits/stdc++.h"

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")

#define fastIO std::ios::sync_with_stdio(0);std::cin.tie(0)
#define ll long long int
#define flush fflush(stdout)
#define bl printf("\n")
#define yn(a, b) printf("%s\n", a >= b ? "Yes":"No")
// #define int ll

using pii = std::pair<int,int>;

const int MOD = 1000000007;
// const int MOD = 998244353;
const int mxN = 500005, inf = INT_MAX;

signed main() {
    // fastIO;
    int testCases=1;
    scanf("%d",&testCases);
    // std::cin>>testCases;
    
    for (int TC = 1; TC <= testCases; TC++) {
        int N;
        scanf("%d",&N);
        int par[N+1] = {0}, link[N+1], tot = 0;
        memset(link, -1, sizeof link);
        
        int a[N]; for (auto &i : a) scanf("%d",&i);
        
        for (int i = 0; i < N; i++) {
            int at = i+a[i];
            if (at < N) link[i] = at;
            if (par[i]) continue;
            tot++;
            while (at < N) {
                par[at]++;
                at += a[at];
            }
        }
        // printf("%d\n", tot);
        
        for (int i = 0; i < N; i++) {
            int L = link[i];
            // printf("(%d %d)\n", i, L);
            int ans = tot;
            if (L != -1 && par[L] == 1) ans++;
            printf("%d ",ans);
        } bl;
        
    }
    
    return 0;
}

/*

*/

Information

Submit By
Type
Submission
Problem
P1066 Light switches
Contest
Brain Booster #4
Language
C++20 (G++ 13.2.0)
Submit At
2024-07-14 18:25:20
Judged At
2024-10-03 13:35:14
Judged By
Score
30
Total Time
≥2092ms
Peak Memory
≥4.062 MiB