QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#353425#7263. Team CompetitionNaganohara_YoimiyaTL 0ms0kbC++141.5kb2024-03-14 08:48:132024-03-14 08:48:13

Judging History

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

  • [2024-03-14 08:48:13]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-03-14 08:48:13]
  • 提交

answer

#include<bits/stdc++.h>

#define ll long long
#define mk make_pair
#define fi first
#define se second

using namespace std;

inline int read(){
	int x=0,f=1;char c=getchar();
	for(;(c<'0'||c>'9');c=getchar()){if(c=='-')f=-1;}
	for(;(c>='0'&&c<='9');c=getchar())x=x*10+(c&15);
	return x*f;
}

const int mod=998244353;
int ksm(int x,ll y,int p=mod){
	int ans=1;y%=(p-1);
	for(int i=y;i;i>>=1,x=1ll*x*x%p)if(i&1)ans=1ll*ans*x%p;
	return ans%p;
}
int inv(int x,int p=mod){return ksm(x,p-2,p)%p;}
mt19937 rnd(time(0));
int randint(int l,int r){return rnd()%(r-l+1)+l;}
void add(int &x,int v){x+=v;if(x>=mod)x-=mod;}
void Mod(int &x){if(x>=mod)x-=mod;}
int cmod(int x){if(x>=mod)x-=mod;return x;}

template<typename T>void cmax(T &x,T v){x=max(x,v);}
template<typename T>void cmin(T &x,T v){x=min(x,v);}

struct Node{int x,y,z;Node(int X=0,int Y=0,int Z=0):x(X),y(Y),z(Z){}};
void solve(){
	vector<Node>ans;
	auto op=[&](int x,int y,int z){ans.emplace_back(Node(x,y,z));};
	int n=read();
	if(n&1){
		for(int i=0;i<n;i++)for(int d=1;d<=(n-1)/2;d++)op(i,(i+d)%n,(i-d+n)%n);
	}
	else{
		n--;
		for(int i=0;i<n;i++)for(int d=1;d<=(n-1)/2;d++)op(i,(i+d)%n,(i-d+n)%n);
		for(int i=0;i<n;i++)for(int d=2;d<=(n-1)/2;d++)op(i,(i+d)%n,(i-d+n)%n);
		for(int i=0;i<n;i++)op(i,(i+1)%n,n),op(i,(i+1)%n,n),op(i,(i+2)%n,n);
	}
	cout<<ans.size()<<'\n';
	for(auto [x,y,z]:ans)cout<<x+1<<" "<<y+1<<" "<<z+1<<'\n';
}

signed main(void){
	
	int tt=read();while(tt--)solve();

	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

5

output:


result: