# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
884155 | 2023-12-06T16:18:36 Z | LucaIlie | Super Dango Maker (JOI22_dango3) | C++17 | 957 ms | 1144 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<vector<int>> sticks; 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 = -1, r = sticks.size(); while ( r - l > 1 ) { int mid = (l + r) / 2; vector<int> q; q.push_back( i ); for ( int x: sticks[mid] ) q.push_back( x ); if ( query( q ) == m - 1 ) r = mid; else l = mid; } if ( r == sticks.size() ) { vector<int> aux; sticks.push_back( aux ); } sticks[r].push_back( i ); } for ( int i = 0; i < m; i++ ) Answer( sticks[i] ); }
Compilation message
# | 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 | 1 ms | 348 KB | Output is correct |
4 | Correct | 1 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 | 7 ms | 348 KB | Output is correct |
2 | Correct | 6 ms | 348 KB | Output is correct |
3 | Correct | 7 ms | 512 KB | Output is correct |
4 | Correct | 7 ms | 348 KB | Output is correct |
5 | Correct | 8 ms | 520 KB | Output is correct |
6 | Correct | 7 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 159 ms | 848 KB | Output is correct |
2 | Correct | 150 ms | 584 KB | Output is correct |
3 | Correct | 199 ms | 592 KB | Output is correct |
4 | Correct | 214 ms | 596 KB | Output is correct |
5 | Correct | 135 ms | 576 KB | Output is correct |
6 | Correct | 135 ms | 588 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 619 ms | 660 KB | Output is correct |
2 | Correct | 622 ms | 944 KB | Output is correct |
3 | Correct | 957 ms | 852 KB | Output is correct |
4 | Correct | 807 ms | 1144 KB | Output is correct |
5 | Correct | 536 ms | 604 KB | Output is correct |
6 | Correct | 544 ms | 600 KB | Output is correct |