Submission #727437

#TimeUsernameProblemLanguageResultExecution timeMemory
727437Vu_CG_CoderScales (IOI15_scales)C++14
38.46 / 100
1 ms212 KiB
/* [Author : Hoang Duy Vu] - THPT Chuyen Nguyen Du */ //#pragma GCC optimize(" unroll-loops") //#pragma gcc optimize("Ofast") //#pragma GCC optimization("Ofast") //#pragma optimize(Ofast) #include "scales.h" #include <bits/stdc++.h> #define All(x) (x).begin(),(x).end() #define ll long long #define C make_pair #define fi first #define se second #define two second.first #define thr second.second #define TASK "txt" using namespace std; template<typename T> bool maximize(T &res, const T &val) { if (res < val) { res = val; return true; } return false; } template<typename T> bool minimize(T &res, const T &val) { if (res > val) { res = val; return true; } return false; } typedef pair<int,int> ii; typedef pair<int,ii> iii; const int LOG = 20; const int INF = 1e9 + 7; const ll LNF = 1e18 + 7; const int mod = 1e9 + 7; const int N = 10; int A[N]; int B[N]; int f[N] = {0}; int cnt = 0; int val[N]; // int getLightest(int a , int b , int c) // { // for (int i = 0 ; i < 5 ; i++) // if (val[i] == a || val[i] == b || val[i] == c) return val[i]; // } // int getMedian(int a , int b , int c) // { // int d = 0; // for (int i = 0 ; i < 5 ; i++) // if (val[i] == a || val[i] == b || val[i] == c) // { // d++; // if (d == 2) return val[i]; // } // } // void answer(int W[]) // { // for (int i = 0 ; i < 6 ; i++) if (W[i] != val[i]) // { // for (int j = 0 ; j < 6 ; j++) cout << val[j] << " "; // cout << "\n"; // break; // } // } void init(int T) { } void orderCoins() { int W[] = {1,2,3,4,5,6}; memset(f,0,sizeof(f)); cnt = 0; A[1] = getLightest(1, 2, 3); A[2] = getMedian(1, 2, 3); f[A[1]]++; f[A[2]]++; B[1] = getLightest(4, 5, 6); B[2] = getMedian(4, 5, 6); f[B[1]]++; f[B[2]]++; for (int i = 1 ; i <= 3 ; i++) if (!f[i]) A[3] = i; for (int i = 4 ; i <= 6 ; i++) if (!f[i]) B[3] = i; if (getLightest(A[3],B[1],B[2]) == A[3]) { for (int i = 1 ; i <= 3 ; i++) W[cnt++] = A[i]; for (int i = 1 ; i <= 3 ; i++) W[cnt++] = B[i]; answer(W); return ; } if (getLightest(B[3],A[1],A[2]) == B[3]) { for (int i = 1 ; i <= 3 ; i++) W[cnt++] = B[i]; for (int i = 1 ; i <= 3 ; i++) W[cnt++] = A[i]; answer(W); return ; } int l = 1 , r = 1; int x = getMedian(A[1],A[2],B[1]); if (x == A[1]) { W[0] = B[1]; l = 1 , r = 2; } else if (x == A[2]) { W[0] = A[1]; W[1] = A[2]; l = 3 , r = 1; } else if (x == B[1]) { W[0] = A[1]; W[1] = B[1]; l = 2 , r = 2; } cnt = l + r - 2; while (cnt < 6) { if (l > 3) { W[cnt++] = B[r]; r++; } else if (r > 3) { W[cnt++] = A[l]; l++; } if (r > 3 || l > 3) continue; if (cnt == 3) { if (l == 2) { int y = getMedian(A[l],A[l + 1],B[r]); if (y == A[2]) { W[3] = B[3]; W[4] = A[2]; W[5] = A[3]; break; } if (y == A[3]) { W[3] = A[2]; W[4] = A[3]; W[5] = B[3]; break; } if (y == B[3]) { W[3] = A[2]; W[4] = B[3]; W[5] = A[3]; break; } } else { int y = getMedian(A[l],B[r + 1],B[r]); if (y == B[2]) { W[3] = A[3]; W[4] = B[2]; W[5] = B[3]; break; } if (y == B[3]) { W[3] = B[2]; W[4] = B[3]; W[5] = A[3]; break; } if (y == A[3]) { W[3] = B[2]; W[4] = A[3]; W[5] = B[3]; break; } } break; } int y = getMedian(W[0],A[l],B[r]); if (y == A[l]) { W[cnt++] = A[l]; l++; } else { W[cnt++] = B[r]; r++; } } // for (int i = 0 ; i < 6 ; i++) cout << W[i] << " "; answer(W); } // int main() // { // ios_base::sync_with_stdio(0); // cin.tie(NULL); cout.tie(NULL); // if(fopen(TASK".inp", "r")){ // freopen(TASK".inp","r",stdin); // freopen(TASK".out","w",stdout); // } // int t; // cin >> t; // while (t--) // { // for (int i = 0 ; i < 6 ; i++) cin >> val[i]; // orderCoins(); // } // return 0; // } // int main() // { // ios_base::sync_with_stdio(0); // cin.tie(NULL); cout.tie(NULL); // if(fopen(TASK".inp", "r")){ // freopen(TASK".inp","r",stdin); // freopen(TASK".out","w",stdout); // } // // int b[6] = {0}; // for (int i = 0 ; i < 6 ; i++) val[i] = i + 1; // do // { // orderCoins(); // } while (next_permutation(val,val + 6)); // return 0; // }

Compilation message (stderr)

scales.cpp: In function 'void init(int)':
scales.cpp:63:15: warning: unused parameter 'T' [-Wunused-parameter]
   63 | void init(int T) {
      |           ~~~~^
#Verdict Execution timeMemoryGrader output
Fetching results...