Submission #375528

#TimeUsernameProblemLanguageResultExecution timeMemory
375528MilosMilutinovicHandcrafted Gift (IOI20_gift)C++14
Compilation error
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; } int construct(int n,int r,vector<int> a,vector<int> b,vector<int> x){ 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; } int main(){ int n,q;scanf("%i%i",&n,&q); vector<int> a(q),b(q),x(q); for(int i=0;i<q;i++)scanf("%i%i%i",&a[i],&b[i],&x[i]); printf("%i\n",construct(n,q,a,b,x)); }

Compilation message (stderr)

gift.cpp: In function 'int main()':
gift.cpp:43:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   43 |     int n,q;scanf("%i%i",&n,&q);
      |             ~~~~~^~~~~~~~~~~~~~
gift.cpp:45:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   45 |     for(int i=0;i<q;i++)scanf("%i%i%i",&a[i],&b[i],&x[i]);
      |                         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/ccoGMTm9.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccr5NLb3.o:gift.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status