QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#49193 | #1807. Distribute the Bars | Crysfly | WA | 4ms | 8396kb | C++11 | 2.6kb | 2022-09-19 17:20:09 | 2022-09-19 17:20:12 |
Judging History
answer
// what is matter? never mind.
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define int long long
using namespace std;
inline int read()
{
char c=getchar();int x=0;bool f=0;
for(;!isdigit(c);c=getchar())f^=!(c^45);
for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
if(f)x=-x;return x;
}
#define mod 1000000007
struct modint{
int x;
modint(int o=0){x=o;}
modint &operator = (int o){return x=o,*this;}
modint &operator +=(modint o){return x=x+o.x>=mod?x+o.x-mod:x+o.x,*this;}
modint &operator -=(modint o){return x=x-o.x<0?x-o.x+mod:x-o.x,*this;}
modint &operator *=(modint o){return x=(__int128)x*o.x%mod,*this;}
modint &operator ^=(int b){
modint a=*this,c=1;
for(;b;b>>=1,a*=a)if(b&1)c*=a;
return x=c.x,*this;
}
modint &operator /=(modint o){return *this *=o^=mod-2;}
friend modint operator +(modint a,modint b){return a+=b;}
friend modint operator -(modint a,modint b){return a-=b;}
friend modint operator *(modint a,modint b){return a*=b;}
friend modint operator /(modint a,modint b){return a/=b;}
friend modint operator ^(modint a,int b){return a^=b;}
friend bool operator ==(modint a,int b){return a.x==b;}
friend bool operator !=(modint a,int b){return a.x!=b;}
bool operator ! () {return !x;}
modint operator - () {return x?mod-x:0;}
bool operator <(const modint&b)const{return x<b.x;}
};
inline modint qpow(modint x,int y){return x^y;}
vector<modint> fac,ifac,iv;
inline void initC(int n)
{
if(iv.empty())fac=ifac=iv=vector<modint>(2,1);
int m=iv.size(); ++n;
if(m>=n)return;
iv.resize(n),fac.resize(n),ifac.resize(n);
For(i,m,n-1){
iv[i]=iv[mod%i]*(mod-mod/i);
fac[i]=fac[i-1]*i,ifac[i]=ifac[i-1]*iv[i];
}
}
inline modint C(int n,int m){
if(m<0||n<m)return 0;
return initC(n),fac[n]*ifac[m]*ifac[n-m];
}
inline modint sign(int n){return (n&1)?(mod-1):(1);}
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;
#define maxn 200005
#define inf 0x3f3f3f3f
int n;
vi o[maxn];
signed main()
{
n=read();
if(n%2==0&&n>2){
cout<<n/2<<'\n';
For(i,1,n/2)cout<<2<<' '<<i*2-1<<" "<<(n-i+1)*2-1<<"\n";
exit(0);
}
For(d,3,n-1)
if(n%d==0){
cout<<d<<endl;
For(i,0,d-1)
For(j,0,d-1){
int g=(i-j+d)%d;
o[g].pb((i*d+j)*2+1);
}
for(int i=d*d+1,j=n,k=0;i<j;++i,--j,k=(k+1)%d) o[k].pb(i*2-1),o[k].pb(j*2-1);
For(i,0,d-1)
for(auto t:o[i])cout<<t<<" \n"[t==o[i].back()];
// For(i,0,d-1)cout<<accumulate(o[i].begin(),o[i].end(),0)<<endl;
exit(0);
}
puts("-1");
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 8396kb
input:
4
output:
2 2 1 7 2 3 5
result:
ok OK (2 groups)
Test #2:
score: 0
Accepted
time: 2ms
memory: 8172kb
input:
2
output:
-1
result:
ok OK (impossible)
Test #3:
score: 0
Accepted
time: 2ms
memory: 8240kb
input:
3
output:
-1
result:
ok OK (impossible)
Test #4:
score: -100
Wrong Answer
time: 4ms
memory: 8284kb
input:
1659
output:
3 1 9 17 19 3317 25 3311 31 3305 37 3299 43 3293 49 3287 55 3281 61 3275 67 3269 73 3263 79 3257 85 3251 91 3245 97 3239 103 3233 109 3227 115 3221 121 3215 127 3209 133 3203 139 3197 145 3191 151 3185 157 3179 163 3173 169 3167 175 3161 181 3155 187 3149 193 3143 199 3137 205 3131 211 3125 217 3119...
result:
wrong answer Integer 3269 violates the range [1, 1659]