Submission #128318

# Submission time Handle Problem Language Result Execution time Memory
128318 2019-07-10T16:44:55 Z OptxPrime Minerals (JOI19_minerals) C++14
90 / 100
74 ms 3780 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++ ){
                if( r1.size() >= l1.size() ){
                    r2.pb( r[i] );
                    continue;
                }
                if( r2.size() >= l2.size() ){
                    r1.pb( r[i] );
                    continue;
                }
            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;
            }
        }
        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++ ){
                if( left.size() >=n ){
                    right.pb(i);
                    continue;
                }
                if( right.size()>=n ){
                    left.pb(i);
                    continue;
                }
                int tmp=query(i);
            if( tmp > curr ){  ///novi
                left.pb( i );
                inside[i] = true;
                curr=tmp;
            }
            else{
                right.pb(i);
               /// ne moramo cak ni izbacivati jer je bitno samo mjenjanje, tj flip
            }
        }
        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: In function 'void Solve(int)':
minerals.cpp:83:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 if( left.size() >=n ){
                     ~~~~~~~~~~~~^~~
minerals.cpp:87:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 if( right.size()>=n ){
                     ~~~~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 7 ms 548 KB Output is correct
4 Correct 12 ms 888 KB Output is correct
5 Correct 23 ms 1396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 248 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 4 ms 376 KB Output is correct
7 Correct 7 ms 548 KB Output is correct
8 Correct 12 ms 888 KB Output is correct
9 Correct 23 ms 1396 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 17 ms 1144 KB Output is correct
12 Correct 23 ms 1528 KB Output is correct
13 Correct 20 ms 1452 KB Output is correct
14 Correct 19 ms 1316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 248 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 4 ms 376 KB Output is correct
7 Correct 7 ms 548 KB Output is correct
8 Correct 12 ms 888 KB Output is correct
9 Correct 23 ms 1396 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 17 ms 1144 KB Output is correct
12 Correct 23 ms 1528 KB Output is correct
13 Correct 20 ms 1452 KB Output is correct
14 Correct 19 ms 1316 KB Output is correct
15 Correct 65 ms 3364 KB Output is correct
16 Correct 66 ms 3384 KB Output is correct
17 Correct 50 ms 3192 KB Output is correct
18 Correct 50 ms 2980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 248 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 4 ms 376 KB Output is correct
7 Correct 7 ms 548 KB Output is correct
8 Correct 12 ms 888 KB Output is correct
9 Correct 23 ms 1396 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 17 ms 1144 KB Output is correct
12 Correct 23 ms 1528 KB Output is correct
13 Correct 20 ms 1452 KB Output is correct
14 Correct 19 ms 1316 KB Output is correct
15 Correct 65 ms 3364 KB Output is correct
16 Correct 66 ms 3384 KB Output is correct
17 Correct 50 ms 3192 KB Output is correct
18 Correct 50 ms 2980 KB Output is correct
19 Correct 67 ms 3400 KB Output is correct
20 Correct 68 ms 3364 KB Output is correct
21 Correct 55 ms 3260 KB Output is correct
22 Correct 48 ms 3064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 248 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 4 ms 376 KB Output is correct
7 Correct 7 ms 548 KB Output is correct
8 Correct 12 ms 888 KB Output is correct
9 Correct 23 ms 1396 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 17 ms 1144 KB Output is correct
12 Correct 23 ms 1528 KB Output is correct
13 Correct 20 ms 1452 KB Output is correct
14 Correct 19 ms 1316 KB Output is correct
15 Correct 65 ms 3364 KB Output is correct
16 Correct 66 ms 3384 KB Output is correct
17 Correct 50 ms 3192 KB Output is correct
18 Correct 50 ms 2980 KB Output is correct
19 Correct 67 ms 3400 KB Output is correct
20 Correct 68 ms 3364 KB Output is correct
21 Correct 55 ms 3260 KB Output is correct
22 Correct 48 ms 3064 KB Output is correct
23 Correct 69 ms 3468 KB Output is correct
24 Correct 68 ms 3600 KB Output is correct
25 Correct 52 ms 3344 KB Output is correct
26 Correct 52 ms 3124 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 248 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 4 ms 376 KB Output is correct
7 Correct 7 ms 548 KB Output is correct
8 Correct 12 ms 888 KB Output is correct
9 Correct 23 ms 1396 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 17 ms 1144 KB Output is correct
12 Correct 23 ms 1528 KB Output is correct
13 Correct 20 ms 1452 KB Output is correct
14 Correct 19 ms 1316 KB Output is correct
15 Correct 65 ms 3364 KB Output is correct
16 Correct 66 ms 3384 KB Output is correct
17 Correct 50 ms 3192 KB Output is correct
18 Correct 50 ms 2980 KB Output is correct
19 Correct 67 ms 3400 KB Output is correct
20 Correct 68 ms 3364 KB Output is correct
21 Correct 55 ms 3260 KB Output is correct
22 Correct 48 ms 3064 KB Output is correct
23 Correct 69 ms 3468 KB Output is correct
24 Correct 68 ms 3600 KB Output is correct
25 Correct 52 ms 3344 KB Output is correct
26 Correct 52 ms 3124 KB Output is correct
27 Correct 66 ms 3568 KB Output is correct
28 Correct 68 ms 3496 KB Output is correct
29 Correct 54 ms 3424 KB Output is correct
30 Correct 56 ms 3236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 248 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 4 ms 376 KB Output is correct
7 Correct 7 ms 548 KB Output is correct
8 Correct 12 ms 888 KB Output is correct
9 Correct 23 ms 1396 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 17 ms 1144 KB Output is correct
12 Correct 23 ms 1528 KB Output is correct
13 Correct 20 ms 1452 KB Output is correct
14 Correct 19 ms 1316 KB Output is correct
15 Correct 65 ms 3364 KB Output is correct
16 Correct 66 ms 3384 KB Output is correct
17 Correct 50 ms 3192 KB Output is correct
18 Correct 50 ms 2980 KB Output is correct
19 Correct 67 ms 3400 KB Output is correct
20 Correct 68 ms 3364 KB Output is correct
21 Correct 55 ms 3260 KB Output is correct
22 Correct 48 ms 3064 KB Output is correct
23 Correct 69 ms 3468 KB Output is correct
24 Correct 68 ms 3600 KB Output is correct
25 Correct 52 ms 3344 KB Output is correct
26 Correct 52 ms 3124 KB Output is correct
27 Correct 66 ms 3568 KB Output is correct
28 Correct 68 ms 3496 KB Output is correct
29 Correct 54 ms 3424 KB Output is correct
30 Correct 56 ms 3236 KB Output is correct
31 Correct 72 ms 3580 KB Output is correct
32 Correct 74 ms 3780 KB Output is correct
33 Correct 56 ms 3396 KB Output is correct
34 Correct 55 ms 3188 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 248 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 4 ms 376 KB Output is correct
7 Correct 7 ms 548 KB Output is correct
8 Correct 12 ms 888 KB Output is correct
9 Correct 23 ms 1396 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 17 ms 1144 KB Output is correct
12 Correct 23 ms 1528 KB Output is correct
13 Correct 20 ms 1452 KB Output is correct
14 Correct 19 ms 1316 KB Output is correct
15 Correct 65 ms 3364 KB Output is correct
16 Correct 66 ms 3384 KB Output is correct
17 Correct 50 ms 3192 KB Output is correct
18 Correct 50 ms 2980 KB Output is correct
19 Correct 67 ms 3400 KB Output is correct
20 Correct 68 ms 3364 KB Output is correct
21 Correct 55 ms 3260 KB Output is correct
22 Correct 48 ms 3064 KB Output is correct
23 Correct 69 ms 3468 KB Output is correct
24 Correct 68 ms 3600 KB Output is correct
25 Correct 52 ms 3344 KB Output is correct
26 Correct 52 ms 3124 KB Output is correct
27 Correct 66 ms 3568 KB Output is correct
28 Correct 68 ms 3496 KB Output is correct
29 Correct 54 ms 3424 KB Output is correct
30 Correct 56 ms 3236 KB Output is correct
31 Correct 72 ms 3580 KB Output is correct
32 Correct 74 ms 3780 KB Output is correct
33 Correct 56 ms 3396 KB Output is correct
34 Correct 55 ms 3188 KB Output is correct
35 Incorrect 70 ms 3604 KB Wrong Answer [2]
36 Halted 0 ms 0 KB -