Submission #129021

# Submission time Handle Problem Language Result Execution time Memory
129021 2019-07-11T12:39:30 Z sealnot123 Minerals (JOI19_minerals) C++14
40 / 100
79 ms 20084 KB
#include "minerals.h"

#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define SZ(a) (int)(a).size()
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
typedef double D;
typedef long double LD;
const int N = 43005;
vector<int> L[4*N], R[4*N];
int mineral[2*N];

void play(int t, int now, int n, vector<int> &l, vector<int> &r){
	int last, a, i;
	/*printf("n = %d\n",n);
	for(i=0;i<n;i++) printf("%d ",l[i]);
	printf("|| ");
	for(i=0;i<n;i++) printf("%d ",r[i]);
	printf("=================\n");*/
	assert(n == SZ(l));
	if(n == 1){
		Answer(l[0], r[0]);
		l.clear(); r.clear();
		return ;
	}
	if(t == 0){
		for(i = 0; i < n/2; i++){
			last = Query(r[i]);
			R[now<<1].pb(r[i]);
		}
		for(i = n/2; i < n; i++) R[now<<1|1].pb(r[i]);
	}else{
		for(i = n/2; i < n; i++){
			last = Query(r[i]);
			R[now<<1|1].pb(r[i]);
		}
		for(i = 0; i < n/2; i++) R[now<<1].pb(r[i]);
	}
	for(i = 0; i < n; i++){
		a = Query(l[i]);
		
			if(a != last) L[now<<1|1].pb(l[i]);
			else L[now<<1].pb(l[i]); 
		
		last = a;
	}
	if(t == 2){
		play(1, now<<1, n/2, L[now<<1], R[now<<1]);
		play(0, now<<1|1, n-n/2, L[now<<1|1], R[now<<1|1]);
	}else{
		play(2, now<<1, n/2, L[now<<1], R[now<<1]);
		play(1, now<<1|1, n-n/2, R[now<<1|1], L[now<<1|1]);
	}
	l.clear(); r.clear();
}

void Solve(int n) {
  	int last = 0, now = 2*n;
  	int i,j,k,l,a,b,c,d;
  	for(i = 1; i <= 2*n; i++) mineral[i] = i;
  	for(i = 1; i <= n; i++){
  		a = Query(mineral[i]);
  		if(a == last) Query(mineral[i]),swap(mineral[i], mineral[now--]), i--;
  		last = a;
  	}
  	for(i = 1; i <= n; i++) Query(mineral[i]);
  	for(i = 1; i <= n; i++) L[1].pb(mineral[i]), R[1].pb(mineral[i+n]);
  	play(0, 1, n, L[1], R[1]);
  	return ;
}

Compilation message

minerals.cpp: In function 'void Solve(int)':
minerals.cpp:66:10: warning: unused variable 'j' [-Wunused-variable]
    int i,j,k,l,a,b,c,d;
          ^
minerals.cpp:66:12: warning: unused variable 'k' [-Wunused-variable]
    int i,j,k,l,a,b,c,d;
            ^
minerals.cpp:66:14: warning: unused variable 'l' [-Wunused-variable]
    int i,j,k,l,a,b,c,d;
              ^
minerals.cpp:66:18: warning: unused variable 'b' [-Wunused-variable]
    int i,j,k,l,a,b,c,d;
                  ^
minerals.cpp:66:20: warning: unused variable 'c' [-Wunused-variable]
    int i,j,k,l,a,b,c,d;
                    ^
minerals.cpp:66:22: warning: unused variable 'd' [-Wunused-variable]
    int i,j,k,l,a,b,c,d;
                      ^
minerals.cpp: In function 'void play(int, int, int, std::vector<int>&, std::vector<int>&)':
minerals.cpp:49:4: warning: 'last' may be used uninitialized in this function [-Wmaybe-uninitialized]
    if(a != last) L[now<<1|1].pb(l[i]);
    ^~
