/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 1ms 540.0 KiB
#3 Accepted 2ms 540.0 KiB
#4 Accepted 24ms 2.414 MiB
#5 Accepted 29ms 3.02 MiB
#6 Accepted 24ms 2.422 MiB
#7 Accepted 24ms 2.27 MiB
#8 Accepted 34ms 3.188 MiB
#9 Accepted 37ms 3.5 MiB
#10 Accepted 25ms 3.027 MiB
#11 Accepted 25ms 3.02 MiB
#12 Accepted 25ms 3.105 MiB
#13 Accepted 27ms 2.977 MiB
#14 Accepted 25ms 3.09 MiB
#15 Accepted 25ms 3.02 MiB
#16 Accepted 25ms 3.102 MiB
#17 Accepted 25ms 3.086 MiB
#18 Accepted 25ms 3.02 MiB
#19 Accepted 26ms 3.02 MiB
#20 Accepted 27ms 3.02 MiB

Code

#include<bits/stdc++.h>
using namespace std;
const long long M=1e7+1,MOD=1000000007;
typedef long long ll;
#define double long double
#define debug(x) cout<<x<<endl

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin>>t;
    while(t--)
    {
       int n;
       cin>>n;
       vector<int>a(n+1);
       for(int i=1;i<=n;i++)cin>>a[i];
       vector<int>L(n+2,0);
       int single=0;
       for(int i=1;i<=n;i++){
           int limtit=i+a[i];
           if(limtit<=n)L[limtit]++;
           single+=(L[i]==0);
       }
       for(int i=1;i<=n;i++){
             int limtit=i+a[i];
             int add=0;
             if(limtit<=n && L[limtit]==1)add++;
             cout<<single+add<<" ";
       }
       cout<<"\n";


    }


    return 0;
 
}

Information

Submit By
Type
Submission
Problem
P1066 Light switches
Language
C++20 (G++ 13.2.0)
Submit At
2024-07-14 08:43:38
Judged At
2024-07-14 08:43:38
Judged By
Score
100
Total Time
37ms
Peak Memory
3.5 MiB