제출 #1031357

#제출 시각아이디문제언어결과실행 시간메모리
1031357Dan4LifeScales (IOI15_scales)C++17
47.50 / 100
1 ms488 KiB
#include "scales.h"
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define sz(a) (int)a.size()
#define all(a) begin(a),end(a)

using ll = long long;
using vi = vector<int>;
using ar2 = array<int,2>;
int W[] = {0, 1, 2, 3, 4, 5, 6};

int getInd(int x){
	for(int i = 1; i <= 6; i++) 
		if(W[i]==x) return i;
	return 0;
}

int getMx[10][10][10];
int getMax(int _a, int _b, int _c){
	int a=_a, b=_b, c=_c;
	if(a>b)swap(a,b);
	if(b>c)swap(b,c);
	if(a>b)swap(a,b);
	if(getMx[a][b][c]) return getMx[a][b][c];
	return getMx[a][b][c]=getHeaviest(a,b,c);
}

int getMn[10][10][10];
int getMin(int _a, int _b, int _c){
	int a=_a, b=_b, c=_c;
	if(a>b)swap(a,b);
	if(b>c)swap(b,c);
	if(a>b)swap(a,b);
	if(getMn[a][b][c]) return getMn[a][b][c];
	return getMn[a][b][c]=getLightest(a,b,c);
}

int getMed[10][10][10];
int getMiddle(int _a, int _b, int _c){
	int a=_a, b=_b, c=_c;
	if(a>b)swap(a,b);
	if(b>c)swap(b,c);
	if(a>b)swap(a,b);
	if(getMed[a][b][c]) return getMed[a][b][c];
	return getMed[a][b][c]=getMedian(a,b,c);
}

int getNxt[10][10][10][10];
int getNext(int _a, int _b, int _c, int _d){
	int a=_a, b=_b, c=_c, d=d;
	if(a>b)swap(a,b);
	if(b>c)swap(b,c);
	if(a>b)swap(a,b);
	if(getNxt[a][b][c][d]) return getNxt[a][b][c][d];
	return getNxt[a][b][c][d]=getNextLightest(a,b,c,d);
}

void init(int T) {}

bool vis[10];

void orderCoins() {
    memset(getMx,0,sizeof(getMx));
    memset(getMn,0,sizeof(getMn));
    memset(getMed,0,sizeof(getMed));
    memset(getNxt,0,sizeof(getNxt));
    memset(vis,0,sizeof(vis));
	for(int i = 1; i <= 6; i++) W[i]=i;
	
	int cur, cur2, cur3;
	
    cur = getMax(W[1],W[2],W[3]);
    cur2 = getMax(W[4],W[5],W[6]), cur3=1;
    while(cur3==cur or cur3==cur2) cur3++;
    cur3 = getMax(cur,cur2,cur3);
    swap(W[6],W[getInd(cur3)]); vis[W[6]]=1;
    
    cur = getMax(W[1],W[2],W[3]);
    cur3 = getMax(cur,W[4],W[5]);
    swap(W[5],W[getInd(cur3)]); vis[W[5]]=1;
    
    cur = getMax(W[1],W[2],W[3]);
    if(cur==W[1]) cur2=W[2];
    else cur2=W[1];
    cur3 = getMax(cur,cur2,W[4]);
    swap(W[4],W[getInd(cur3)]); vis[W[4]]=1;
    
    cur = getMax(W[1],W[2],W[3]);
    swap(W[3],W[getInd(cur)]); vis[W[3]]=1;
    
    cur = getMin(W[1],W[2],W[3]);
    if(cur==W[2]) swap(W[1],W[2]); vis[W[2]]=1;
    
    int ans[] = {W[1],W[2],W[3],W[4],W[5],W[6]}; answer(ans);
}

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

scales.cpp: In function 'int getNext(int, int, int, int)':
scales.cpp:51:41: warning: unused parameter '_d' [-Wunused-parameter]
   51 | int getNext(int _a, int _b, int _c, int _d){
      |                                     ~~~~^~
scales.cpp: In function 'void init(int)':
scales.cpp:60:15: warning: unused parameter 'T' [-Wunused-parameter]
   60 | void init(int T) {}
      |           ~~~~^
scales.cpp: In function 'void orderCoins()':
scales.cpp:94:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   94 |     if(cur==W[2]) swap(W[1],W[2]); vis[W[2]]=1;
      |     ^~
scales.cpp:94:36: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   94 |     if(cur==W[2]) swap(W[1],W[2]); vis[W[2]]=1;
      |                                    ^~~
scales.cpp: In function 'int getNext(int, int, int, int)':
scales.cpp:52:24: warning: 'd' is used uninitialized in this function [-Wuninitialized]
   52 |  int a=_a, b=_b, c=_c, d=d;
      |                        ^
#Verdict Execution timeMemoryGrader output
Fetching results...