# Verdict Execution time Memory Grader output
1 Correct 9 ms 8312 KB Output is correct
2 Correct 9 ms 8312 KB Output is correct
3 Correct 9 ms 8440 KB Output is correct
4 Correct 9 ms 8444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 8568 KB Output is correct
2 Correct 12 ms 8824 KB Output is correct
3 Correct 14 ms 9336 KB Output is correct
4 Correct 21 ms 10236 KB Output is correct
5 Correct 32 ms 12152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 8312 KB Output is correct
2 Correct 9 ms 8312 KB Output is correct
3 Correct 9 ms 8440 KB Output is correct
4 Correct 9 ms 8444 KB Output is correct
5 Correct 10 ms 8568 KB Output is correct
6 Correct 12 ms 8824 KB Output is correct
7 Correct 14 ms 9336 KB Output is correct
8 Correct 21 ms 10236 KB Output is correct
9 Correct 32 ms 12152 KB Output is correct
10 Correct 10 ms 8696 KB Output is correct
11 Correct 26 ms 11384 KB Output is correct
12 Correct 34 ms 12248 KB Output is correct
13 Correct 29 ms 12280 KB Output is correct
14 Correct 29 ms 12152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 8312 KB Output is correct
2 Correct 9 ms 8312 KB Output is correct
3 Correct 9 ms 8440 KB Output is correct
4 Correct 9 ms 8444 KB Output is correct
5 Correct 10 ms 8568 KB Output is correct
6 Correct 12 ms 8824 KB Output is correct
7 Correct 14 ms 9336 KB Output is correct
8 Correct 21 ms 10236 KB Output is correct
9 Correct 32 ms 12152 KB Output is correct
10 Correct 10 ms 8696 KB Output is correct
11 Correct 26 ms 11384 KB Output is correct
12 Correct 34 ms 12248 KB Output is correct
13 Correct 29 ms 12280 KB Output is correct
14 Correct 29 ms 12152 KB Output is correct
15 Incorrect 79 ms 20084 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 8312 KB Output is correct
2 Correct 9 ms 8312 KB Output is correct
3 Correct 9 ms 8440 KB Output is correct
4 Correct 9 ms 8444 KB Output is correct
5 Correct 10 ms 8568 KB Output is correct
6 Correct 12 ms 8824 KB Output is correct
7 Correct 14 ms 9336 KB Output is correct
8 Correct 21 ms 10236 KB Output is correct
9 Correct 32 ms 12152 KB Output is correct
10 Correct 10 ms 8696 KB Output is correct
11 Correct 26 ms 11384 KB Output is correct
12 Correct 34 ms 12248 KB Output is correct
13 Correct 29 ms 12280 KB Output is correct
14 Correct 29 ms 12152 KB Output is correct
15 Incorrect 79 ms 20084 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 8312 KB Output is correct
2 Correct 9 ms 8312 KB Output is correct
3 Correct 9 ms 8440 KB Output is correct
4 Correct 9 ms 8444 KB Output is correct
5 Correct 10 ms 8568 KB Output is correct
6 Correct 12 ms 8824 KB Output is correct
7 Correct 14 ms 9336 KB Output is correct
8 Correct 21 ms 10236 KB Output is correct
9 Correct 32 ms 12152 KB Output is correct
10 Correct 10 ms 8696 KB Output is correct
11 Correct 26 ms 11384 KB Output is correct
12 Correct 34 ms 12248 KB Output is correct
13 Correct 29 ms 12280 KB Output is correct
14 Correct 29 ms 12152 KB Output is correct
15 Incorrect 79 ms 20084 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 8312 KB Output is correct
2 Correct 9 ms 8312 KB Output is correct
3 Correct 9 ms 8440 KB Output is correct
4 Correct 9 ms 8444 KB Output is correct
5 Correct 10 ms 8568 KB Output is correct
6 Correct 12 ms 8824 KB Output is correct
7 Correct 14 ms 9336 KB Output is correct
8 Correct 21 ms 10236 KB Output is correct
9 Correct 32 ms 12152 KB Output is correct
10 Correct 10 ms 8696 KB Output is correct
11 Correct 26 ms 11384 KB Output is correct
12 Correct 34 ms 12248 KB Output is correct
13 Correct 29 ms 12280 KB Output is correct
14 Correct 29 ms 12152 KB Output is correct
15 Incorrect 79 ms 20084 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 8312 KB Output is correct
2 Correct 9 ms 8312 KB Output is correct
3 Correct 9 ms 8440 KB Output is correct
4 Correct 9 ms 8444 KB Output is correct
5 Correct 10 ms 8568 KB Output is correct
6 Correct 12 ms 8824 KB Output is correct
7 Correct 14 ms 9336 KB Output is correct
8 Correct 21 ms 10236 KB Output is correct
9 Correct 32 ms 12152 KB Output is correct
10 Correct 10 ms 8696 KB Output is correct
11 Correct 26 ms 11384 KB Output is correct
12 Correct 34 ms 12248 KB Output is correct
13 Correct 29 ms 12280 KB Output is correct
14 Correct 29 ms 12152 KB Output is correct
15 Incorrect 79 ms 20084 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 8312 KB Output is correct
2 Correct 9 ms 8312 KB Output is correct
3 Correct 9 ms 8440 KB Output is correct
4 Correct 9 ms 8444 KB Output is correct
5 Correct 10 ms 8568 KB Output is correct
6 Correct 12 ms 8824 KB Output is correct
7 Correct 14 ms 9336 KB Output is correct
8 Correct 21 ms 10236 KB Output is correct
9 Correct 32 ms 12152 KB Output is correct
10 Correct 10 ms 8696 KB Output is correct
11 Correct 26 ms 11384 KB Output is correct
12 Correct 34 ms 12248 KB Output is correct
13 Correct 29 ms 12280 KB Output is correct
14 Correct 29 ms 12152 KB Output is correct
15 Incorrect 79 ms 20084 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -