Submission #1109624

#TimeUsernameProblemLanguageResultExecution timeMemory
1109624simona1230Palembang Bridges (APIO15_bridge)C++17
0 / 100
1 ms2552 KiB
#include <bits/stdc++.h> using namespace std; int k,n,num; pair<int,int> p[200001]; int other,curr; int l[200001],r[200001]; vector<pair<int,int> > v; int c=0; void read() { cin>>k>>n; for(int i=1;i<=n;i++) { char c1,c2; int s,f; cin>>c1>>s>>c2>>f; if(c1!=c2) { if(s>f)swap(s,f); curr+=s+f+3; v.push_back({s,1}); v.push_back({f,2}); } else { other+=max(s,f)-min(s,f); } } sort(v.begin(),v.end()); for(int i=0;i<v.size();i++) { if(i==0||v[i].first!=v[i-1].first)c++; if(v[i].second==1)l[c]++; else r[c]++; } } void solve() { int cntl=0,cntr=n; for(int i=1;i<=c;i++) { cntr-=l[i]; cntl+=r[i]; curr+=(cntl-cntr)*2; cout<<l[i]<<" "<<r[i]<<" "<<curr+other<<" "<<cntl<<" "<<cntr<<endl; } } int main() { read(); solve(); return 0; } /* 1 5 B 0 A 4 B 1 B 3 A 5 B 7 B 2 A 6 B 1 A 7 */

Compilation message (stderr)

bridge.cpp: In function 'void read()':
bridge.cpp:34:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     for(int i=0;i<v.size();i++)
      |                 ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...