제출 #1367062

#제출 시각아이디문제언어결과실행 시간메모리
1367062eyadooz저울 (IOI15_scales)C++20
컴파일 에러
0 ms0 KiB
#include "scales.h"
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int) (x).size()
#define endl '\n'


void init(int T) {
    /* ... */
}
// int getHeaviest(int a, int b, int c){
//     cout << "H: " << a << " " << b << "  "<< c << endl << flush;
//     int x;
//     cin >> x;
//     return x;
// }
// int getMedian(int a, int b, int c){
//     cout << "M: " << a << " " << b << "  "<< c << endl << flush;
//     int x;
//     cin >> x;
//     return x;
// }
// int getLightest(int a, int b, int c){
//     cout << "L: " << a << " " << b << "  "<< c << endl << flush;
//     int x;
//     cin >> x;
//     return x;
// }
// void answer(int w[]){
//     for(int i = 0;i<6;i++) cout << w[i] << " ";
//         return ;
// }
void orderCoins() {
    vector<int> a, b;
    a.pb(getLightest(1, 2, 3));  
    a.pb(getMedian(1, 2, 3));  
    if(a.find(3)==a.end()) a.pb(3);
    if(a.find(2)==a.end()) a.pb(2);
    if(a.find(1)==a.end()) a.pb(1);
    b.pb(getLightest(4, 5, 6));  
    b.pb(getMedian(4, 5, 6));  
    if(b.find(6)==b.end()) b.pb(6);
    if(b.find(5)==b.end()) b.pb(5);
    if(b.find(4)==b.end()) b.pb(4);
    
    vector<int> s;
    while(min(sz(a), sz(b))>=1&&sz(a)+sz(b)>=3) {
        if(sz(a)<sz(b)) swap(a, b);
        auto it=getLightest(a[0], a[1], b[0]);
        s.pb(it);
        if(find(all(a), it)!=a.end()) a.erase(find(all(a), it));
        if(find(all(b), it)!=b.end()) b.erase(find(all(b), it));
    }
    if(sz(a)&&sz(b)) {
        auto it=getMedian(a[0], b[0], s.back());
        s.pb(it);
        if(find(all(a), it)!=a.end()) a.erase(find(all(a), it));
        if(find(all(b), it)!=b.end()) b.erase(find(all(b), it));    
    }
    reverse(all(a));
    reverse(all(b));
    while(sz(a)) s.pb(a.back()), a.pop_back();
    while(sz(b)) s.pb(b.back()), b.pop_back();
    int w[6];
    for(int i = 0;i < 6;i++) w[i]=s[i];
    answer(w);
}

컴파일 시 표준 에러 (stderr) 메시지

scales.cpp: In function 'void orderCoins()':
scales.cpp:44:10: error: 'class std::vector<int>' has no member named 'find'
   44 |     if(a.find(3)==a.end()) a.pb(3);
      |          ^~~~
scales.cpp:45:10: error: 'class std::vector<int>' has no member named 'find'
   45 |     if(a.find(2)==a.end()) a.pb(2);
      |          ^~~~
scales.cpp:46:10: error: 'class std::vector<int>' has no member named 'find'
   46 |     if(a.find(1)==a.end()) a.pb(1);
      |          ^~~~
scales.cpp:49:10: error: 'class std::vector<int>' has no member named 'find'
   49 |     if(b.find(6)==b.end()) b.pb(6);
      |          ^~~~
scales.cpp:50:10: error: 'class std::vector<int>' has no member named 'find'
   50 |     if(b.find(5)==b.end()) b.pb(5);
      |          ^~~~
scales.cpp:51:10: error: 'class std::vector<int>' has no member named 'find'
   51 |     if(b.find(4)==b.end()) b.pb(4);
      |          ^~~~