QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#120254#6136. Airdropchenxinyang2006Compile Error//C++142.6kb2023-07-06 15:51:002023-07-06 15:51:02

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-06 15:51:02]
  • 评测
  • [2023-07-06 15:51:00]
  • 提交

answer

#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(j);i<=(k);i++)
#define per(i,j,k) for(int i=(j);i>=(k);i--)
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define db double
#define ldb long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define eb emplace_back
#define SZ(S) (int)S.size()
//#define mod 998244353
//#define mod 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3f
using namespace std;

template <class T>
void chkmax(T &x,T y){
	if(x < y) x = y;
}

template <class T>
void chkmin(T &x,T y){
	if(x > y) x = y;
}

inline int popcnt(int x){
	return __builtin_popcount(x);
}

inline int ctz(int x){
	return __builtin_ctz(x);
}


/*ll power(ll p,int k = mod - 2){
	ll ans = 1;
	while(k){
		if(k % 2 == 1) ans = ans * p % mod;
		p = p * p % mod;
		k /= 2;	
	}
	return ans;
}*/
int T,n,y0;
pii P[100005];
int buc[200005],res[2][100005];

#define mx 100000
void solve(){
	scanf("%d%d",&n,&y0);
	rep(i,1,n){
		int x,y;
		scanf("%d%d",&x,&y);
		P[i] = mkp(x,abs(y - y0));
	}
	sort(P + 1,P + n + 1);
	fill(res[0],res[0] + n + 2,0);
	fill(res[1],res[1] + n + 2,0);
	int cur = 0,pos;
	for(int l = 1,r;l <= n;l = r + 1){
		r = l;
		while(r < n && P[r + 1].first == P[r].first) r++;

		rep(i,l,r){
			pos = mx - P[i].first + P[i].second;
			if(i != r && P[i].second == P[i + 1].second){
				cur -= buc[pos];
				buc[pos] = 0;
				i++;
				continue;
			}
			cur -= buc[pos];
			buc[pos] ^= 1;
			cur += buc[pos];
		}
		res[0][r] = cur;
	}
	rep(i,1,n) buc[mx - P[i].first + P[i].second] = 0;

	cur = 0;
	for(int r = n,l;r;r = l - 1){
		l = r;
		while(l > 1 && P[l - 1].first == P[l].first) l--;

		rep(i,l,r){
			pos = P[i].first + P[i].second;
			if(i != r && P[i].second == P[i + 1].second){
				cur -= buc[pos];
				buc[pos] = 0;
				i++;
				continue;
			}
			cur -= buc[pos];
			buc[pos] ^= 1;
			cur += buc[pos];
		}
		res[1][l] = cur;
	}
	rep(i,1,n) buc[P[i].first + P[i].second] = 0;

	int Mn = inf,Mx = 0;
	for(int l = 1,r;l <= n;l = r + 1){
		r = l;
		while(r < n && P[r].first == P[r + 1].first) r++;
		chkmin(Mn,r - l + 1 + res[0][l - 1] + res[1][r + 1]);
		chkmax(Mx,r - l + 1 + res[0][l - 1] + res[1][r + 1]);
	}
	P[n + 1] = mkp(inf,0);P[0] = mkp(-inf,0);
	rep(i,0,n){
		if(P[i + 1].first > P[i].first + 1){
			chkmin(Mn,res[0][i] + res[1][i + 1]);
			chkmax(Mx,res[0][i] + res[1][i + 1]);
		}
	}
	printf("%d %d\n",Mn,Mx);
}

int main(){
//	freopen("test.in","r",stdin);
	scanf("%d",&T);
	while(T--) solve();
	return 0;
}

詳細信息

answer.code:48:9: error: ‘int y0’ redeclared as different kind of entity
   48 | int T,n,y0;
      |         ^~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/c++config.h:571,
                 from /usr/include/c++/11/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:33,
                 from answer.code:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:220:1: note: previous declaration ‘double y0(double)’
  220 | __MATHCALL (y0,, (_Mdouble_));
      | ^~~~~~~~~~
answer.code: In function ‘void solve()’:
answer.code:54:19: warning: format ‘%d’ expects argument of type ‘int*’, but argument 3 has type ‘double (*)(double) throw ()’ {aka ‘double (*)(double)’} [-Wformat=]
   54 |         scanf("%d%d",&n,&y0);
      |                  ~^     ~~~
      |                   |     |
      |                   int*  double (*)(double) throw () {aka double (*)(double)}
answer.code:58:36: error: invalid operands of types ‘int’ and ‘double(double) throw ()’ {aka ‘double(double)’} to binary ‘operator-’
   58 |                 P[i] = mkp(x,abs(y - y0));
      |                                  ~ ^ ~~
      |                                  |   |
      |                                  int double(double) throw () {aka double(double)}
answer.code:54:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   54 |         scanf("%d%d",&n,&y0);
      |         ~~~~~^~~~~~~~~~~~~~~
answer.code:57:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   57 |                 scanf("%d%d",&x,&y);
      |                 ~~~~~^~~~~~~~~~~~~~
answer.code: In function ‘int main()’:
answer.code:124:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  124 |         scanf("%d",&T);
      |         ~~~~~^~~~~~~~~