QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#87294#5750. SiteswapjeffqiWA 2ms3544kbC++141.4kb2023-03-12 12:09:002023-03-12 12:09:01

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-12 12:09:01]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3544kb
  • [2023-03-12 12:09:00]
  • 提交

answer

#include<bits/stdc++.h>
#define rep(i,a,b) for (int i = (a); i <= (b); ++i)
#define drep(i,a,b) for (int i = (a); i >= (b); --i)
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>
#define fi first
#define se second
#define eb emplace_back
#define mp make_pair
using namespace std;
LL read() {
	LL  x = 0,y = 1; char ch = getchar(); while (!isdigit(ch)) {if (ch == '-') y = -y; ch = getchar();}
	while (isdigit(ch)) {x = x*10+ch-'0'; ch = getchar();} return x*y;
}
namespace qiqi {
	const int N = 1e5+5,M = 4; int n,a[N],c[M];
	struct DSU {
		int fa[N],c[N]; LL sum[N];
		void init(int n) {
			rep(i,1,n) {
				fa[i] = i; sum[i] = a[i];
				c[i] = i&1 ? 1 : 2;
			}
		}
		int find(int x) {return x == fa[x] ? x : fa[x] = find(fa[x]);}
		void merge(int x,int y) {
			x = find(x); y = find(y); if (x == y) return;
			fa[y] = x; sum[x] += sum[y];
		}
	} dsu;
	void main() {
		n = read();
		rep(i,1,n) a[i] = read();
		dsu.init(n);
		rep(i,1,n) {
			dsu.merge(i,(i+a[i]-1)%n+1);
			if (a[i]&1) {
				dsu.c[dsu.find(i)] = 3;
			}
		}
		rep(i,1,M-1) c[i] = 0;
		rep(i,1,n) if (i == dsu.fa[i]) {
			int x = dsu.sum[i]/n;
			if (!(n&1) || dsu.c[i] == 3) c[dsu.c[i]] += x;
			else {
				c[dsu.c[i]] += (x+1)/2;
				c[dsu.c[i]^3] += x/2;
			}
		}
		rep(i,1,M-1) printf("%d ",c[i]); puts("");
	}
}
int main() {
	int T = read(); while (T--) qiqi::main(); return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: -100
Wrong Answer
time: 1ms
memory: 3480kb

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 33 0 
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 23 4 
3 9 31 
3 10 51 
7 9 28 
19 10 39 
0 3 51 
2...

result:

wrong answer 38th numbers differ - expected: '11', found: '33'