QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#90893#5750. SiteswapMr_EightAC ✓3ms5612kbC++142.8kb2023-03-26 02:23:402023-03-26 02:23:42

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-26 02:23:42]
  • 评测
  • 测评结果:AC
  • 用时:3ms
  • 内存:5612kb
  • [2023-03-26 02:23:40]
  • 提交

answer

//#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <climits>
#include <functional>
#include <cstring>
#include <string>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <complex>
#include <random>
#include <cassert>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/priority_queue.hpp>
#define itn int
#define nit int
#define ll long long
#define ms multiset
#define F(i,a,b) for(int i=a,i##end=b;i<=i##end;++i)
#define UF(i,a,b) for(int i=a,i##end=b;i>=i##end;--i)
#define re register
#define ri re int
#define il inline
#define pii pair<int,int>
#define cp complex<double>
#define vi vector<int>
#define ull unsigned long long
#define mem0(x) memset(x,0,sizeof(x))
#define mem0x3f(x) memset(x,0x3f,sizeof(x))
using namespace std;
//using namespace __gnu_pbds;
const double Pi=acos(-1);
namespace fastIO {
	template<class T>
	inline void read(T &x) {
		x=0;
		bool fu=0;
		char ch=0;
		while(ch>'9'||ch<'0') {
			ch=getchar();
			if(ch=='-')fu=1;
		}
		while(ch<='9'&&ch>='0') x=(x*10-48+ch),ch=getchar();
		if(fu)x=-x;
	}
	inline int read() {
		int x=0;
		bool fu=0;
		char ch=0;
		while(ch>'9'||ch<'0') {
			ch=getchar();
			if(ch=='-')fu=1;
		}
		while(ch<='9'&&ch>='0') x=(x*10-48+ch),ch=getchar();
		return fu?-x:x;
	}
	template<class T,class... Args>
	inline void read(T& t,Args&... args) {
		read(t);
		read(args...);
	}
	char _n_u_m_[40];
	template<class T>
	inline void write(T x) {
		if(x==0){
			putchar('0');
			return;
		}
		T tmp = x > 0 ? x : -x ;
		if( x < 0 ) putchar('-') ;
		int cnt = 0 ;
		while( tmp > 0 ) {
			_n_u_m_[ cnt ++ ] = tmp % 10 + '0' ;
			tmp /= 10 ;
		}
		while( cnt > 0 ) putchar(_n_u_m_[ -- cnt ]) ;
	}
	template<class T>
	inline void write(T x ,char ch) {
		write(x);
		putchar(ch);
	}
}
using namespace fastIO;
#define int long long
int n,a[1000002],I;
ll x,y,z;
vector<int>v;
bool aa,b;
bool vis[1000002];
inline void solve(int now){
	if(n&1){
		if(aa&b)z+=now;
		else if(aa)x+=(now+1)>>1,y+=now>>1;
		else x+=now>>1,y+=(now+1)>>1;
		return;
	}
	if(aa&&b)z+=now;
	else if(aa)x+=now;
	else y+=now;
}
inline void dfs(int pos,int now){
	assert(a[pos]);
	if(vis[pos]){
		assert(pos==I);
		if((now&n)&1)aa=b=true;
		solve(now);
		return;
	}
	if(pos+(now&n)&1)aa=true;
	else b=true;
	vis[pos]=true;
	v.push_back(now);
	dfs((pos+a[pos]-1)%n+1,now+(pos+a[pos]-1)/n);
}
signed main() {
	F(asdf,1,read()){
		read(n);x=y=z=0;
		F(i,1,n)read(a[i]),vis[i]=false;
		F(i,1,n)if(!vis[i]&&a[i])I=i,aa=b=false,v.clear(),dfs(i,0);
	//	if(n&1)z+=x,z+=y,x=y=0;
		write(x,' ');write(y,' ');write(z,'\n');
	}
	return 0;
}


详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 3300kb

input:

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

output:

0 0 2
2 1 0
3 2 0

result:

ok 9 numbers

Test #2:

score: 0
Accepted
time: 2ms
memory: 3340kb

input:

100
10
94 8 4 52 7 53 16 96 29 1
10
23 35 96 34 86 39 16 72 63 96
10
51 2 46 21 15 31 41 28 42 83
10
75 67 64 88 46 98 3 17 14 98
10
24 77 54 48 16 37 23 88 99 84
10
52 93 44 87 84 80 37 22 73 28
10
35 80 96 60 75 19 100 63 54 88
10
38 49 63 68 29 67 3 57 68 48
10
89 57 51 21 61 16 100 73 99 83
10
6...

output:

2 0 34
0 0 56
0 0 36
0 0 57
4 0 51
0 13 47
25 14 28
0 0 49
10 0 55
0 0 30
9 0 48
0 0 48
15 11 22
0 7 34
9 0 39
4 7 26
9 0 56
6 10 49
6 5 32
0 0 45
7 4 44
8 0 46
7 4 60
24 19 0
0 0 57
0 13 28
9 1 37
0 0 58
7 0 38
0 0 40
6 6 21
3 9 31
3 10 51
7 9 28
19 10 39
0 3 51
22 8 29
0 8 40
7 0 51
0 0 40
0 16 45...

result:

ok 300 numbers

Test #3:

score: 0
Accepted
time: 2ms
memory: 3336kb

input:

100
54
386 856 526 874 268 682 718 686 344 116 412 25 82 99 203 496 2 949 757 584 713 137 518 782 485 769 852 483 906 918 152 211 561 355 527 591 585 506 57 49 929 767 317 287 475 186 267 199 227 390 124 373 309 444
85
491 676 471 547 85 660 974 510 349 341 89 557 936 180 632 919 810 887 498 426 644...

output:

0 17 437
16 16 485
0 0 559
4 2 413
0 7 490
1 1 510
0 0 424
0 0 514
0 38 386
1 0 473
0 0 667
7 7 507
22 0 490
0 41 472
0 0 580
0 0 526
0 0 441
0 55 423
0 0 467
18 18 523
0 0 517
0 0 565
0 0 486
0 0 492
0 0 495
21 21 519
2 6 437
47 54 302
0 16 510
21 0 482
82 82 358
3 31 334
30 0 355
54 81 367
20 20 5...

result:

ok 300 numbers

Test #4:

score: 0
Accepted
time: 0ms
memory: 5612kb

input:

1
100000
173636392 284273077 698424898 5611435 902118118 237290573 833213168 776939793 5890016 899034976 776348831 518211565 717077869 409849809 602678259 232306557 142010208 148869327 319416709 814019507 368419097 599868858 338329488 88679485 555698506 294475578 715560768 893338866 371965797 381639...

output:

0 0 500204201

result:

ok 3 number(s): "0 0 500204201"

Test #5:

score: 0
Accepted
time: 3ms
memory: 5388kb

input:

2
27355
460071504 378603706 534707902 580629932 984454706 47518920 863592507 534539132 32710375 333680435 834350586 804715694 851485226 611532912 367032640 220290347 971674730 390231297 220133525 423772279 762042987 778306763 418668366 841875081 59148109 99723573 442421595 652768507 141655948 405219...

output:

0 0 501084219
5102 5102 500096109

result:

ok 6 numbers