QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#114432#1428. GrpAsif17rWA 1ms3544kbC++204.2kb2023-06-22 02:11:572023-06-22 02:11:59

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-22 02:11:59]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3544kb
  • [2023-06-22 02:11:57]
  • Submitted

answer

// #pragma GCC target("fpmath=sse,sse2") // off
// #pragma GCC target("fpmath=387") // on
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma,tune=native")
//#pragma GCC optimize("O2, Ofast,unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
#include <ext/random>
#ifdef DEBUG
#include <sys/resource.h>
#endif
#define int long long
using namespace __gnu_pbds;
const int mod = 1e9 + 7;
#define FOR(i,a,b) for(int i=a;i<(int)b;i++)
#define FORr(i,a,b) for(int i =a;i>=(int)b;i--)
#define rep(i,n) FOR(i,0,n)
#define rep1(i,n) FOR(i,1,n)
#define print(arr)  for(auto a: arr) cout << a<< " "; cout << endl;
#define in(a) int a; cin >> a;
#define inp(arr,n) vector<int>arr(n); for(auto &a: arr) cin >> a;
#define pb emplace_back
#define all(a) a.begin(), a.end()
#define mp make_pair
#define f first
#define vi vector<int>
#define s second
#define mxheap priority_queue<int>
#define mnheap priority_queue<int, vector<int>, greater<int>>
#define mxheap2 priority_queue<pair<int,int>>
#define mnheap2 priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>>
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define case cout << "Case "<< tt << ": ";
inline int uceil(int a,int b) {int res = a/b; if(a%b and res >= 0) res++; return res;}
#define pll pair<int, int>
#define set_bit(x, idx) x = x|(1LL<<idx)
int dx[8] = {0,1,0,-1,1,-1,1,-1};
int dy[8] = {-1,0,1,0,1,1,-1,-1};
#define toggle_bit(x, idx) x = x^(1LL<<idx)
#define check_bit(x, idx) min(x&(1LL<<idx),1LL)
#define endl "\n"
#define yes cout << "Yes\n";
#define no cout << "No\n";
#define db long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rng(x,y) uniform_int_distribution<int>(x,y)(rng)
#define CAST(X) std::bitset<sizeof(X)*8>
#define ACCESS(X) *((std::bitset<sizeof(X)*8>*)&X)


#ifdef DEBUG
#include "tpc.hpp"
#define pause(x) thamm(x)
#define FAST_IO
#define dbg(...) {cerr << __LINE__ << " : " ;cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__);}
#define ok tikkk
#elif ASHIQ
#define pause(x) 
#define FAST_IO
#define dbg(...) 
#define ok
#else
#define pause(x) 
#define FAST_IO {ios_base::sync_with_stdio(false); cin.tie(0);}
#define dbg(...) 
#define ok
#endif

void printAns(vector<pll>&bags){
    cout << bags.size() << endl;
    int n = bags.size();
    int cnt = 0;
    for(auto a: bags){
        cnt++;
        if(a.s == 0) cout << 1 << " ";
        else cout << 2 << " ";
        for(int i = 0; i <= 17; i++){
            if(check_bit(a.f,i) == 1) cout << char('a'+i);
        }
        if(a.s != 0){
            cout <<" ";
            for(int i = 0; i <= 17; i++){
                if(check_bit(a.s,i) == 1) cout << char('a'+i);
            }
        }
        if(cnt != n) cout << endl;
    }
}

vector<int>mc[19];


//aboid function
void solvetc(int tt){
    in(n) in(k)
    int lim = 1<<n;
    for(int i = 0; i < lim; i++){
        int cnt = __builtin_popcount(i);
        mc[cnt].pb(i);
    }
    int hi = k, lo = 0;
    vector<pll>bags;
    while(lo < hi){
        // assert(mc[hi].size() >= mc[lo].size());
        while(mc[lo].size() != mc[hi].size()) mc[lo].pb(0);
        sort(all(mc[hi]));
        sort(all(mc[lo]), greater<int>());
        for(int i = 0; i < mc[lo].size(); i++){
            bags.pb(mp(mc[hi][i], mc[lo][i]));
        }
        lo++, hi--;
    }   
    if(lo == hi){
        int rlo = 0, rhi = mc[lo].size()-1;
        while(rlo < rhi){
            bags.pb(mp(mc[lo][rlo], mc[lo][rhi]));
            rlo++, rhi--;
        }
        if(rlo == rhi) bags.pb(mp(mc[lo][rlo], 0));
    }
    // cout << bags.size() << endl;
    // for(auto a: bags){
    //     cout << a.f << " " << a.s << endl;
    // }

    printAns(bags);
}

int32_t main()
{
    FAST_IO ;
    #ifdef DEBUG
    init_mem;
    //freopen("in", "r", stdin);
    #endif
    int nn = 1;
    // cin >> nn;
    rep(i, nn) solvetc(i+1);
    #ifdef DEBUG
    show_mem;
    #endif
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3516kb

input:

3 2

output:

5
1 ab
1 ac
1 bc
2 a c
1 b

result:

ok ok, n = 3, k = 2, groups = 5

Test #2:

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

input:

3 3

output:

4
1 abc
2 ab c
2 ac b
2 bc a

result:

ok ok, n = 3, k = 3, groups = 4

Test #3:

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

input:

1 1

output:

1
1 a

result:

ok ok, n = 1, k = 1, groups = 1

Test #4:

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

input:

2 1

output:

2
1 a
1 b

result:

ok ok, n = 2, k = 1, groups = 2

Test #5:

score: 0
Accepted
time: 0ms
memory: 3516kb

input:

2 2

output:

2
1 ab
2 a b

result:

ok ok, n = 2, k = 2, groups = 2

Test #6:

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

input:

3 1

output:

3
1 a
1 b
1 c

result:

ok ok, n = 3, k = 1, groups = 3

Test #7:

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

input:

4 3

output:

10
1 abc
1 abd
1 acd
1 bcd
2 ab d
2 ac c
2 bc b
2 ad a
1 bd
1 cd

result:

wrong answer group 6: element 'c' repeated more than once