Submission #824686

#TimeUsernameProblemLanguageResultExecution timeMemory
824686LucaIlieMinerals (JOI19_minerals)C++17
40 / 100
19 ms2888 KiB
#include "minerals.h" #include <bits/stdc++.h> using namespace std; const int MAX_N = 43000; const int UNDEF = -1; int pairr[2 * MAX_N + 1], perm[2 * MAX_N + 1]; int ans = 0; void solve( vector <int> &v, bool active ) { int n = v.size() / 2, ln = n / 2; vector<int> left, right; /*printf( "%d: ", n ); for ( int i: v ) printf( "%d ", perm[i] ); printf( "\n" );*/ if ( n == 1 ) { pairr[v[0]] = v[1]; pairr[v[1]] = v[0]; return; } int prevAns = ans, pairs = 0; for ( int i: v ) { if ( left.size() == ln * 2 ) { right.push_back( i ); continue; } ans = Query( perm[i] ); if ( active ) { if ( ans == prevAns ) pairs++; } else { if ( ans > prevAns ) pairs++; } if ( pairs > ln ) { right.push_back( i ); ans = Query( perm[i] ); pairs--; } else left.push_back( i ); prevAns = ans; } solve( left, !active ); solve( right, active ); } void Solve( int n ) { vector<int> v; for ( int i = 1; i <= 2 * n; i++ ) { pairr[i] = UNDEF; v.push_back( i ); perm[i] = i; } solve( v, false ); for ( int i = 1; i <= 2 * n; i++ ) { if ( pairr[i] < i ) Answer( perm[i], perm[pairr[i]] ); } }

Compilation message (stderr)

minerals.cpp: In function 'void solve(std::vector<int>&, bool)':
minerals.cpp:28:26: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   28 |         if ( left.size() == ln * 2 ) {
      |              ~~~~~~~~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...