Submission #356669

#TimeUsernameProblemLanguageResultExecution timeMemory
356669urd05Scales (IOI15_scales)C++14
45.45 / 100
1 ms512 KiB
#include "scales.h"
#include <bits/stdc++.h>
using namespace std;
 
void init(int T) {
    /* ... */
}
 
int g(vector<int> v) {
    for(int i=1;i<=6;i++) {
        for(int j=0;j<v.size();j++) {
            if (v[j]==i) {
                break;
            }
            if (j+1==v.size()) {
                return i;
            }
        }
    }
}
 
int get(vector<int> v) {
    if (v.size()==1) {
        return v[0];
    }
    if (v.size()==6) {
        int a=getLightest(1,2,3);
        int b=getLightest(4,5,6);
      int c;
      for(int i=1;i<=6;i++) {
        if (i!=a&&i!=b) {
          c=i;
        }
      }
        return getLightest(a,b,c);
    }
    int val=v[0];
    for(int i=1;i<v.size();i+=2) {
        if (i+1==v.size()) {
            val=getMedian(val,v[i],g(v));
            continue;
        }
        val=getLightest(val,v[i],v[i+1]);
    }
    return val;
}
 
void orderCoins() {
    int W[6];
    vector<int> v;
    for(int i=1;i<=6;i++) {
        v.push_back(i);
    }
    for(int i=0;i<6;i++) {
        vector<int> nt;
        W[i]=get(v);
        for(int j=0;j<v.size();j++) {
            if (v[j]!=W[i]) {
                nt.push_back(v[j]);
            }
        }
        v.clear();
        for(int j=0;j<nt.size();j++) {
            v.push_back(nt[j]);
        }
    }
    answer(W);
    return;
}

Compilation message (stderr)

scales.cpp: In function 'void init(int)':
scales.cpp:5:15: warning: unused parameter 'T' [-Wunused-parameter]
    5 | void init(int T) {
      |           ~~~~^
scales.cpp: In function 'int g(std::vector<int>)':
scales.cpp:11:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |         for(int j=0;j<v.size();j++) {
      |                     ~^~~~~~~~~
scales.cpp:15:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |             if (j+1==v.size()) {
      |                 ~~~^~~~~~~~~~
scales.cpp: In function 'int get(std::vector<int>)':
scales.cpp:38:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for(int i=1;i<v.size();i+=2) {
      |                 ~^~~~~~~~~
scales.cpp:39:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         if (i+1==v.size()) {
      |             ~~~^~~~~~~~~~
scales.cpp: In function 'void orderCoins()':
scales.cpp:57:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |         for(int j=0;j<v.size();j++) {
      |                     ~^~~~~~~~~
scales.cpp:63:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |         for(int j=0;j<nt.size();j++) {
      |                     ~^~~~~~~~~~
scales.cpp: In function 'int g(std::vector<int>)':
scales.cpp:20:1: warning: control reaches end of non-void function [-Wreturn-type]
   20 | }
      | ^
scales.cpp: In function 'int get(std::vector<int>)':
scales.cpp:35:27: warning: 'c' may be used uninitialized in this function [-Wmaybe-uninitialized]
   35 |         return getLightest(a,b,c);
      |                ~~~~~~~~~~~^~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...