Submission #128303

# Submission time Handle Problem Language Result Execution time Memory
128303 2019-07-10T16:22:31 Z OptxPrime Minerals (JOI19_minerals) C++14
Compilation error
0 ms 0 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 memo[100010];
    int nn;
    int curr,opencurr,tmp;


    void conquer( vector<int> l, vector<int> r )
    {
        int sz = l.size()/2;
        if( l.size()==1 ){
            ans( l[0], r[0] );
            return;
        }
        vector<int> l1, l2;
        l1.clear();
        l2.clear();
        int cnt=0;
        for( int i=0;i<sz;i++ ){
                l1.pb( l[i] );
            if( !inside[ l[i] ] ){ /// mora biti unutra
               cnt= query( l[i] ); ///update cnt kad ubacimo
                inside[ l[i] ]=true;
            }
    }
        for( int i=sz;i<l.size();i++ ){
                l2.pb( l[i] );
            if( inside[ l[i] ] ){       /// ne smije bit unutra
                cnt=query( l[i] );
                inside[ l[i] ]=false;
            }
        }
        vector<int> r1,r2;
        r1.clear();
        r2.clear();
        for( int i=0;i<r.size();i++ ){
            int tmp=query( r[i] );
            if( tmp  == cnt ){ /// nista se nije desilo, dakle vec je bio taj mineral
                r1.pb( r[i] );
            }
            else{ /// promjenio se broj, dakle dodali smo novi mineral, prema tome on pripada grupi koja je izgasena
                r2.pb( r[i] );
                cnt = tmp;
            }
        }
    //    cout << l.size() <<  " " << r.size() << " bruh " <<endl;
   //     for( int i=0;i<l1.size();i++ ){
    //        cout << l1[i] << " " << r1[i] <<  " bree " <<endl;
        }
        conquer( l1,r1 );
        conquer( l2,r2 );
    }
    void Solve(int n)
    {
        nn=n;///globalno n
        int curr=0;
        vector<int> left,right;
        for( int i=1;i<=2*n;i++ ){
                int tmp=query(i);
            if( tmp > curr ){  ///novi
                left.pb( i );
                inside[i] = true;
                curr=tmp;
            }
            else{
                right.pb(i);
                curr=query(i);   /// izbaci
            }
        }
       // cout << left[0] << " " <<left[1] << " " <<right[0 ] << " " << right[1 ] << " budal;e " <<endl;
        conquer( left, right );
    }

Compilation message

minerals.cpp: In function 'void conquer(std::vector<int>, std::vector<int>)':
minerals.cpp:46:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for( int i=sz;i<l.size();i++ ){
                       ~^~~~~~~~~
minerals.cpp:56:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for( int i=0;i<r.size();i++ ){
                      ~^~~~~~~~~
minerals.cpp: At global scope:
minerals.cpp:70:16: error: expected constructor, destructor, or type conversion before '(' token
         conquer( l1,r1 );
                ^
minerals.cpp:71:16: error: expected constructor, destructor, or type conversion before '(' token
         conquer( l2,r2 );
                ^
minerals.cpp:72:5: error: expected declaration before '}' token
     }
     ^