Submission #31261

#TimeUsernameProblemLanguageResultExecution timeMemory
31261top34051Scales (IOI15_scales)C++14
0 / 100
0 ms2024 KiB
#include "scales.h"
#include<bits/stdc++.h>
using namespace std;

vector<int> p,a,b,tp;

void init(int T) {
}

void orderCoins() {
    int i,x,temp,mn,t1,t2;
    int W[] = {1, 2, 3, 4, 5, 6};

    a.clear(); b.clear();
    t1 = getLightest(1,2,3);
    t2 = getLightest(4,5,6);
    for(i=1;i<=3;i++) {
        if(i!=t1 && i!=t2) {
            mn = getLightest(i,t1,t2);
            break;
        }
    }
    for(i=1;i<=3;i++) if(i!=mn) a.push_back(i);
    for(i=4;i<=6;i++) if(i!=mn) b.push_back(i);
    if(a.size()>b.size()) swap(a,b);

    p.clear();
    p.push_back(mn);
    for(i=0;i<b.size();i++) p.push_back(b[i]);
    cerr << "p : ";

    for(i=0;i<p.size();i++) cerr << p[i] << " ";
    cerr << "\n";

    cerr << "a : ";
    for(i=0;i<a.size();i++) cerr << a[i] << " ";
    cerr << "\n";

    x = a[0];
    temp = getNextLightest(p[0],p[1],p[2],x);
    if(temp==p[0]) {
        temp = getNextLightest(p[0],p[1],p[3],x);
        if(temp==p[0]) p.push_back(x);
        else {
            tp.clear();
            for(i=0;i<p.size();i++) {
                if(temp==p[i]) tp.push_back(x);
                tp.push_back(p[i]);
            }
            p = tp;
        }
    }
    else {
        tp.clear();
        for(i=0;i<p.size();i++) {
            if(temp==p[i]) tp.push_back(x);
            tp.push_back(p[i]);
        }
        p = tp;
    }

    x = a[1];
    temp = getNextLightest(p[0],p[1],p[2],x);
    if(temp==p[0]) {
        temp = getNextLightest(p[0],p[3],p[4],x);
        if(temp==p[0]) p.push_back(x);
        else {
            tp.clear();
            for(i=0;i<p.size();i++) {
                if(temp==p[i]) tp.push_back(x);
                tp.push_back(p[i]);
            }
            p = tp;
        }
    }
    else {
        tp.clear();
        for(i=0;i<p.size();i++) {
            if(temp==p[i]) tp.push_back(x);
            tp.push_back(p[i]);
        }
        p = tp;
    }

    for(i=0;i<6;i++) W[i] = p[i];

    answer(W);
}

Compilation message (stderr)

scales.cpp:7:15: warning: unused parameter 'T' [-Wunused-parameter]
 void init(int T) {
               ^
scales.cpp: In function 'void orderCoins()':
scales.cpp:29:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(i=0;i<b.size();i++) p.push_back(b[i]);
              ^
scales.cpp:32:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(i=0;i<p.size();i++) cerr << p[i] << " ";
              ^
scales.cpp:36:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(i=0;i<a.size();i++) cerr << a[i] << " ";
              ^
scales.cpp:46:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(i=0;i<p.size();i++) {
                      ^
scales.cpp:55:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(i=0;i<p.size();i++) {
                  ^
scales.cpp:69:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(i=0;i<p.size();i++) {
                      ^
scales.cpp:78:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(i=0;i<p.size();i++) {
                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...