제출 #129021

#제출 시각아이디문제언어결과실행 시간메모리
129021sealnot123Minerals (JOI19_minerals)C++14
40 / 100
79 ms20084 KiB
#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 ;
}

컴파일 시 표준 에러 (stderr) 메시지

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...