QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#300245#1807. Distribute the BarsJooDdaeWA 1ms3552kbC++20805b2024-01-07 21:46:142024-01-07 21:46:15

Judging History

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

  • [2024-01-07 21:46:15]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3552kb
  • [2024-01-07 21:46:14]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;


int main() {
    cin.tie(0)->sync_with_stdio(0);
    int n; cin >> n;

    if(n % 2 == 0) {
        cout << n/2 << "\n";
        for(int i=1;i<=n/2;i++) cout << "2 " << i*2-1 << " " << (n-i+1)*2-1 << "\n";
        return 0;
    }

    int k = 0;
    for(int i=n-1;i>1;i--) if(n % i == 0) k = i;
    if(!k) return cout << -1, 0;

    vector<vector<int>> ans(k);
    for(int i=0;i<k;i++) for(int j=0;j<k;j++) ans[i].push_back((j*k+(i+j)%k)*2+1);
    for(int i=0, j=0;i<k;i++) while(ans[i].size() < n/k) ans[i].push_back((k*k+j)*2+1), ans[i].push_back((n-j)*2-1), j++;

    cout << k << "\n";
    for(auto v : ans) {
        cout << n/k;
        for(auto x : v) cout << " " << x;
        cout << "\n";
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3436kb

input:

4

output:

2
2 1 7
2 3 5

result:

ok OK (2 groups)

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3552kb

input:

2

output:

1
2 1 3

result:

wrong answer M=1 is too small