QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#596932#6339. CookiesMispertion#0 0ms3696kbC++232.2kb2024-09-28 16:43:352024-09-28 16:43:37

Judging History

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

  • [2024-09-28 16:43:37]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:3696kb
  • [2024-09-28 16:43:35]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
#define int ll
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define mispertion ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define F first
#define S second
#define getlast(s) (*s.rbegin())
#define debg cout << "OK\n"

const ld PI = 3.1415926535;
const int N = 1e5+5;
const int M = 50 + 1;
const int mod = 1e9+7;
const int infi = 1e15;
const ll infl = LLONG_MAX;
const int P = 31;

int mult(int a, int b) {
    return a * 1LL * b % mod;
}

int sum(int a, int b) { 
    if (a + b < 0)
        return a + b + mod;
    if (a + b >= mod)
        return a + b - mod;
    return a + b;
}

ll binpow(ll a, ll n) {
    if (n == 0)
        return 1;
    if (n % 2 == 1) {
        return binpow(a, n - 1) * a % mod;
    } else {
        ll b = binpow(a, n / 2);
        return b * b % mod;
    }
}

int n, a[N], m, b[N], dp[N];

void solve(){
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    cin >> m;
    for(int i = 1; i <= m; i++)
        cin >> b[i];
    dp[0] = 1;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            if(i >= b[j])
                dp[i] |= dp[i - b[j]];
        }
    }
    if(!dp[n]){
        cout << -1 << '\n';
        return;
    }
    vector<vector<int>> ans = {};
    int ci = n;
    while(ci > 0){
        int j = -1;
        for(int k = 1; k <= m; k++){
            if(ci >= b[k] && dp[ci - b[k]])
                j = b[k];
        }
        vector<int> da = {};
        for(int i = ci; i >= ci - j + 1; i--){
            da.pb(i);
        }
        ans.pb(da);
        ci = ci - j;
    }
    cout << sz(ans) << '\n';
    for(auto e : ans){
        cout << sz(e) << ' ';
        for(auto e1 : e){
            cout << e1 << ' ';
        }
        cout << '\n';
    } 
}   

signed main() {
    mispertion;
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 6
Accepted
time: 0ms
memory: 3648kb

input:

1
1
1
1

output:

1
1 1 

result:

ok good!

Test #2:

score: 6
Accepted
time: 0ms
memory: 3696kb

input:

2
1 1
1
1

output:

2
1 2 
1 1 

result:

ok good!

Test #3:

score: 6
Accepted
time: 0ms
memory: 3616kb

input:

2
1 1
1
2

output:

1
2 2 1 

result:

ok good!

Test #4:

score: 6
Accepted
time: 0ms
memory: 3636kb

input:

2
1 1
2
1 2

output:

1
2 2 1 

result:

ok good!

Test #5:

score: 6
Accepted
time: 0ms
memory: 3632kb

input:

4
1 1 1 1
2
2 3

output:

2
2 4 3 
2 2 1 

result:

ok good!

Test #6:

score: 0
Wrong Answer
time: 0ms
memory: 3680kb

input:

8
1 1 1 1 1 1 1 1
3
1 4 5

output:

4
5 8 7 6 5 4 
1 3 
1 2 
1 1 

result:

wrong answer you used more buckets than jury

Subtask #2:

score: 0
Wrong Answer

Test #28:

score: 0
Wrong Answer
time: 0ms
memory: 3584kb

input:

1
15
1
1

output:

1
1 1 

result:

wrong answer there are unused item 1

Subtask #3:

score: 0
Wrong Answer

Test #45:

score: 0
Wrong Answer
time: 0ms
memory: 3640kb

input:

2
7 8
2
1 2

output:

1
2 2 1 

result:

wrong answer there are unused item 1

Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Skipped

Dependency #4:

0%

Subtask #6:

score: 0
Skipped

Dependency #1:

0%