QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#147434#6641. XOR Diceqzez#AC ✓1ms3920kbC++141.1kb2023-08-23 09:12:292023-08-25 01:30:38

Judging History

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

  • [2023-08-25 01:30:38]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3920kb
  • [2023-08-23 09:12:29]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<typename T>
ostream& operator << (ostream &out,const vector<T>&x){
	if(x.empty())return out<<"[]";
	out<<'['<<x[0];
	for(int len=x.size(),i=1;i<len;i++)out<<','<<x[i];
	return out<<']';
}
template<typename T>
vector<T> ary(const T *a,int l,int r){
	return vector<T>{a+l,a+1+r};
}
template<typename T>
void debug(T x){
	cerr<<x<<'\n';
}
template<typename T,typename ...S>
void debug(T x,S ...y){
	cerr<<x<<' ',debug(y...);
}
int n,d;
vector<int>ans;
bool chk(int x){
	int n=ans.size();
	for(int S=0;S<(1<<n);S++){
		int sum=0;
		for(int i=0;i<n;i++)if(S>>i&1)sum^=ans[i];
		if((sum^x)%d)return 0;
	}
	return 1;
}
bool dfs(int i){
	if(ans.size()==5)return 1;
	if(i>1e6)return 0;
	if(chk(i)){
		ans.push_back(i);
		if(dfs(i+d))return 1;
		ans.pop_back();
	}
	return dfs(i+d);
}
int main(){
	cin>>n>>d;
	if(!dfs(d))return cout<<"WA\n",0;
	ans.push_back(0);
	for(int i=1;i<=n;i++){
		for(int j=0;j<=5;j++){
			printf("%d%c",ans[j],"\n "[j<5]);
		}
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3764kb

input:

3 2

output:

2 4 6 8 10 0
2 4 6 8 10 0
2 4 6 8 10 0

result:

ok Correct answer

Test #2:

score: 0
Accepted
time: 1ms
memory: 3744kb

input:

100 60

output:

60 960 1020 15360 15420 0
60 960 1020 15360 15420 0
60 960 1020 15360 15420 0
60 960 1020 15360 15420 0
60 960 1020 15360 15420 0
60 960 1020 15360 15420 0
60 960 1020 15360 15420 0
60 960 1020 15360 15420 0
60 960 1020 15360 15420 0
60 960 1020 15360 15420 0
60 960 1020 15360 15420 0
60 960 1020 15...

result:

ok Correct answer

Test #3:

score: 0
Accepted
time: 1ms
memory: 3728kb

input:

99 2

output:

2 4 6 8 10 0
2 4 6 8 10 0
2 4 6 8 10 0
2 4 6 8 10 0
2 4 6 8 10 0
2 4 6 8 10 0
2 4 6 8 10 0
2 4 6 8 10 0
2 4 6 8 10 0
2 4 6 8 10 0
2 4 6 8 10 0
2 4 6 8 10 0
2 4 6 8 10 0
2 4 6 8 10 0
2 4 6 8 10 0
2 4 6 8 10 0
2 4 6 8 10 0
2 4 6 8 10 0
2 4 6 8 10 0
2 4 6 8 10 0
2 4 6 8 10 0
2 4 6 8 10 0
2 4 6 8 10 0
2...

result:

ok Correct answer

Test #4:

score: 0
Accepted
time: 1ms
memory: 3796kb

input:

99 59

output:

59 708 767 45312 45371 0
59 708 767 45312 45371 0
59 708 767 45312 45371 0
59 708 767 45312 45371 0
59 708 767 45312 45371 0
59 708 767 45312 45371 0
59 708 767 45312 45371 0
59 708 767 45312 45371 0
59 708 767 45312 45371 0
59 708 767 45312 45371 0
59 708 767 45312 45371 0
59 708 767 45312 45371 0
...

result:

ok Correct answer

Test #5:

score: 0
Accepted
time: 1ms
memory: 3804kb

input:

93 17

output:

17 34 51 68 85 0
17 34 51 68 85 0
17 34 51 68 85 0
17 34 51 68 85 0
17 34 51 68 85 0
17 34 51 68 85 0
17 34 51 68 85 0
17 34 51 68 85 0
17 34 51 68 85 0
17 34 51 68 85 0
17 34 51 68 85 0
17 34 51 68 85 0
17 34 51 68 85 0
17 34 51 68 85 0
17 34 51 68 85 0
17 34 51 68 85 0
17 34 51 68 85 0
17 34 51 68...

result:

ok Correct answer

Test #6:

score: 0
Accepted
time: 1ms
memory: 3772kb

input:

100 49

output:

49 196 245 2058 2107 0
49 196 245 2058 2107 0
49 196 245 2058 2107 0
49 196 245 2058 2107 0
49 196 245 2058 2107 0
49 196 245 2058 2107 0
49 196 245 2058 2107 0
49 196 245 2058 2107 0
49 196 245 2058 2107 0
49 196 245 2058 2107 0
49 196 245 2058 2107 0
49 196 245 2058 2107 0
49 196 245 2058 2107 0
4...

result:

ok Correct answer

Test #7:

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

input:

100 5

output:

5 10 15 80 85 0
5 10 15 80 85 0
5 10 15 80 85 0
5 10 15 80 85 0
5 10 15 80 85 0
5 10 15 80 85 0
5 10 15 80 85 0
5 10 15 80 85 0
5 10 15 80 85 0
5 10 15 80 85 0
5 10 15 80 85 0
5 10 15 80 85 0
5 10 15 80 85 0
5 10 15 80 85 0
5 10 15 80 85 0
5 10 15 80 85 0
5 10 15 80 85 0
5 10 15 80 85 0
5 10 15 80 8...

result:

ok Correct answer

Test #8:

score: 0
Accepted
time: 1ms
memory: 3720kb

input:

1 57

output:

57 1026 1083 2052 2109 0

result:

ok Correct answer

Test #9:

score: 0
Accepted
time: 1ms
memory: 3768kb

input:

1 22

output:

22 264 286 704 726 0

result:

ok Correct answer

Test #10:

score: 0
Accepted
time: 1ms
memory: 3804kb

input:

1 60

output:

60 960 1020 15360 15420 0

result:

ok Correct answer

Test #11:

score: 0
Accepted
time: 1ms
memory: 3712kb

input:

1 2

output:

2 4 6 8 10 0

result:

ok Correct answer

Test #12:

score: 0
Accepted
time: 1ms
memory: 3732kb

input:

10 24

output:

24 96 120 384 408 0
24 96 120 384 408 0
24 96 120 384 408 0
24 96 120 384 408 0
24 96 120 384 408 0
24 96 120 384 408 0
24 96 120 384 408 0
24 96 120 384 408 0
24 96 120 384 408 0
24 96 120 384 408 0

result:

ok Correct answer