Submission #485447

# Submission time Handle Problem Language Result Execution time Memory
485447 2021-11-07T19:16:44 Z MohamedAliSaidane Scales (IOI15_scales) C++14
0 / 100
1 ms 204 KB
#include <bits/stdc++.h>
#include "scales.h"
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> ti;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ld,ld> pld;
#define pb push_back
#define popb pop_back()
#define pf push_front
#define popf pop_front
#define ff first
#define ss second
#define MOD (ll)(1000000007)
#define INF (ll) (1e18)
#define all(v) (v).begin(),(v).end()
const int nx[8] = {0, 0, 1, -1,1,1,-1,-1}, ny[8] = {1, -1, 0, 0,1,-1,1,-1}; //East, West, South, North+
ll gcd(ll a , ll b) {return b ? gcd(b , a % b) : a ;}
ll lcm(ll a, ll b){return (a / gcd(a, b)) * b;}
////////////******SOLUTION******\\\\\\\\\\\

int light(int A, int B, int C)
{
    return getLightest(A, B, C);
}
int heav(int A, int B, int C)
{
    return getHeaviest(A,B,C);
}
int med(int A, int B, int C)
{
    return getMedian(A,B,C);
}
int nxt(int A, int B, int C, int D)
{
    return getNextLightest(A,B,C,D);
}

void orderCoins()
{
    int W[6];
    int adj[7][7];
    memset(adj,0,sizeof(adj));
    int X = light(1,2,3);
    int U = heav(1,2,3);
    int M;
    for(int i = 1; i <= 3; i++)
        if(X != i && U != i)
            M = i;
    int Y = light(4,5,6);
    int V = heav(4,5,6);
    int N;
    for(int i= 4; i <= 6; i ++)
        if(Y != i && V != i)
            N = i;
    int anx = med(M,N,V);
    if(anx == N)
    {
        swap(X,Y);
        swap(M,N);
        swap(U,V);
        anx = med(X,Y,N);
        W[0] = anx == Y? X: Y;
        W[1] = anx;
        W[2] = anx == X? N: X;
        anx = med(M,U,V);
        W[3] = anx == M? V: M;
        W[4] = anx;
        W[5] = anx == V? U: V;
        answer(W);
        return ;
    }
    else if(anx == M)
    {
        // Y < N < M < V
        anx = med(X,Y,N);
        W[0] = anx == Y? X: Y;
        W[1] = anx;
        W[2] = anx == X? N: X;
        anx = med(M,U,V);
        W[3] = anx == M? V: M;
        W[4] = anx;
        W[5] = anx == V? U: V;
        answer(W);
        return ;
    }
    else
    {
        // N < V < M < U
        anx = med(X,Y,N);
        int five = M;
        int six = U;
        int one, two, three, four;
        if(anx == X)
        {
            // Y < X < N < V < M < U
            one = Y; two = X; three = N, four = V;
        }
        else if(anx == Y)
        {
            // X < Y < N < V < M < U
            one = X, two = Y, three = N, four = V;
        }
        else
        {
            // Y < N < X, V < M < U
            one = Y, two = N;
            three = light(X,V,U);
            four = three == X? V: X;
        }
        W[0] = one, W[1] = two, W[2] = three, W[3] = four; W[4] = five; W[5] = six;
        answer(W);
        return ;

    }

}
void init(int T)
{
    return ;
}
/*int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    solve();
}*/

Compilation message

scales.cpp:25:1: warning: multi-line comment [-Wcomment]
   25 | ////////////******SOLUTION******\\\\\\\\\\\
      | ^
scales.cpp: In function 'void init(int)':
scales.cpp:123:15: warning: unused parameter 'T' [-Wunused-parameter]
  123 | void init(int T)
      |           ~~~~^
scales.cpp: In function 'void orderCoins()':
scales.cpp:72:24: warning: 'N' may be used uninitialized in this function [-Wmaybe-uninitialized]
   72 |         W[3] = anx == M? V: M;
      |                ~~~~~~~~^~~~~~
scales.cpp:37:21: warning: 'M' may be used uninitialized in this function [-Wmaybe-uninitialized]
   37 |     return getMedian(A,B,C);
      |            ~~~~~~~~~^~~~~~~
scales.cpp:51:9: note: 'M' was declared here
   51 |     int M;
      |         ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Incorrect 0 ms 204 KB Output isn't correct
4 Incorrect 0 ms 204 KB Output isn't correct
5 Incorrect 0 ms 204 KB Output isn't correct
6 Incorrect 0 ms 204 KB Output isn't correct
7 Incorrect 0 ms 204 KB Output isn't correct
8 Incorrect 0 ms 204 KB Output isn't correct
9 Incorrect 0 ms 204 KB Output isn't correct
10 Incorrect 0 ms 204 KB Output isn't correct
11 Incorrect 0 ms 204 KB Output isn't correct
12 Incorrect 0 ms 204 KB Output isn't correct
13 Incorrect 1 ms 204 KB Output isn't correct
14 Incorrect 0 ms 204 KB Output isn't correct
15 Incorrect 0 ms 204 KB Output isn't correct
16 Incorrect 0 ms 204 KB Output isn't correct
17 Incorrect 0 ms 204 KB Output isn't correct
18 Incorrect 0 ms 204 KB Output isn't correct
19 Incorrect 0 ms 204 KB Output isn't correct
20 Incorrect 0 ms 204 KB Output isn't correct
21 Incorrect 0 ms 204 KB Output isn't correct
22 Incorrect 0 ms 204 KB Output isn't correct
23 Incorrect 0 ms 204 KB Output isn't correct
24 Incorrect 0 ms 204 KB Output isn't correct
25 Incorrect 0 ms 204 KB Output isn't correct
26 Incorrect 0 ms 204 KB Output isn't correct
27 Incorrect 0 ms 204 KB Output isn't correct
28 Incorrect 0 ms 204 KB Output isn't correct
29 Incorrect 0 ms 204 KB Output isn't correct
30 Incorrect 1 ms 204 KB Output isn't correct
31 Incorrect 0 ms 204 KB Output isn't correct
32 Incorrect 0 ms 204 KB Output isn't correct
33 Incorrect 0 ms 204 KB Output isn't correct
34 Incorrect 1 ms 204 KB Output isn't correct
35 Incorrect 0 ms 204 KB Output isn't correct
36 Incorrect 0 ms 204 KB Output isn't correct
37 Incorrect 0 ms 204 KB Output isn't correct
38 Incorrect 0 ms 204 KB Output isn't correct
39 Incorrect 0 ms 204 KB Output isn't correct
40 Incorrect 0 ms 204 KB Output isn't correct