제출 #237993

#제출 시각아이디문제언어결과실행 시간메모리
237993crossing0ver저울 (IOI15_scales)C++17
컴파일 에러
0 ms0 KiB
#define ll long long 
#include "scales.h"
using namespace std;
vector<vector<int> > all,sall;
vector<vector<int> > Left1,Left;
vector<int> g,to_ask;
bool vis[7];
int oper,X[7];
 
void G(int c) {
	if (c == 6) {
		Left1.push_back(g);
		return;	
	}
	for (int i = 1; i <= 6; i++) {
		if (!vis[i]) {
			g.push_back(i);
			vis[i] = 1;
			G(c+1);
			vis[i] = 0;
			g.pop_back();
		}
	}
}
void init(int T) {
	for (int i = 1; i<=6;i++) 
	for (int j = i + 1; j <= 6; j++)
	for (int k = j+1;k <=6;k++)  {
		all.push_back({i,j,k});
		for (int f = 1; f <= 6; f++) {
			if (f != j && f != i && f != k)
			sall.push_back({i,j,k,f});
		}
	}
	G(0);
	Left = Left1;
}
void minimize(int &total_ans,int &c,int type,vector<int> v) {
	 if (total_ans > c) {
		total_ans = c;
		to_ask = v;
		oper = type;
	}
}
vector<vector<int> > F;
bool flag;
int calc(vector<int> v,int p = 0,int type = 0 ,int d = 0) {
	F.clear();
	int a[7] = {0},cnt = 0;
	vector<int> h;
	
	for (int i : v) if (i != v[p]) h.push_back(i); 
	
	for (auto g : Left) {
		for (int i = 0; i < 6; i++) a[ g[i] ] = i;		
	if (type == 0 && a[ v[p] ] < min( a[ h[0] ], a[ h[1] ]) ) {cnt++; if (flag) F.push_back(g);}
	if (type == 1 && a[ v[p] ] > max( a[ h[0] ], a[ h[1] ])) {cnt++; if (flag) F.push_back(g);}
	if (type == 2 && a[ v[p] ] < max( a[ h[0] ], a[ h[1] ]) && a[ v[p] ] > min( a[ h[0] ], a[ h[1] ]) ) {cnt++; if (flag) F.push_back(g);} 
	if (type == 3) {
		vector<pair<int,int> > c;
		c.emplace_back ( a[ v[p] ],v[p]); 
		c.emplace_back ( a[ h[0] ], h[0]); 
		c.emplace_back ( a[ h[1] ], h[1]);
		sort (c.begin(),c.end());
		
		if ( a[d] > a[ c.back().second ]) {
			if (c[0].second == v[p]) {cnt++; if (flag) F.push_back(g);}
		}
		else {
			auto pos = lower_bound(c.begin(),c.end(), make_pair(a[d],0));
			if ( (*pos).second == v[p]) {cnt++; if (flag) F.push_back(g);}
		} 
	}
	}
	if (flag) Left = F;
	return cnt;
}
void cnt_min(){
	int total_ans = 10000;
  for (auto v:sall) {
	 		int d = v[3];
	 		vector<int> g;
	 		int c = 0;
	 		
	 		for (int  i =0 ; i < 3; i++) g.push_back(v[i]);
	 		for (int i = 0; i < 3; i++)
	 		c = max(c,calc(g,i,3,d));
	 		
	 		minimize(total_ans,c,3,v);
		 }
	 	for (auto v : all)  {
	 	for (int type = 2; type >= 0; type--) {
	 		int c = 0;
	 	for (int i = 0; i < 3; i++) 
	 		c = max(c,calc(v,i,type,0));
	 	minimize(total_ans,c,type,v);
	 	}
	 	}
}
 
