Task: | Palembang Bridges |
Sender: | Lieska |
Submission time: | 2019-04-04 13:22:05 +0300 |
Language: | C++ |
Status: | COMPILE ERROR |
Compiler report
input/code.cpp:4:58: error: 'll y1' redeclared as different kind of symbol ll k, n, a, b, x, t[100001], r[100001], y, z, p[100001], y1; ^~ In file included from /usr/include/features.h:424:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/os_defines.h:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/c++config.h:533, from /usr/include/c++/7/cassert:43, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:33, from input/code.cpp:1: /usr/include/x86_64-linux-gnu/bits/mathcalls.h:221:1: note: previous declaration 'double y1(double)' __MATHCALL (y1,, (_Mdouble_)); ^ input/code.cpp: In function 'int main()': input/code.cpp:36:12: error: assignment of function 'double y1(double)' y1=1e18; ^~~~ input/code.cpp:36:12: error: cannot convert 'double' to 'double(double) throw ()' in assignment input/code.cpp:52:23: error: ISO C++...
Code
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll k, n, a, b, x, t[100001], r[100001], y, z, p[100001], y1; char c, c1; multiset<ll> s; int main(){ cin >> k >> n; for (int i=1; i<=n; ++i){ cin >> c >> a >> c1 >> b; x+=abs(b-a); if (c!=c1){ if (a>b) swap(a,b); t[i]=a; r[i]=b; p[i]=1; s.insert(a); s.insert(b); y++; x++; } } if (k==1){ a=1; auto it=s.begin(); while (a<=y){ a++; it++; } a=*it; for (int i=1; i<=n; ++i) { if (p[i] && ((a<t[i] && a<r[i]) || (a>t[i]&& a>r[i]))) x+=2*(min(abs(t[i]-a),abs(r[i]-a))); } } if (k==2){ y1=1e18; auto it=s.begin(); while (it!=s.end()){ auto ir=s.find(*it); ir++; while (ir!=s.end()){ z=0; a=*it; b=*ir; for (int i=1; i<=n; ++i) { if (p[i]){ if (a>t[i] && a>r[i]) z+=2*(a-r[i]); else if (b<t[i] && b<r[i]) z+=2*(t[i]-b); else if (a<t[i] && a<r[i] && b>t[i] && b>r[i]) z+=2*(min(t[i]-a, b-r[i])); } } if (z<y1) y1=z; ir++; } it++; } } cout << x+y1; }