QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#300245 | #1807. Distribute the Bars | JooDdae | WA | 1ms | 3552kb | C++20 | 805b | 2024-01-07 21:46:14 | 2024-01-07 21:46:15 |
Judging History
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