답안 #802703

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
802703 2023-08-02T13:30:34 Z Liudas 저울 (IOI15_scales) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "scales.h"
using namespace std;
int getHeaviest(int a, int b, int c){
    int d;
    cout<< a << " " << b << " " << c << endl;
    cin >> d;
    return d;
}
int getLightest(int a, int b, int c){
    int d;
    cout<< a << " " << b << " " << c << endl;
    cin >> d;
    return d;
}
int getMedian(int a, int b, int c){
    int d;
    cout<< a << " " << b << " " << c << endl;
    cin >> d;
    return d;
}
void answer(int a[]){
    for(int i = 0 ; i< 6;  i++){
        cout << a[i] <<" ";
    }
    cout << endl;
}
void orderCoins(){
    int arr[6];
    vector<int> b = {1,2,3,4,5,6};
    int ans = getHeaviest(1,2,3);
    int ans2 = getHeaviest(4, 5, 6);
    int ans3 = getHeaviest(ans, ans2, (ans == 3? 2: 3));
    arr[5] = ans3;
    b.erase(find(b.begin(), b.end(), ans3));
    if(ans == ans3){
        b.erase(find(b.begin(), b.end(), ans2));
        ans3 = getHeaviest(b[0], b[1], ans2);
        b.push_back(ans2);
    }
    else{
        b.erase(find(b.begin(), b.end(), ans));
        ans3 = getHeaviest(b[2], b[3], ans);
        b.push_back(ans);
    }
    b.erase(find(b.begin(), b.end(), ans3));
    arr[4] = ans3;
    int c1 = b[0], c2 = b[1], c3 = b[2], c4;
    ans = getLightest(b[0],b[1],b[2]);
    b.erase(find(b.begin(), b.end(), ans));
    ans2 = getHeaviest(b[0], b[1], b[2]);
    b.push_back(ans);
    b.erase(find(b.begin(), b.end(), ans2));
    arr[3] = ans2;
    ans3 = getMedian(b[0], b[1], b[2]);
    if(ans == c1){
        b.erase(find(b.begin(), b.end(), c1));
        if(ans2 == c2){
        b.erase(find(b.begin(), b.end(), c3));
        c4 = c3;
        }
        else{
        b.erase(find(b.begin(), b.end(), c2));
        c4 = c2;
        }
        if(ans3 == ans){
            arr[0] = b[0];
            arr[1] = ans;
            arr[2] = c4;
        }
        else if(ans3 == c4){
            arr[0] = ans;
            arr[1] = c4;
            arr[2] = b[0];
        }
        else{
            arr[0] = ans;
            arr[1] = b[0];
            arr[2] = c4;
        }

    }
    if(ans == c2){
        b.erase(find(b.begin(), b.end(), c2));
        if(ans2 == c1){
        b.erase(find(b.begin(), b.end(), c3));
        c4 = c3;
        }
        else{
        b.erase(find(b.begin(), b.end(), c1));
        c4 = c1;
        }
        if(ans3 == ans){
            arr[0] = b[0];
            arr[1] = ans;
            arr[2] = c4;
        }
        else if(ans3 == c4){
            arr[0] = ans;
            arr[1] = c4;
            arr[2] = b[0];
        }
        else{
            arr[0] = ans;
            arr[1] = b[0];
            arr[2] = c4;
        }
    }
    if(ans == c3){
        b.erase(find(b.begin(), b.end(), c3));
        if(ans2 == c2){
        b.erase(find(b.begin(), b.end(), c1));
        c4 = c1;
        }
        else{
        b.erase(find(b.begin(), b.end(), c2));
        c4 = c2;
        }
        if(ans3 == ans){
            arr[0] = b[0];
            arr[1] = ans;
            arr[2] = c4;
        }
        else if(ans3 == c4){
            arr[0] = ans;
            arr[1] = c4;
            arr[2] = b[0];
        }
        else{
            arr[0] = ans;
            arr[1] = b[0];
            arr[2] = c4;
        }
    }
    answer(arr);
}
void init(int T){
}

Compilation message

scales.cpp: In function 'void init(int)':
scales.cpp:137:15: warning: unused parameter 'T' [-Wunused-parameter]
  137 | void init(int T){
      |           ~~~~^
/usr/bin/ld: /tmp/ccdz4eG9.o: in function `getMedian':
scales.cpp:(.text+0xb0): multiple definition of `getMedian'; /tmp/ccjqzUH7.o:grader.c:(.text+0x90): first defined here
/usr/bin/ld: /tmp/ccdz4eG9.o: in function `getHeaviest':
scales.cpp:(.text+0x1d0): multiple definition of `getHeaviest'; /tmp/ccjqzUH7.o:grader.c:(.text+0x180): first defined here
/usr/bin/ld: /tmp/ccdz4eG9.o: in function `getLightest':
scales.cpp:(.text+0x1e0): multiple definition of `getLightest'; /tmp/ccjqzUH7.o:grader.c:(.text+0x240): first defined here
/usr/bin/ld: /tmp/ccdz4eG9.o: in function `answer':
scales.cpp:(.text+0x1f0): multiple definition of `answer'; /tmp/ccjqzUH7.o:grader.c:(.text+0x0): first defined here
collect2: error: ld returned 1 exit status