void orderCoins() {
	Left = Left1;
    int r = 10;
    
    while(r--) {
    cnt_min();
    vector<int> v = to_ask;
    
    int p;
    flag = 1;
    if (oper == 0) {
    	int a = getLightest(v[0],v[1],v[2]);
    	for (int i = 0; i < 3; i++) if (a == v[i]) p = i;
		calc(v,p,0,0); 
	}
	if (oper == 1) {
    	int a = getHeaviest(v[0],v[1],v[2]);
    	for (int i = 0; i < 3; i++) if (a == v[i]) p = i;
		calc(v,p,1,0);
	}
	if (oper == 2) {
    	int a = getMedian(v[0],v[1],v[2]);
		for (int i = 0; i < 3; i++) if (a == v[i]) p = i;
		calc(v,p,2,0);    	
	}
	if (oper == 3) {
		int a = getNextLightest(v[0], v[1], v[2], v[3]);
		int d = v[3];
			vector<int> g;
	 		for (int  i =0 ; i < 3; i++) g.push_back(v[i]);
	 	for (int i = 0; i < 3; i++) if (a == v[i]) p = i;
	 	calc(g,p,3,d);
    }
      flag = 0;
	 if (Left.size() == 1){
	 	int W[6];
	 	for (int i = 0 ; i <  Left[0].size(); i++) W[i] =Left[0][i];
		answer(W);
	 	return;
	 } 
	}
}

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

scales.cpp:4:1: error: 'vector' does not name a type
 vector<vector<int> > all,sall;
 ^~~~~~
scales.cpp:5:1: error: 'vector' does not name a type
 vector<vector<int> > Left1,Left;
 ^~~~~~
scales.cpp:6:1: error: 'vector' does not name a type
 vector<int> g,to_ask;
 ^~~~~~
scales.cpp: In function 'void G(int)':
scales.cpp:12:3: error: 'Left1' was not declared in this scope
   Left1.push_back(g);
   ^~~~~
scales.cpp:12:19: error: 'g' was not declared in this scope
   Left1.push_back(g);
                   ^
scales.cpp:17:4: error: 'g' was not declared in this scope
    g.push_back(i);
    ^
scales.cpp: In function 'void init(int)':
scales.cpp:29:3: error: 'all' was not declared in this scope
   all.push_back({i,j,k});
   ^~~
scales.cpp:29:3: note: suggested alternative: 'll'
   all.push_back({i,j,k});
   ^~~
   ll
scales.cpp:32:4: error: 'sall' was not declared in this scope
    sall.push_back({i,j,k,f});
    ^~~~
scales.cpp:32:4: note: suggested alternative: 'll'
    sall.push_back({i,j,k,f});
    ^~~~
    ll
scales.cpp:36:2: error: 'Left' was not declared in this scope
  Left = Left1;
  ^~~~
scales.cpp:36:9: error: 'Left1' was not declared in this scope
  Left = Left1;
         ^~~~~
