QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#244525#5750. Siteswapucup-team870#WA 1ms3592kbC++14916b2023-11-09 11:12:222023-11-09 11:12:24

Judging History

你现在查看的是最新测评结果

  • [2023-11-09 11:12:24]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3592kb
  • [2023-11-09 11:12:22]
  • 提交

answer

#include<bits/stdc++.h>
#define For(i,j,k) for(int i=j;i<=k;++i)
using namespace std;
typedef long long ll;
int a[100005]; bool fl[100005];
int main(){
    int _; scanf("%d",&_);
    while(_--){
        int n; scanf("%d",&n);
        For(i,0,n-1) scanf("%d",&a[i]),fl[i]=0;
        //
        ll x=0,y=0,z=0;
        For(i,0,n-1) if (a[i]&&!fl[i]){
            ll cnt=0,st=i,now=i; fl[i]=1;
            while(1){
                cnt+=a[now]; now=(now+a[now])%n;
                if (!a[now]) exit(24442226);
                if (fl[now]){
                    if (now!=st) exit(466616666);
                    break;
                }
                fl[now]=1;
            }
            //ans
            cnt=cnt/n;
            if (a[i]%2==1) z+=cnt;
            else if (i%2==1) x+=cnt;
            else y+=cnt;
        }
        printf("%lld %lld %lld\n",x,y,z);
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3592kb

input:

3
3
1 5 0
6
4 6 4 0 4 0
2
6 4

output:

0 0 2
1 2 0
2 3 0

result:

wrong answer 4th numbers differ - expected: '2', found: '1'