제출 #1252044

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

// int use_detector(int x){
// //implement your own, comment this function when submitting
// }

vector<int> find_routers(int l, int n, int q){
    //code
    vector<int> ans(n,-1);
    vector<bool> seen(n,false);
    int counter=0;
    int call = 0;
    for(int i = 0; i <= l && counter<n && call < q; i+=2)
    {
      int pos = use_detector(i);
      call++;
      int idx = pos-1;
      if(!seen{idx})
      {
        seen[idx] =true;
        ans[idx] = i;
        counter++;
        
      }

    }

    return ans;
}
// comment main function when submitting
// int main(){
//     int mx,n,q;
//     cin>>mx>>n>>q;
//     cout<<"GIVE INPUT:"<<endl;
//     find_routers(mx,n,q);
//     cout<<"DONE"<<endl;
    
//     return 0; 
// }

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

routers.cpp: In function 'std::vector<int> find_routers(int, int, int)':
routers.cpp:20:10: error: no match for 'operator!' (operand type is 'std::vector<bool>')
   20 |       if(!seen{idx})
      |          ^~~~~
routers.cpp:20:10: note: candidate: 'operator!(bool)' (built-in)
routers.cpp:20:10: note:   no known conversion for argument 1 from 'std::vector<bool>' to 'bool'
routers.cpp:20:15: error: expected ')' before '{' token
   20 |       if(!seen{idx})
      |         ~     ^
      |               )