QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#576027#6786. Let's ChaticedCompile Error//C++232.0kb2024-09-19 18:00:142024-09-19 18:00:19

Judging History

你现在查看的是最新测评结果

  • [2024-09-19 18:00:19]
  • 评测
  • [2024-09-19 18:00:14]
  • 提交

answer

#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<bitset>
#include<iomanip>
#include<tuple>
#include<numeric>



#define ll long long
#define inf 0x3f3f3f3f
#define lc p<<1
#define rc p<<1|1
#define endl '\n'
#define all(a) a.begin()+1,a.end()
#define all0(a) a.begin(),a.end()
#define lowbit(a) (a&-a)
#define pb push_back
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl

using namespace std;
const double eps=1e-6;
typedef pair<int,int>PII;

void solve()
{
	int n,m,x,y;
	cin>>n>>m>>x>>y;
	vector<PII>a(x+1);
	vector<PII>b(y+1);
	
	for(int i=1;i<=x;i++) cin>>a[i].first>>a[i].second;
	for(int i=1;i<=y;i++) cin>>b[i].first>>b[i].second;
	vector<int>f;
	for(int i=1;i<=x;i++)
	{
		int l=a[i].first;
		int r=a[i].second;
		f.pb(l);
		f.pb(r);
		f.pb(r+1);
	}
	
	for(int i=1;i<=y;i++)
	{
		int l=b[i].first;
		int r=b[i].second;
		f.pb(l);
		f.pb(r);
		f.pb(r+1);
	}
	
	
	sort(all0(f));
	f.erase(unique(all0(f)),f.end());
	int len=f.size();
	vector<int> cnt(len);
	
	for(int i=1;i<=x;i++)
	{
		int l=a[i].first;
		int r=a[i].second;
		int k=lower_bound(all0(f),l)-f.begin();
		cnt[k]++;
		k=lower_bound(all0(f),r)-f.begin();
		cnt[k+1]--;
	}
	
	for(int i=1;i<=y;i++)
	{
		int l=b[i].first;
		int r=b[i].second;
		int k=lower_bound(all0(f),l)-f.begin();
		cnt[k]++;
		k=lower_bound(all0(f),r)-f.begin();
		cnt[k+1]--;
	}
	
	int ans=0;
	for(int i=1;i<len;i++)  cnt[i]+=cnt[i-1];
	
	//for(int i=0;i<len;i++) cout<<cnt[i]<<' ';
	//cout<<endl;
	
	for(int i= 0;i<len;i++ )
	{
		if(cnt[i]==2)
		{
			int j=i+1;
			while( j<len && cnt[j]==2) j++;
			if(j>i) 
			{
				ans+= max(0,f[j-1]-f[i]+2-m);
				//cout<<f[i]<<' '<<f[j-1]<<' ';
				//cout<<ans<<endl;
			}
			// cout<<f[i]<<' '<<f[j]<<endl;
			i=j;
		}
	}
	
	cout<<ans<<endl;
	
}
	
	
int main()
{
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	i

详细

answer.code: In function ‘int main()’:
answer.code:119:9: error: ‘i’ was not declared in this scope
  119 |         i
      |         ^
answer.code:119:10: error: expected ‘}’ at end of input
  119 |         i
      |          ^
answer.code:117:1: note: to match this ‘{’
  117 | {
      | ^