Submission #128177

# Submission time Handle Problem Language Result Execution time Memory
128177 2019-07-10T13:37:34 Z OptxPrime Minerals (JOI19_minerals) C++14
0 / 100
2 ms 376 KB
#include <iostream>
#include <cmath>
#include<vector>
#include <algorithm>
#include <utility>
#include<stack>
#include<queue>
#include<map>
#include <fstream>
#include <minerals.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long

#define ans Answer
#define query Query


    bool inside[100010];
    int nn;
    int curr,opencurr,tmp;

 /*   void Answer( int a, int b )
    {
        cout <<a << " " << b<< " par " <<endl;
    }
    int Query( int x )
    {
        cout<<x << " kveri "  << tmp <<endl;
        int t;
        cin>>t;
        return t;
    }*/

    void conquer( vector<int> vec )
    {
  //      cout << " ponovo " <<endl;
        int sz = vec.size();
        if( sz==2 ){
            ans( vec[0], vec[1] );
            return;
        }
     //   cout << " ciscenje " <<endl;
        for( int i=1;i<=2*nn;i++ ){
            if( inside[i] ) {
                    query( i ); /// ocistimo prethodno, sporo ciscenje samo za probu
                inside[i]=false;
            }
        }
  //      cout << " gotovo ciscenje " <<endl;
        int gsz=sz/2;
        if( gsz%2==1 ) gsz++;
        int opensz = gsz/2;
        vector<int>vec1,vec2;
        vec1.clear();
        vec2.clear();
         curr=0,opencurr=0;
        for( int i=0;i<sz;i++ ){

        if( vec1.size() >=gsz ){
            vec.pb( vec[i] ); /// ako si popunio prvu grupu samo dodaj na drugu
        }
        else{
            tmp = query( vec[i] );
            inside[ vec[i] ] = true;
            if( tmp > curr  ){  /// zatvorila se neka iz prve grupe
                vec1.pb( vec[i] );
                curr=tmp;
            }
            else{
                if( opencurr < opensz ){    /// otvorila se neka iz prve grupe
                    vec1.pb( vec[i] );
                    opencurr++;
                }
                else{   ///otvorila se neka iz druge grupe
                    vec2.pb( vec[i] );
                  curr=  query( vec[i] );
                    inside[ vec[i] ]=false;
                }
            }
        }
    }
        /// zaboravio sam ocistit kveri
    //    for( int i=0;i<vec1.size();i++ ) query[ vec[i] ]; /// ovo valjda ocisti kveri ? skontat fino kako se cisti
        conquer( vec1 );
        conquer( vec2 );
    }


    void Solve(int n)
    {
        nn=n;///globalno n
        vector<int>vec;
        vec.clear();
        for ( int i=1;i<=2*n;i++){
            vec.pb(i);
            inside[i]=false;
        }
        conquer( vec );
    }

Compilation message

minerals.cpp: In function 'void conquer(std::vector<int>)':
minerals.cpp:63:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if( vec1.size() >=gsz ){
             ~~~~~~~~~~~~^~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 252 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 252 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 252 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 252 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 252 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 252 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 252 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 252 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -