#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 );
}
int g = 0;
for ( int i = 1; i <= n * m; i++ ) {
int l = 0, r = g;
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 ( l == g )
g++;
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 |
1 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 |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
524 KB |
Output is correct |
2 |
Correct |
11 ms |
348 KB |
Output is correct |
3 |
Correct |
11 ms |
528 KB |
Output is correct |
4 |
Correct |
13 ms |
348 KB |
Output is correct |
5 |
Correct |
12 ms |
520 KB |
Output is correct |
6 |
Correct |
11 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
267 ms |
592 KB |
Output is correct |
2 |
Correct |
257 ms |
832 KB |
Output is correct |
3 |
Correct |
295 ms |
580 KB |
Output is correct |
4 |
Correct |
301 ms |
604 KB |
Output is correct |
5 |
Correct |
269 ms |
592 KB |
Output is correct |
6 |
Correct |
258 ms |
596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
672 ms |
600 KB |
Wrong Answer [3] |
2 |
Halted |
0 ms |
0 KB |
- |