Submission #706575

# Submission time Handle Problem Language Result Execution time Memory
706575 2023-03-07T05:17:14 Z asdfasdfasdfasdf Minerals (JOI19_minerals) C++14
90 / 100
76 ms 3580 KB
#include "minerals.h"
#include <bits/stdc++.h>

using namespace std;

int match[111111];

vector<int> group[2];

void Divide(vector<int> A, vector<int> B, int c)
{
    random_shuffle(A.begin(),A.end());
	random_shuffle(B.begin(),B.end());

	if(A.size()==0)
        return;

	if(A.size()==1)
	{
		match[A[0]]=B[0];
		match[B[0]]=A[0];

		return;
	}

	int pre=0;

	int sz=A.size()/2;

	if(sz==0)
        sz++;

	if(sz==A.size())
        sz--;

	vector<int> A1;
	vector<int> A2;

	vector<int> B1;
	vector<int> B2;

    if(c==1)
    {
        for(int i=0;i<sz;i++)
            pre=Query(A[i]+1);

        for(int i=0;i<A.size();i++)
        {
            if(i<sz)
                A1.push_back(A[i]);
            else
                A2.push_back(A[i]);
        }

        for(int i=0;i<B.size();i++)
        {
            if(A1.size()==B1.size())
                B2.push_back(B[i]);
            else if(A2.size()==B2.size())
                B1.push_back(B[i]);
            else
            {
                int tmp=Query(B[i]+1);

                if(pre!=tmp)
                    B1.push_back(B[i]);
                else
                    B2.push_back(B[i]);

                pre=tmp;
            }
        }
    }
    else
    {
        for(int i=sz;i<A.size();i++)
            pre=Query(A[i]+1);

        for(int i=0;i<A.size();i++)
        {
            if(i<sz)
                A1.push_back(A[i]);
            else
                A2.push_back(A[i]);
        }

        for(int i=0;i<B.size();i++)
        {
            if(A1.size()==B1.size())
                B2.push_back(B[i]);
            else if(A2.size()==B2.size())
                B1.push_back(B[i]);
            else
            {
                int tmp=Query(B[i]+1);

                if(pre!=tmp)
                    B1.push_back(B[i]);
                else
                    B2.push_back(B[i]);

                pre=tmp;
            }
        }
    }

	Divide(A1,B1,0);
	Divide(A2,B2,1);

    return;
}

void Solve(int n)
{
	int pre=0;

	for(int i=0;i<n*2;i++)
    {
		int tmp=Query(i+1);
		if(pre<tmp)
			group[0].push_back(i);
        else
            group[1].push_back(i);

        pre=tmp;
	}

	Divide(group[0],group[1],1);

	for(int i=0;i<n;i++)
		Answer(group[0][i]+1,match[group[0][i]]+1);

	return;
}

Compilation message

minerals.cpp: In function 'void Divide(std::vector<int>, std::vector<int>, int)':
minerals.cpp:33:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |  if(sz==A.size())
      |     ~~^~~~~~~~~~
minerals.cpp:47:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |         for(int i=0;i<A.size();i++)
      |                     ~^~~~~~~~~
minerals.cpp:55:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |         for(int i=0;i<B.size();i++)
      |                     ~^~~~~~~~~
minerals.cpp:76:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   76 |         for(int i=sz;i<A.size();i++)
      |                      ~^~~~~~~~~
minerals.cpp:79:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |         for(int i=0;i<A.size();i++)
      |                     ~^~~~~~~~~
minerals.cpp:87:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   87 |         for(int i=0;i<B.size();i++)
      |                     ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 3 ms 464 KB Output is correct
