/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 3ms 2.004 MiB
#2 Accepted 6ms 2.02 MiB
#3 Accepted 4ms 2.066 MiB
#4 Time Exceeded ≥2074ms ≥11.176 MiB
#5 Time Exceeded ≥2091ms ≥11.234 MiB
#6 Time Exceeded ≥2080ms ≥11.238 MiB
#7 Time Exceeded ≥2068ms ≥11.145 MiB
#8 Time Exceeded ≥2080ms ≥11.043 MiB
#9 Time Exceeded ≥2084ms ≥11.09 MiB
#10 Time Exceeded ≥2076ms ≥11.121 MiB
#11 Time Exceeded ≥2084ms ≥11.102 MiB
#12 Time Exceeded ≥2088ms ≥11.055 MiB
#13 Time Exceeded ≥2074ms ≥11.117 MiB
#14 Time Exceeded ≥2086ms ≥11.102 MiB
#15 Time Exceeded ≥2077ms ≥11.191 MiB
#16 Time Exceeded ≥2093ms ≥11.219 MiB
#17 Time Exceeded ≥2095ms ≥11.098 MiB
#18 Time Exceeded ≥2085ms ≥11.051 MiB
#19 Time Exceeded ≥2068ms ≥11.219 MiB
#20 Time Exceeded ≥2080ms ≥11.227 MiB

Code

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ps(b) cout << (b ? "YES" : "NO") << '\n'
#define pc cout << "Case " << tc << ": "
#ifdef LOCAL
#include "def.h"
#else
#define ck(...) 
#endif
const ll M = 1e9 + 7, N = 2e5 + 5;
ll n;
vector<ll> v(N);
ll cnt(ll in){
    ll c = 0, i, j;
    set<ll> st;
    for (i = 0; i < n;++i){
        if(st.find(i) != st.end())
            continue;
        c++;
        if (i == in) continue;
        for (j = i; j < n; j = j + v[j]){
            if(st.find(j) != st.end())
                break;
            st.insert(j);
            if(j==in) break;
        }
    }
    return c;
}
void test(int tc) {
    ll a = 0, b = 0, c = 0, d = 0, i = 0, j = 0, k = 0, m = 0, q = 0;
    cin >> n;
    for (i = 0; i < n; ++i) { cin >> v[i]; }
    for (i = 0; i < n;++i) {
        cout << cnt(i) << ' ';
    }
    cout << '\n';
}

signed main() {
    cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit|cin.badbit);
    int tc = 0, t = 1;
    cin >> t;
    while (tc < t) test(++tc);
    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 17:20:05
Judged At
2024-10-03 13:36:16
Judged By
Score
15
Total Time
≥2095ms
Peak Memory
≥11.238 MiB