제출 #375538

#제출 시각아이디문제언어결과실행 시간메모리
375538MilosMilutinovicHandcrafted Gift (IOI20_gift)C++14
컴파일 에러
0 ms0 KiB
#include "gift.h" #include <bits/stdc++.h> using namespace std; #define pb push_back #define pii pair<int,int> vector<pii> Compress(vector<pii> a){ vector<pii> ev; for(auto i:a){ ev.pb({i.first,-1}); ev.pb({i.second,1}); } sort(ev.begin(),ev.end()); vector<pii> ans; int l,bal=0; for(auto i:ev){ if(i.second==-1){ if(bal==0)l=i.first; ++bal; }else{ --bal; if(bal==0)ans.pb({l,i.first}); //if(bal==0)printf("%i %i\n",l,i.first); } } return ans; } void craft(string s){cout<<s<<"\n";} int construct(int n,int r,vector<int> a,vector<int> b,vector<int> x){ bool SubTask1=true,SubTask2=true; for(int i=0;i<r;i++){ if(x[i]==1)SubTask2=false; else SubTask1=false; } if(SubTask1){ string ans=""; for(int i=0;i<n;i++)ans+='R'; craft(ans); return 1; } if(SubTask2){ for(int i=0;i<r;i++)if(a[i]==b[i])return 0; string ans=""; for(int i=0;i<n;i++)ans+=(i%2?'R':'B'); craft(ans); return 1; } if(n<=18&&r<=18){ for(int i=0;i<(1<<n);i++){ string ans=""; for(int j=0;j<n;j++){ if(i&(1<<j))ans+='R'; else ans+='B'; } bool ok=true; for(int i=0;i<r;i++){ map<char,int> was; was.clear(); for(int j=a[i];j<=b[i];j++)was[ans[j]]=1; if((was['R']+was['B'])!=x[i]){ok=false;break;} } cout<<ans<<endl; if(ok){ craft(ans); return 1; } } return 0; } string ans=""; for(int i=0;i<n;i++)ans+='R'; vector<pii> zer,one; for(int i=0;i<r;i++){ if(x[i]==2&&a[i]==b[i])return 0; if(x[i]==1)zer.pb({a[i],b[i]}); else one.pb({a[i],b[i]}); } zer=Compress(zer); one=Compress(one); for(int i=0;i<(int)one.size();i++)ans[one[i].first]='B'; craft(ans); return 1; }

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

gift.cpp: In function 'int construct(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
gift.cpp:37:18: error: call of overloaded 'craft(std::string&)' is ambiguous
   37 |         craft(ans);
      |                  ^
In file included from gift.cpp:1:
gift.h:5:6: note: candidate: 'void craft(std::string&)'
    5 | void craft(std::string &s);
      |      ^~~~~
gift.cpp:27:6: note: candidate: 'void craft(std::string)'
   27 | void craft(string s){cout<<s<<"\n";}
      |      ^~~~~
gift.cpp:44:18: error: call of overloaded 'craft(std::string&)' is ambiguous
   44 |         craft(ans);
      |                  ^
In file included from gift.cpp:1:
gift.h:5:6: note: candidate: 'void craft(std::string&)'
    5 | void craft(std::string &s);
      |      ^~~~~
gift.cpp:27:6: note: candidate: 'void craft(std::string)'
   27 | void craft(string s){cout<<s<<"\n";}
      |      ^~~~~
gift.cpp:63:26: error: call of overloaded 'craft(std::string&)' is ambiguous
   63 |                 craft(ans);
      |                          ^
In file included from gift.cpp:1:
gift.h:5:6: note: candidate: 'void craft(std::string&)'
    5 | void craft(std::string &s);
      |      ^~~~~
gift.cpp:27:6: note: candidate: 'void craft(std::string)'
   27 | void craft(string s){cout<<s<<"\n";}
      |      ^~~~~
gift.cpp:80:14: error: call of overloaded 'craft(std::string&)' is ambiguous
   80 |     craft(ans);
      |              ^
In file included from gift.cpp:1:
gift.h:5:6: note: candidate: 'void craft(std::string&)'
    5 | void craft(std::string &s);
      |      ^~~~~
gift.cpp:27:6: note: candidate: 'void craft(std::string)'
   27 | void craft(string s){cout<<s<<"\n";}
      |      ^~~~~