Submission #25091

# Submission time Handle Problem Language Result Execution time Memory
25091 2017-06-20T06:27:52 Z 서규호(#1053) Palembang Bridges (APIO15_bridge) C++
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

#define lld long long
#define pp pair<int,int>
#define pb push_back
#define MOD 10007
#define left lleft
#define right rright
#define INF 2000000000
#define LINF 1000000000000000000LL
#define next nnext

using namespace std;

int N,K,rear;
lld memo,ans,sum;
lld cnt1,cnt2,cnt3,cnt4;
vector<lld> X;
struct IN{
	int x,y;
}in[100002];
struct data{
	int x,num;
}a[100002],b[100002];

void process1(){
	for(int i=1; i<=N; i++){
		sum += (a[i].x+b[i].x-X[0]-X[0]);
		if(a[i].x > X[0]) cnt2++;
	}
	ans = min(ans,sum);
	int tx,ty;
	tx = ty = 0;
	while(1){
		if(tx == N || a[tx+1].x > X[0]) break;
		tx++;
	}
	for(int i=1; i<X.size(); i++){
		sum += (2*cnt1*(X[i]-X[i-1])); sum -= (2*cnt2*(X[i]-X[i-1]));
		while(1){
			if(tx == N || a[tx+1].x > X[i]) break;
			tx++;
			cnt2--;
		}
		while(1){
			if(ty == N || b[ty+1].x > X[i-1]) break;
			ty++;
			cnt1++; sum += (X[i]-X[i-1])*2;
		}
		ans = min(ans,sum);
	}
}

int main(){
	scanf("%d %d",&K,&N);
	for(int i=1; i<=N; i++){
		int x,y;
		char op1,op2;
		scanf("\n%c %d %c %d",&op1,&x,&op2,&y);
		if(x > y) swap(x,y);
		if(op1 == op2) memo += (y-x);
		else{
			rear++;
			a[rear].x = x; a[rear].num = i;
			b[rear].x = y; b[rear].num = i;
			X.pb(x); X.pb(y);
			memo++;
		}
	}
	N = rear; ans = LINF;
	sort(X.begin(),X.end());
	X.erase(unique(X.begin(),X.end()),X.end());
	sort(a+1,a+N+1,[&](data &x,data &y){
		return x.x < y.x;
	});
	sort(b+1,b+N+1,[&](data &x,data &y){
		return x.x < y.x;
	});
	if(K == 1) process1();
	ans += memo;
	printf("%lld\n",ans);

	return 0;
}

Compilation message

bridge.cpp: In function 'void process1()':
bridge.cpp:38:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=1; i<X.size(); i++){
                ^
bridge.cpp: In function 'int main()':
bridge.cpp:75:2: warning: lambda expressions only available with -std=c++11 or -std=gnu++11
  });
  ^
bridge.cpp:75:3: error: no matching function for call to 'sort(data*, data*, main()::<lambda(data&, data&)>)'
  });
   ^
In file included from /usr/include/c++/5/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:64,
                 from bridge.cpp:1:
/usr/include/c++/5/bits/stl_algo.h:4689:5: note: candidate: template<class _RAIter> void std::sort(_RAIter, _RAIter)
     sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
     ^
/usr/include/c++/5/bits/stl_algo.h:4689:5: note:   template argument deduction/substitution failed:
bridge.cpp:75:3: note:   candidate expects 2 arguments, 3 provided
  });
   ^
In file included from /usr/include/c++/5/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:64,
                 from bridge.cpp:1:
/usr/include/c++/5/bits/stl_algo.h:4718:5: note: candidate: template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare)
     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
     ^
/usr/include/c++/5/bits/stl_algo.h:4718:5: note:   template argument deduction/substitution failed:
bridge.cpp: In substitution of 'template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = data*; _Compare = main()::<lambda(data&, data&)>]':
bridge.cpp:75:3:   required from here
bridge.cpp:75:3: error: template argument for 'template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare)' uses local type 'main()::<lambda(data&, data&)>'
  });
   ^
bridge.cpp:75:3: error:   trying to instantiate 'template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare)'
bridge.cpp:78:2: warning: lambda expressions only available with -std=c++11 or -std=gnu++11
  });
  ^
bridge.cpp:78:3: error: no matching function for call to 'sort(data*, data*, main()::<lambda(data&, data&)>)'
  });
   ^
In file included from /usr/include/c++/5/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:64,
                 from bridge.cpp:1:
/usr/include/c++/5/bits/stl_algo.h:4689:5: note: candidate: template<class _RAIter> void std::sort(_RAIter, _RAIter)
     sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
     ^
/usr/include/c++/5/bits/stl_algo.h:4689:5: note:   template argument deduction/substitution failed:
bridge.cpp:78:3: note:   candidate expects 2 arguments, 3 provided
  });
   ^
In file included from /usr/include/c++/5/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:64,
                 from bridge.cpp:1:
/usr/include/c++/5/bits/stl_algo.h:4718:5: note: candidate: template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare)
     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
     ^
/usr/include/c++/5/bits/stl_algo.h:4718:5: note:   template argument deduction/substitution failed:
bridge.cpp: In substitution of 'template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = data*; _Compare = main()::<lambda(data&, data&)>]':
bridge.cpp:78:3:   required from here
bridge.cpp:78:3: error: template argument for 'template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare)' uses local type 'main()::<lambda(data&, data&)>'
  });
   ^
bridge.cpp:78:3: error:   trying to instantiate 'template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare)'
bridge.cpp:55:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&K,&N);
                      ^
bridge.cpp:59:41: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("\n%c %d %c %d",&op1,&x,&op2,&y);
                                         ^