QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#18943 | #1807. Distribute the Bars | foreverlasting# | WA | 4ms | 6060kb | C++20 | 4.5kb | 2022-01-27 16:52:08 | 2022-05-06 03:21:56 |
Judging History
answer
//2022.1.27 by ljz
//email [email protected]
//if you find any bug in my code
//please tell me
#include<bits/stdc++.h>
//#include<ext/pb_ds/tree_policy.hpp>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;
#define res int
#define LL long long
#define Inf 0x3f3f3f3f
#define sup 0x7fffffff
#define inf 0x3f3f3f3f
#define INF 2000000000000000000
//#define unl __int128
#define eps 1e-10
#define RG
#define db double
#define pc(x) __builtin_popcount(x)
#define ctz(x) __builtin_ctz(x)
//#define pc(x) __builtin_popcountll(x)
typedef pair<int,int> Pair;
//#define poly vector<int>
#define mp make_pair
#define fi first
#define se second
#define pi acos(-1.0)
#define pb push_back
#define ull unsigned LL
#define uint unsigned int
#define lowbit(x) ((x)&-(x))
#define gc getchar
#define ld long db
//template <class T>using Tree=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//inline int gc() {
// static char buf[100000],*p1,*p2;
// return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
//char sr[1<<21],z[20];
//int C=-1,Z=0;
//inline void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
//inline void print(RG LL x){
// if(C>1<<20)Ot();if(x<0)sr[++C]='-',x=-x;
// while(z[++Z]=x%10+48,x/=10);
// while(sr[++C]=z[Z],--Z);
//}
template <typename T> inline void Read(T &x) {
res c=gc();
bool f=false;
for(x=0;!isdigit(c);c=gc())if(c=='-')f=true;
for(;isdigit(c);c=gc())x=x*10+c-'0';
if(f)x=-x;
}
inline int read() {
res s=0,ch=gc(),w=1;
while(ch<'0'||ch>'9'){
if(ch=='-')w=-1;
else if(ch==EOF)break;
ch=gc();
}
while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
return s*w;
}
inline LL Read() {
RG LL s=0;
res ch=gc(),w=1;
while(ch<'0'||ch>'9'){
if(ch=='-')w=-1;
else if(ch==EOF)break;
ch=gc();
}
while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
return s*w;
}
inline void write(RG __int128 x){
if(x>10)write(x/10);
putchar(int(x%10)+'0');
}
const int kcz=1000000007;
const int G=3,GI=332748118;
//inline void add(res &x,const res &y){
// x+=y,x>=kcz?x-=kcz:1;
//}
//inline int Add(const res &x,const res &y){
// return x+y>=kcz?x+y-kcz:x+y;
//}
//inline int mul(const res &x,const res &y){
// return int(1ll*x*y%kcz);
//}
#define add(x,y) ((x)+=(y),(x)>=kcz?(x)-=kcz:1)
#define Add(x,y) ((x)+(y)>=kcz?(x)+(y)-kcz:(x)+(y))
#define mul(x,y) (int)((LL)(x)*(y)%kcz)
#define Mul(x,y,d) (int)((ull)(x)*(y)/(d)%kcz)
inline int qpow(res x,res y=kcz-2){
res ret=1;
while(y){
if(y&1)ret=mul(ret,x);
x=mul(x,x),y>>=1;
}
return ret;
}
inline int qpow(res x,res y,const res &ljc){
res ret=1;
while(y){
if(y&1)ret=(int)(1ll*ret*x%ljc);
x=(int)(1ll*x*x%ljc),y>>=1;
}
return ret;
}
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
//cloclim_t start=cloclim();
//inline void clim(){
// if(1.0*(cloclim()-start)/CLOCKS_PER_SEC>0.1)exit(0);
//}
//2022.1.27 by ljz
//email [email protected]
//if you find any bug in my code
//please tell me
namespace MAIN{
vector<int> A[100000+10];
inline void MAIN(){
res n=read();
if(n&1){
res p=-1;
for(res i=2;i*i<=n;i++){
if(n%i==0){
p=i;break;
}
}
if(p==-1){puts("-1");return;}
for(res i=1;i<=p;i++){
for(res j=1;j<=p;j++){
res t=(p-j+i)%p;
if(!t)t=p;
A[i].pb((t-1)*p+j);
}
}
for(res i=p*p+1;i<=n;i+=2*p){
for(res j=i;j<=i+p-1;j++){
A[j-i+1].pb(j);
}
for(res j=i+p;j<=i+2*p-1;j++){
A[i+2*p-j].pb(j);
}
}
printf("%d\n",p);
for(res i=1;i<=p;i++){
printf("%d ",int(A[i].size()));
for(auto x:A[i])printf("%d ",2*x-1);
puts("");
}
}
else {
printf("%d\n",n/2);
for(res i=1;i<=n/2;i++)printf("%d %d %d\n",2,2*i-1,2*(n-i)+1);
}
}
}
int main(){
// srand(time(0));
// freopen("1.in","r",stdin);
// freopen("1.out","w",stdout);
res Case=1;
for(res T=1;T<=Case;T++)MAIN::MAIN();
// Ot();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 4ms
memory: 6060kb
input:
4
output:
2 2 1 7 2 3 5
result:
ok OK (2 groups)
Test #2:
score: -100
Wrong Answer
time: 2ms
memory: 5992kb
input:
2
output:
1 2 1 3
result:
wrong answer M=1 is too small