/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 752.0 KiB
#2 Accepted 2ms 560.0 KiB
#3 Accepted 2ms 572.0 KiB
#4 Accepted 59ms 2.465 MiB
#5 Accepted 52ms 3.016 MiB
#6 Accepted 56ms 2.441 MiB
#7 Accepted 58ms 2.414 MiB
#8 Accepted 62ms 3.316 MiB
#9 Accepted 68ms 3.223 MiB
#10 Accepted 50ms 3.008 MiB
#11 Accepted 49ms 3.059 MiB
#12 Accepted 51ms 3.043 MiB
#13 Accepted 51ms 3.074 MiB
#14 Accepted 51ms 3.078 MiB
#15 Accepted 51ms 3.062 MiB
#16 Accepted 52ms 3.035 MiB
#17 Accepted 49ms 3.066 MiB
#18 Accepted 50ms 3.066 MiB
#19 Accepted 51ms 3.066 MiB
#20 Accepted 51ms 3.176 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-11-11 03:26:21
Judged By
Score
100
Total Time
68ms
Peak Memory
3.316 MiB