Submission #884149

# Submission time Handle Problem Language Result Execution time Memory
884149 2023-12-06T16:12:09 Z LucaIlie Super Dango Maker (JOI22_dango3) C++17
22 / 100
679 ms 1108 KB
#include "dango3.h"
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 400;
const int MAX_M = 25;
int pos[MAX_N * MAX_M + 1];
vector<int> v;
vector<int> groups[MAX_N];

void insert( int x ) {
    pos[x] = v.size();
    v.push_back( x );
}

void erase( int x ) {
    swap( v[pos[x]], v[v.size() - 1] );
    pos[v[pos[x]]] = pos[x];
    pos[x] = 0;
    v.pop_back();
}

int query( vector<int> q ) {
    for ( int x: q )
        erase( x );

    /*printf( "q " );
    for ( int x: q )
        printf( "%d ", x );
    printf( "\n" );*/

    int ans = Query( v );

    for ( int x: q )
        insert( x );

    return ans;
}

void Solve( int n, int m ) {
    for ( int i = 1; i <= n * m; i++ ) {
        pos[i] = i - 1;
        v.push_back( i );
    }

    for ( int i = 1; i <= n * m; i++ ) {
        int l = 0, r = n;
        while ( l != r ) {
            int mid = (l + r) / 2;

            vector<int> q;
            q.push_back( i );
            for ( int j = l; j <= mid; j++ ) {
                if ( !groups[j].empty() )
                    q.push_back( groups[j].back() );
            }

            if ( query( q ) == m - 2 )
                r = mid;
            else
                l = mid + 1;
        }

        if ( r == n ) {
            for ( int j = 0; j < n; j++ ) {
                if ( groups[j].empty() ) {
                    l = j;
                    break;
                }
            }
        }

        groups[l].push_back( i );
    }

    for ( int i = 0; i < m; i++ ) {
        vector<int> ans;
        for ( int j = 0; j < n; j++ )
            ans.push_back( groups[j][i] );
        Answer( ans );
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 524 KB Output is correct
2 Correct 11 ms 344 KB Output is correct
3 Correct 12 ms 348 KB Output is correct
4 Correct 12 ms 456 KB Output is correct
5 Correct 11 ms 524 KB Output is correct
6 Correct 11 ms 524 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 257 ms 604 KB Output is correct
2 Correct 255 ms 604 KB Output is correct
3 Correct 373 ms 604 KB Output is correct
4 Correct 378 ms 604 KB Output is correct
5 Correct 264 ms 604 KB Output is correct
6 Correct 264 ms 1108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 679 ms 976 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -