QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#21804#2832. Graph TheoryCCPSDCGK#Compile Error//C++202.4kb2022-03-08 15:55:382022-05-18 04:12:08

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-18 04:12:08]
  • 评测
  • [2022-03-08 15:55:38]
  • 提交

answer

#include<map>
#include<set>
#include<queue>
#include<deque>
#include<cmath>
#include<ctime>
#include<bitset>
#include<vector>
#include<cstdio>
#include<string>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
#define mkp make_pair
#define lb lower_bound
#define ub upper_bound
#define eb emplace_back
#define fs fflush(stdout)
#define ump unordered_map
#define pq priority_queue
#define clz __builtin_clz
#define ctz __builtin_ctz
#define space putchar(' ')
#define enter putchar('\n')
#define sz(x) (int)x.size()
#define np next_permutation
#define clzl __builtin_clzll
#define par __builtin_parity
#define ctzl __builtin_ctzll
#define ppc __builtin_popcount
#define parl __builtin_parityll
#define all(x) x.begin(),x.end()
#define ppcl __builtin_popcountll
#define ms(x,y) memset(x,y,sizeof(x))
#define debug(x) cerr<<#x<<"= "<<(x)<<'\n'
template<class T> inline T &read(T &x){
	x=0;int f=1;char ch=getchar();
	while(ch<48||ch>57){if(ch=='-') f=-f;ch=getchar();}
	while(ch>=48&&ch<=57) x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return x*=f;
}
template<class T> inline void print(T x){
	static char buf[40];static int cnt=0;
	if(x<0) putchar(45),x=-x;
	do buf[++cnt]=x%10^48;while(x/=10);
	do putchar(buf[cnt--]);while(cnt);
}
#define mod 998244353
#define inf 0x3f3f3f3f
#define fpi freopen("","r",stdin)
#define fpo freopen("","w",stdout)
pair<int,int> p[200005];
int sum[200005];
inline void add(int l,int r){if(l>r) sum[1]++;sum[l]++,sum[r]--;}
bool check(int x,int n){
	int i;
	for(i=1;i<=m;i++){
		if(p[i].second-p[i].first>x) add(p[i].second,p[i].first);
		if(n+p[i].first-p[i].second>x) add(p[i].first,p[i].second);
	}
	for(i=2;i<=n;i++) sum[i]+=sum[i-1];
	for(i=1;i<=n;i++) if(!sum[i]) return 1;return 0;
}
void solve(int n,int m){
	int l=0,r=n,ans,i;
	for(i=1;i<=n;i++) sum[i]=0; 
	for(i=1;i<=m;i++){
		read(p[i].first),read(p[i].second);
		if(p[i].first>p[i].second) p[i].first^=p[i].second^=p[i].first^=p[i].second;
		l=max(l,min(p[i].second-p[i].first,n+p[i].first-p[i].second));
	}
	while(l<=r){
		int mid=l+r>>1;
		if(check(mid,n)) ans=mid,r=mid-1;else l=mid+1;
	}print(ans),enter;
}
int main(){
	int n,m;
	while(cin>>n>>m) solve(n,m);
	return 0;
}

Details

answer.code: In function ‘bool check(int, int)’:
answer.code:64:20: error: ‘m’ was not declared in this scope
   64 |         for(i=1;i<=m;i++){
      |                    ^