682021-01-09 22:36:13Babják PéterRobotokcpp11Forditási hiba
#include <iostream>
#include <algorithm>
using namespace std;
struct d
{
	int f,s;	
};
struct cmp
{
	bool operator()(const d &a, const d &b)
	{
		if(a.s==b.s)
		{
			return a.f<b.f;
		}
		return a.s<b.s;
	}	
};
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int n,m,k;
    cin>>n>>m>>k;
    d r[k];
    for(int i=0;i<k;i++)
    {
    	cin>>r[i].f>>r[i].s;
	}
	sort(r,r+k,cmp());
	vector<int>ans;
	ans.push_back(r[0].f);
	for(int i=1;i<k;i++)
	{
		vector<int>::iterator up;
		up=upper_bound(ans.begin(),ans.end(),r[i].f,greater<int>());
		int z=up-ans.begin();
		if(ans[z-1]==r[i].f)
		{
			continue;		
		}
		if(up==ans.end())
		{
			ans.push_back(r[i].f);
		}
		else
		{
			ans[z]=r[i].f;
		}
	}
	cout<<ans.size()<<endl;
    return 0;
}
Forditási hiba
exit status 1main.cpp: In function ‘int main()’:
main.cpp:30:2: error: ‘vector’ was not declared in this scope
   30 |  vector<int>ans;
      |  ^~~~~~
main.cpp:3:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
    2 | #include <algorithm>
  +++ |+#include <vector>
    3 | using namespace std;
main.cpp:30:9: error: expected primary-expression before ‘int’
   30 |  vector<int>ans;
      |         ^~~
main.cpp:31:2: error: ‘ans’ was not declared in this scope; did you mean ‘abs’?
   31 |  ans.push_back(r[0].f);
      |  ^~~
      |  abs
main.cpp:34:10: error: expected primary-expression before ‘int’
   34 |   vector<int>::iterator up;
      |          ^~~
main.cpp:35:3: error: ‘up’ was not declared in this scope
   35 |   up=upper_bound(ans.begin(),ans.end(),r[i].f,greater<int>());
      |   ^~
Exited with error status 1