Submission #424800

#TimeUsernameProblemLanguageResultExecution timeMemory
424800ollelScales (IOI15_scales)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include <iostream> #include "scales.h" using namespace std; #define rep(i,a,b) for(int i = a; i < b; i++) #define pb push_back #define lso(x) x&(-x) typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; int t; // int getLightest(vi x) { // cout << "lightest:"; // rep(i,0,3) cout << x[i] << " ";cout<<endl; // int ans; cin >> ans; return ans; // } // int getNextLightest(vi x) { // cout << "next lightest:"; // rep(i,0,4) cout << x[i] << " ";cout<<endl; // int ans; cin >> ans; return ans; // } // int getMedian(vi x) { // cout << "Median:"; // rep(i,0,3) cout << x[i] << " ";cout<<endl; // int ans; cin >> ans; return ans; // } void init(int T) {t = T;} // void answer(vi x) {rep(i,0,6) cout << x[i] << " ";} void orderCoins() { vi first(3), second(3); first[0] = getLightest(1, 2, 3); first[1] = getMedian(1, 2, 3); rep(i, 1, 4) if (i != first[0] && i != first[1]) first[2] = i; second[0] = getLightest(4, 5, 6); second[1] = getMedian(4, 5, 6); rep(i, 4, 7) if (i != second[0] && i != second[1]) second[2] = i; vi ordered; bool swp = false; int ans = getNextLightest(second[0], second[1], second[2], first[0]); if (ans == second[1]) { swp = true; swap(first, second); } if (ans == second[0] || swp) { ordered.pb(first[0]); ordered.pb(second[0]); int x = getNextLightest(second[2], second[1], first[2], first[1]); if (x == second[2]) { ordered.pb(second[1]); ordered.pb(first[1]); ordered.pb(first[2]); ordered.pb(second[2]); } else if (x == second[1]) { ordered.pb(first[1]); ordered.pb(second[1]); int y = getNextLightest(first[0], second[2], first[2], second[1]); if (y == first[2]) { ordered.pb(first[2]); ordered.pb(second[2]); } else { ordered.pb(second[2]); ordered.pb(first[2]); } } else if (x == first[2]) { int y = getMedian(first[1], second[2], second[3]) if (y == second[2]) { ordered.pb(first[1]); ordered.pb(first[2]); ordered.pb(second[1]); ordered.pb(second[2]); } else if (y == first[1]) { ordered.pb(second[1]); ordered.pb(first[1]); ordered.pb(first[2]); ordered.pb(second[2]); } else { ordered.pb(second[1]); ordered.pb(second[2]); ordered.pb(first[1]); ordered.pb(first[2]); } } } else { ordered.pb(second[0]); ordered.pb(second[1]); ordered.pb(first[0]); int med = getMedian(first[1], first[2], second[2]); if (med == first[1]) { ordered.pb(second[2]); ordered.pb(first[1]); ordered.pb(first[2]); } else if (med == first[2]) { ordered.pb(first[1]); ordered.pb(first[2]); ordered.pb(second[2]); } else { ordered.pb(first[1]); ordered.pb(second[2]); ordered.pb(first[2]); } } int o[6]; rep(i,0,6) o[i] = ordered[i]; answer(o); } // int main(){ // orderCoins(); // }

Compilation message (stderr)

scales.cpp: In function 'void orderCoins()':
scales.cpp:82:7: error: expected ',' or ';' before 'if'
   82 |       if (y == second[2]) {
      |       ^~
scales.cpp:81:11: warning: unused variable 'y' [-Wunused-variable]
   81 |       int y = getMedian(first[1], second[2], second[3])
      |           ^
scales.cpp:87:9: error: expected '}' before 'else'
   87 |       } else if (y == first[1]) {
      |         ^~~~
scales.cpp:80:29: note: to match this '{'
   80 |     else if (x == first[2]) {
      |                             ^
scales.cpp:87:18: error: 'y' was not declared in this scope
   87 |       } else if (y == first[1]) {
      |                  ^
scales.cpp: At global scope:
scales.cpp:101:3: error: expected unqualified-id before 'else'
  101 |   else {
      |   ^~~~
scales.cpp:6:20: error: expected unqualified-id before 'for'
    6 | #define rep(i,a,b) for(int i = a; i < b; i++)
      |                    ^~~
scales.cpp:122:3: note: in expansion of macro 'rep'
  122 |   rep(i,0,6) o[i] = ordered[i];
      |   ^~~
scales.cpp:122:7: error: 'i' does not name a type
  122 |   rep(i,0,6) o[i] = ordered[i];
      |       ^
scales.cpp:6:35: note: in definition of macro 'rep'
    6 | #define rep(i,a,b) for(int i = a; i < b; i++)
      |                                   ^
scales.cpp:122:7: error: 'i' does not name a type
  122 |   rep(i,0,6) o[i] = ordered[i];
      |       ^
scales.cpp:6:42: note: in definition of macro 'rep'
    6 | #define rep(i,a,b) for(int i = a; i < b; i++)
      |                                          ^
scales.cpp:123:9: error: expected constructor, destructor, or type conversion before '(' token
  123 |   answer(o);
      |         ^
scales.cpp:124:1: error: expected declaration before '}' token
  124 | }
      | ^