Submission #57865

#TimeUsernameProblemLanguageResultExecution timeMemory
57865E869120Scales (IOI15_scales)C++14
45.45 / 100
3 ms720 KiB
#include "scales.h" #include <iostream> #include <vector> #include <algorithm> using namespace std; // ----------------------------- /*int Weight[7], Queries = 0; int getLightest(int A, int B, int C) { Queries++; if (A <= 0 || A >= 7 || B <= 0 || B >= 7 || C <= 0 || C >= 7 || A == B || B == C || C == A) cout << "Wrong Answer [1]" << endl; vector<pair<int, int>>V; for (int i = 1; i <= 6; i++) { if (Weight[i] == A) V.push_back(make_pair(i, A)); if (Weight[i] == B) V.push_back(make_pair(i, B)); if (Weight[i] == C) V.push_back(make_pair(i, C)); } sort(V.begin(), V.end()); return V[0].second; } int getMedian(int A, int B, int C) { Queries++; if (A <= 0 || A >= 7 || B <= 0 || B >= 7 || C <= 0 || C >= 7 || A == B || B == C || C == A) cout << "Wrong Answer [2]" << endl; vector<pair<int, int>>V; for (int i = 1; i <= 6; i++) { if (Weight[i] == A) V.push_back(make_pair(i, A)); if (Weight[i] == B) V.push_back(make_pair(i, B)); if (Weight[i] == C) V.push_back(make_pair(i, C)); } sort(V.begin(), V.end()); return V[1].second; } int getHeaviest(int A, int B, int C) { Queries++; if (A <= 0 || A >= 7 || B <= 0 || B >= 7 || C <= 0 || C >= 7 || A == B || B == C || C == A) cout << "Wrong Answer [3]" << endl; vector<pair<int, int>>V; for (int i = 1; i <= 6; i++) { if (Weight[i] == A) V.push_back(make_pair(i, A)); if (Weight[i] == B) V.push_back(make_pair(i, B)); if (Weight[i] == C) V.push_back(make_pair(i, C)); } sort(V.begin(), V.end()); return V[2].second; } void answer(int W[]) { for (int i = 0; i < 6; i++) { if (W[i] != Weight[i + 1]) { cout << "Wrong Answer [4]" << endl; return; } } cout << "Accepted : Total Number of Queries = " << Queries << endl; }*/ // ----------------------------- void init(int T) { } vector<int>V; bool used[7]; void orderCoins() { for (int i = 1; i <= 6; i++) used[i] = false; V.clear(); for (int i = 0; i < 3; i++) { // Calculate the 1-st to 3-rd lightest of 6. vector<int>vec; for (int j = 1; j <= 6; j++) { if (used[j] == false)vec.push_back(j); } while (vec.size() >= 2) { int G = getLightest(vec[0], vec[1], vec[2]); vector<int>H; for (int j = 0; j < vec.size(); j++) { if (j < 3 && vec[j] != G) continue; H.push_back(vec[j]); } if (H.size() == 2) { for (int j = 1; j <= 6; j++) { if (j != H[0] && j != H[1] && used[j] == false) { H.push_back(j); break; } } } vec = H; } used[vec[0]] = true; V.push_back(vec[0]); } vector<int>vec; for (int i = 1; i <= 6; i++) { if (used[i] == false) vec.push_back(i); } int G1 = getLightest(vec[0], vec[1], vec[2]); used[G1] = true; V.push_back(G1); int G2 = getMedian(vec[0], vec[1], vec[2]); used[G2] = true; V.push_back(G2); for (int i = 1; i <= 6; i++) { if (used[i] == false) V.push_back(i); } int W[6] = { V[0],V[1],V[2],V[3],V[4],V[5] }; answer(W); }

Compilation message (stderr)

In file included from grader.c:2:0:
graderlib.c: In function 'void answer(int*)':
graderlib.c:53:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
     if (_ghksjhdfkae19ga_ > 1) 
     ^~
graderlib.c:56:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
  for (i = 0; i < 6; i++) {
  ^~~
scales.cpp: In function 'void init(int)':
scales.cpp:56:15: warning: unused parameter 'T' [-Wunused-parameter]
 void init(int T) {
               ^
scales.cpp: In function 'void orderCoins()':
scales.cpp:63:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  for (int i = 1; i <= 6; i++) used[i] = false; V.clear();
  ^~~
scales.cpp:63:48: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  for (int i = 1; i <= 6; i++) used[i] = false; V.clear();
                                                ^
scales.cpp:73:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for (int j = 0; j < vec.size(); j++) {
                    ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...