3 Correct 5 ms 592 KB Output is correct
4 Correct 11 ms 856 KB Output is correct
5 Correct 22 ms 1348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 3 ms 464 KB Output is correct
7 Correct 5 ms 592 KB Output is correct
8 Correct 11 ms 856 KB Output is correct
9 Correct 22 ms 1348 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 15 ms 1156 KB Output is correct
12 Correct 23 ms 1420 KB Output is correct
13 Correct 22 ms 1416 KB Output is correct
14 Correct 22 ms 1356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 3 ms 464 KB Output is correct
7 Correct 5 ms 592 KB Output is correct
8 Correct 11 ms 856 KB Output is correct
9 Correct 22 ms 1348 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 15 ms 1156 KB Output is correct
12 Correct 23 ms 1420 KB Output is correct
13 Correct 22 ms 1416 KB Output is correct
14 Correct 22 ms 1356 KB Output is correct
15 Correct 62 ms 3208 KB Output is correct
16 Correct 63 ms 3160 KB Output is correct
17 Correct 62 ms 3368 KB Output is correct
18 Correct 62 ms 3000 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 3 ms 464 KB Output is correct
7 Correct 5 ms 592 KB Output is correct
8 Correct 11 ms 856 KB Output is correct
9 Correct 22 ms 1348 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 15 ms 1156 KB Output is correct
12 Correct 23 ms 1420 KB Output is correct
13 Correct 22 ms 1416 KB Output is correct
14 Correct 22 ms 1356 KB Output is correct
15 Correct 62 ms 3208 KB Output is correct
16 Correct 63 ms 3160 KB Output is correct
17 Correct 62 ms 3368 KB Output is correct
18 Correct 62 ms 3000 KB Output is correct
19 Correct 64 ms 3264 KB Output is correct
20 Correct 72 ms 3400 KB Output is correct
21 Correct 65 ms 3436 KB Output is correct
22 Correct 63 ms 3044 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 3 ms 464 KB Output is correct
7 Correct 5 ms 592 KB Output is correct
8 Correct 11 ms 856 KB Output is correct
9 Correct 22 ms 1348 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 15 ms 1156 KB Output is correct
12 Correct 23 ms 1420 KB Output is correct
13 Correct 22 ms 1416 KB Output is correct
14 Correct 22 ms 1356 KB Output is correct
15 Correct 62 ms 3208 KB Output is correct
16 Correct 63 ms 3160 KB Output is correct
17 Correct 62 ms 3368 KB Output is correct
18 Correct 62 ms 3000 KB Output is correct
19 Correct 64 ms 3264 KB Output is correct
20 Correct 72 ms 3400 KB Output is correct
21 Correct 65 ms 3436 KB Output is correct
22 Correct 63 ms 3044 KB Output is correct
23 Correct 67 ms 3332 KB Output is correct
24 Correct 68 ms 3352 KB Output is correct
25 Correct 64 ms 3344 KB Output is correct
26 Correct 64 ms 3204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 3 ms 464 KB Output is correct
7 Correct 5 ms 592 KB Output is correct
8 Correct 11 ms 856 KB Output is correct
9 Correct 22 ms 1348 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 15 ms 1156 KB Output is correct
12 Correct 23 ms 1420 KB Output is correct
13 Correct 22 ms 1416 KB Output is correct
14 Correct 22 ms 1356 KB Output is correct
15 Correct 62 ms 3208 KB Output is correct
16 Correct 63 ms 3160 KB Output is correct
17 Correct 62 ms 3368 KB Output is correct
18 Correct 62 ms 3000 KB Output is correct
19 Correct 64 ms 3264 KB Output is correct
20 Correct 72 ms 3400 KB Output is correct
21 Correct 65 ms 3436 KB Output is correct
22 Correct 63 ms 3044 KB Output is correct
23 Correct 67 ms 3332 KB Output is correct
24 Correct 68 ms 3352 KB Output is correct
25 Correct 64 ms 3344 KB Output is correct
26 Correct 64 ms 3204 KB Output is correct
27 Correct 76 ms 3396 KB Output is correct
28 Correct 67 ms 3328 KB Output is correct
29 Correct 72 ms 3484 KB Output is correct
30 Correct 67 ms 3200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 3 ms 464 KB Output is correct
7 Correct 5 ms 592 KB Output is correct
8 Correct 11 ms 856 KB Output is correct
9 Correct 22 ms 1348 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 15 ms 1156 KB Output is correct
12 Correct 23 ms 1420 KB Output is correct
13 Correct 22 ms 1416 KB Output is correct
14 Correct 22 ms 1356 KB Output is correct
15 Correct 62 ms 3208 KB Output is correct
16 Correct 63 ms 3160 KB Output is correct
17 Correct 62 ms 3368 KB Output is correct
18 Correct 62 ms 3000 KB Output is correct
19 Correct 64 ms 3264 KB Output is correct
20 Correct 72 ms 3400 KB Output is correct
21 Correct 65 ms 3436 KB Output is correct
22 Correct 63 ms 3044 KB Output is correct
23 Correct 67 ms 3332 KB Output is correct
24 Correct 68 ms 3352 KB Output is correct
25 Correct 64 ms 3344 KB Output is correct
26 Correct 64 ms 3204 KB Output is correct
27 Correct 76 ms 3396 KB Output is correct
28 Correct 67 ms 3328 KB Output is correct
29 Correct 72 ms 3484 KB Output is correct
30 Correct 67 ms 3200 KB Output is correct
31 Correct 73 ms 3496 KB Output is correct
32 Correct 71 ms 3448 KB Output is correct
33 Correct 74 ms 3580 KB Output is correct
34 Correct 67 ms 3236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 3 ms 464 KB Output is correct
7 Correct 5 ms 592 KB Output is correct
8 Correct 11 ms 856 KB Output is correct
9 Correct 22 ms 1348 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 15 ms 1156 KB Output is correct
12 Correct 23 ms 1420 KB Output is correct
13 Correct 22 ms 1416 KB Output is correct
14 Correct 22 ms 1356 KB Output is correct
15 Correct 62 ms 3208 KB Output is correct
16 Correct 63 ms 3160 KB Output is correct
17 Correct 62 ms 3368 KB Output is correct
18 Correct 62 ms 3000 KB Output is correct
19 Correct 64 ms 3264 KB Output is correct
20 Correct 72 ms 3400 KB Output is correct
21 Correct 65 ms 3436 KB Output is correct
22 Correct 63 ms 3044 KB Output is correct
23 Correct 67 ms 3332 KB Output is correct
24 Correct 68 ms 3352 KB Output is correct
25 Correct 64 ms 3344 KB Output is correct
26 Correct 64 ms 3204 KB Output is correct
27 Correct 76 ms 3396 KB Output is correct
28 Correct 67 ms 3328 KB Output is correct
29 Correct 72 ms 3484 KB Output is correct
30 Correct 67 ms 3200 KB Output is correct
31 Correct 73 ms 3496 KB Output is correct
32 Correct 71 ms 3448 KB Output is correct
33 Correct 74 ms 3580 KB Output is correct
34 Correct 67 ms 3236 KB Output is correct
35 Incorrect 69 ms 3464 KB Wrong Answer [2]
36 Halted 0 ms 0 KB -