scales.cpp:25:15: warning: unused parameter 'T' [-Wunused-parameter]
 void init(int T) {
               ^
scales.cpp: At global scope:
scales.cpp:38:46: error: 'vector' has not been declared
 void minimize(int &total_ans,int &c,int type,vector<int> v) {
                                              ^~~~~~
scales.cpp:38:52: error: expected ',' or '...' before '<' token
 void minimize(int &total_ans,int &c,int type,vector<int> v) {
                                                    ^
scales.cpp: In function 'void minimize(int&, int&, int, int)':
scales.cpp:41:3: error: 'to_ask' was not declared in this scope
   to_ask = v;
   ^~~~~~
scales.cpp:41:12: error: 'v' was not declared in this scope
   to_ask = v;
            ^
scales.cpp: At global scope:
scales.cpp:45:1: error: 'vector' does not name a type
 vector<vector<int> > F;
 ^~~~~~
scales.cpp:47:10: error: 'vector' was not declared in this scope
 int calc(vector<int> v,int p = 0,int type = 0 ,int d = 0) {
          ^~~~~~
scales.cpp:47:17: error: expected primary-expression before 'int'
 int calc(vector<int> v,int p = 0,int type = 0 ,int d = 0) {
                 ^~~
scales.cpp:47:24: error: expected primary-expression before 'int'
 int calc(vector<int> v,int p = 0,int type = 0 ,int d = 0) {
                        ^~~
scales.cpp:47:34: error: expected primary-expression before 'int'
 int calc(vector<int> v,int p = 0,int type = 0 ,int d = 0) {
                                  ^~~
scales.cpp:47:48: error: expected primary-expression before 'int'
 int calc(vector<int> v,int p = 0,int type = 0 ,int d = 0) {
                                                ^~~
scales.cpp:47:57: error: expression list treated as compound expression in initializer [-fpermissive]
 int calc(vector<int> v,int p = 0,int type = 0 ,int d = 0) {
                                                         ^
scales.cpp: In function 'void cnt_min()':
scales.cpp:80:15: error: 'sall' was not declared in this scope
   for (auto v:sall) {
               ^~~~
scales.cpp:80:15: note: suggested alternative: 'calc'
   for (auto v:sall) {
               ^~~~
               calc
scales.cpp:82:5: error: 'vector' was not declared in this scope
     vector<int> g;
     ^~~~~~
scales.cpp:82:12: error: expected primary-expression before 'int'
     vector<int> g;
            ^~~
scales.cpp:85:34: error: 'g' was not declared in this scope
     for (int  i =0 ; i < 3; i++) g.push_back(v[i]);
                                  ^
scales.cpp:87:20: error: 'g' was not declared in this scope
     c = max(c,calc(g,i,3,d));
                    ^
scales.cpp:87:27: error: 'calc' cannot be used as a function
     c = max(c,calc(g,i,3,d));
                           ^
scales.cpp:87:9: error: 'max' was not declared in this scope
     c = max(c,calc(g,i,3,d));
         ^~~
scales.cpp:91:18: error: 'all' was not declared in this scope
    for (auto v : all)  {
                  ^~~
scales.cpp:91:18: note: suggested alternative: 'll'
    for (auto v : all)  {
                  ^~~
                  ll
scales.cpp:95:30: error: 'calc' cannot be used as a function
     c = max(c,calc(v,i,type,0));
                              ^
scales.cpp:95:9: error: 'max' was not declared in this scope
     c = max(c,calc(v,i,type,0));
         ^~~
scales.cpp: In function 'void orderCoins()':
scales.cpp:102:2: error: 'Left' was not declared in this scope
  Left = Left1;
  ^~~~
scales.cpp:102:9: error: 'Left1' was not declared in this scope
  Left = Left1;
         ^~~~~
scales.cpp:107:5: error: 'vector' was not declared in this scope
     vector<int> v = to_ask;
     ^~~~~~
scales.cpp:107:12: error: expected primary-expression before 'int'
     vector<int> v = to_ask;
            ^~~
scales.cpp:112:26: error: 'v' was not declared in this scope
      int a = getLightest(v[0],v[1],v[2]);
                          ^
scales.cpp:114:15: error: 'calc' cannot be used as a function
   calc(v,p,0,0); 
               ^
scales.cpp:117:26: error: 'v' was not declared in this scope
      int a = getHeaviest(v[0],v[1],v[2]);
                          ^
scales.cpp:119:15: error: 'calc' cannot be used as a function
   calc(v,p,1,0);
               ^
scales.cpp:122:24: error: 'v' was not declared in this scope
      int a = getMedian(v[0],v[1],v[2]);
                        ^
scales.cpp:124:15: error: 'calc' cannot be used as a function
   calc(v,p,2,0);     
               ^
scales.cpp:127:27: error: 'v' was not declared in this scope
   int a = getNextLightest(v[0], v[1], v[2], v[3]);
                           ^
scales.cpp:129:11: error: expected primary-expression before 'int'
    vector<int> g;
           ^~~
scales.cpp:130:34: error: 'g' was not declared in this scope
     for (int  i =0 ; i < 3; i++) g.push_back(v[i]);
                                  ^
scales.cpp:132:9: error: 'g' was not declared in this scope
    calc(g,p,3,d);
         ^
scales.cpp:132:16: error: 'calc' cannot be used as a function
    calc(g,p,3,d);
                ^