QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#61690#1807. Distribute the BarsAlienCollapsarWA 4ms6008kbC++141.2kb2022-11-14 16:17:262022-11-14 16:17:48

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-11-14 16:17:48]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:6008kb
  • [2022-11-14 16:17:26]
  • 提交

answer

#include<cstdio>
#include<iostream>
#include<vector>
using namespace std;
const int Maxn=1e5+5;
int pri[Maxn],tot;
bool vis[Maxn];
void getPrime(int n){
    for(int i=2;i<=n;++i){
        if(!vis[i])pri[++tot]=i;
        for(int j=1;j<=tot&&i*pri[j]<=n;++j){
            vis[i*pri[j]]=1;
            if(i%pri[j]==0)break;
        }
    }
}
vector<int>ans[Maxn];
int main(){
    int n;cin>>n;
    getPrime(n);
    if(!vis[n]){cout<<-1<<'\n';return 0;}
    if(n&1){
        int a,b;
        for(int i=1;i<=tot;++i)
            if(n%pri[i]==0){a=pri[i],b=n/pri[i];break;}
        int m=a*(b-a);
        for(int i=1,j=m,k=0;i<j;++i,--j,++k){
            ans[k].emplace_back((i<<1)-1);
            ans[k].emplace_back((j<<1)-1);
        }
        int st=0;
        for(int i=m+1;i<=n;i+=a,(++st)%=a)
            for(int j=0;j<a;++j)
                ans[(st+j)%a].emplace_back((i+j<<1)-1);
        cout<<a<<'\n';
        for(int i=0;i<a;++i){
            cout<<ans[i].size()<<' ';
            for(int x:ans[i])cout<<x<<' ';cout<<'\n';
        }
    }else{
        cout<<(n>>1)<<'\n';
        for(int i=1,j=n;i<j;++i,--j)
            cout<<2<<' '<<(i<<1)-1<<' '<<(j<<1)-1<<'\n';
    }
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 4ms
memory: 5680kb

input:

4

output:

2
2 1 7
2 3 5

result:

ok OK (2 groups)

Test #2:

score: 0
Accepted
time: 2ms
memory: 5824kb

input:

2

output:

-1

result:

ok OK (impossible)

Test #3:

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

input:

3

output:

-1

result:

ok OK (impossible)

Test #4:

score: -100
Wrong Answer
time: 3ms
memory: 6008kb

input:

1659

output:

3
5 1 3299 3301 3311 3315 
5 3 3297 3303 3307 3317 
5 5 3295 3305 3309 3313 

result:

wrong answer Not all bars are distributed