Submission #824237

#TimeUsernameProblemLanguageResultExecution timeMemory
824237LucaIlieMinerals (JOI19_minerals)C++17
6 / 100
14 ms1360 KiB
#include "minerals.h" #include <bits/stdc++.h> using namespace std; const int MAX_N = 43000; const int B = 100; const int UNDEF = -1; int perm[2 * MAX_N + 1], pairr[2 * MAX_N + 1]; set<int> notPaired, s; vector<int> pairedQueue; void Solve( int n ) { for ( int i = 0; i < 2 * n; i++ ) { perm[i] = i + 1; pairr[i] = UNDEF; notPaired.insert( i ); } random_shuffle( perm, perm + 2 * n ); while ( !notPaired.empty() ) { pairedQueue.clear(); for ( int i: notPaired ) { int x = Query( perm[i] ); if ( x > B ) { Query( perm[i] ); continue; } if ( x == s.size() ) { int p = UNDEF; for ( int j: s ) { int y = Query( perm[j] ); if ( x == y ) { p = j; break; } else Query( perm[j] ); } pairr[i] = p; pairr[p] = i; pairedQueue.push_back( i ); pairedQueue.push_back( p ); s.erase( p ); Query( perm[i] ); } else s.insert( i ); } for ( int i: pairedQueue ) notPaired.erase( i ); } for ( int i = 0; i < 2 * n; i++ ) { if ( pairr[i] < i ) Answer( perm[pairr[i]], perm[i] ); } }

Compilation message (stderr)

minerals.cpp: In function 'void Solve(int)':
minerals.cpp:29:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::set<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |             if ( x == s.size() ) {
      |                  ~~^~~~~~~~~~~
#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...