71922024-01-03 11:50:40horvathabelKazamatacpp17Wrong answer 0/4039ms5732 KiB
#include <bits/stdc++.h>
using namespace std;
void solve(){
    int n;
    cin>>n;
    int x;
    cin>>x;
    int ans=0;
    vector<pair<bool,int>> help;
    help.resize(n+1,{0,0});
    int tol=n+1;
    if (x!=0){
        tol=x;
        ans+=n-abs((0-x)%n);
    }
    int rs=0;
    bool streak=false;
    int cnt=0;
    int j=0;
    for (int i=1; i<n;i++){
        int kulcs;
        cin>>kulcs;
        kulcs+=rs;
        kulcs%=n;
        help[kulcs]={true,rs};
        if (streak){
            j++;
            if (j==cnt) streak=false;
        }
        else{
            if (!help[i].first && tol>i){
                ans++;
                rs++;
            }
            if(help[i].first){
                streak=true;
                cnt=rs-help[i].second;
                j=0;
            }
        }
    }
    cout<<ans;

}
int main()
{
    int t=1;
    //cin>>t;
    while (t--) solve();
}
SubtaskSumTestVerdictTimeMemory
base0/40
1Wrong answer0/03ms1808 KiB
2Wrong answer0/020ms2764 KiB
3Wrong answer0/23ms2272 KiB
4Wrong answer0/23ms2484 KiB
5Wrong answer0/23ms2692 KiB
6Wrong answer0/23ms2784 KiB
7Wrong answer0/23ms3028 KiB
8Wrong answer0/23ms3208 KiB
9Wrong answer0/23ms3340 KiB
10Wrong answer0/23ms3500 KiB
11Wrong answer0/239ms5064 KiB
12Wrong answer0/239ms5272 KiB
13Wrong answer0/239ms5500 KiB
14Wrong answer0/239ms5480 KiB
15Wrong answer0/239ms5568 KiB
16Wrong answer0/239ms5692 KiB
17Wrong answer0/239ms5680 KiB
18Wrong answer0/239ms5648 KiB
19Wrong answer0/239ms5732 KiB
20Wrong answer0/239ms5648 KiB
21Wrong answer0/239ms5644 KiB
22Wrong answer0/239ms5644 KiB