QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#882273#8302. Incoming Asteroidssz051Compile Error//C++202.3kb2025-02-04 23:00:172025-02-04 23:00:19

Judging History

This is the latest submission verdict.

  • [2025-02-04 23:00:19]
  • Judged
  • [2025-02-04 23:00:17]
  • Submitted

answer

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <cassert>
#include <stack>
#include <random>
#include <map>
#define int long long
using namespace std; 

void read(int &x){
	x=0;
	int f=1;
	char c=getchar();
	while(!('0'<=c && c<='9')){
		if(c=='-'){
			f=-1;
		}
		c=getchar();
	}
	while('0'<=c && c<='9'){
		x=(x<<3)+(x<<1)+(c^48);
		c=getchar();
	}
	x*=f;
}
int lg(int k){
	return k==0?-1:__lg(k);
}
typedef vector<int> Array;
namespace Alarm{
	int qlim[200010],qh[200010],delt[200010],qcnt=0;
	vector<int> qp[200010];
	vector<int> seps[200010][42];
	int sum[200010];
	Alarm(){}
	int insert(vector<int> pos,int lim){
		//<P7603 only>
		for(int i:pos){
			lim+=sum[i];
		}
		//</>
		qlim[++qcnt]=lim;
		qp[qcnt]=pos;
		qh[qcnt]=40;
		while(qh[qcnt]>=0){
			int cur=0;
			for(int i:pos){
				cur+=sum[i]|((1ll<<qh[qcnt])-1);
			}
			if(cur>=lim){
				qh[qcnt]--;
			}else{
				break;
			}
		}
		for(int i:pos){
			seps[i][qh[qcnt]+1].push_back(qcnt);
		}
		return qcnt;
	}
	vector<int> update(int k,int v){
		vector<int> res;
		int tp=lg(sum[k]^(sum[k]+v));
		sum[k]+=v;
		for(int p=-1;p<=tp;p++){
			vector<int> tmp=seps[k][p+1];
			seps[k][p+1].clear();
			for(int i:tmp){
				//printf("[%lld %lld %lld]",k,p,i);
				if(qh[i]!=p){
					continue;
				}
				while(qh[i]>=0){
					int cur=0;
					for(int j:qp[i]){
						cur+=sum[j]|((1ll<<qh[i])-1);
					}
					if(cur>=qlim[i]){
						qh[i]--;
					}else{
						break;
					}
				}
				if(qh[i]==-1){
					res.push_back(i);	
				}else{
					if(qh[i]==p){
						seps[k][p+1].push_back(i);
					}else{
						for(int j:qp[i]){
							seps[j][qh[i]+1].push_back(i);
						}
					}
				}
			}
		}
		return res;
	}
}
int n,m;
signed main(){
	read(n);
	read(m);
	int opt,x,y;
	while(m--){
		read(opt);
		if(opt==1){
			read(x);
			read(y);
			Array cur(y,0);
			for(int i=0;i<y;i++){
				read(cur[i]);
			}
			Alarm::insert(cur,x);
		}else{
			read(x);
			read(y);
			Array cur=Alarm::update(x,y);
			sort(cur.begin(),cur.end());
			printf("%d%c",cur.size(),cur.size()?' ':'\n');
			for(int i=0;i<cur.size();i++){
				printf("%d%c",cur[i],i==cur.size()-1?'\n':' ');
			}
		}
	}
	return 0;
}

詳細信息

answer.code:38:9: error: ISO C++ forbids declaration of ‘Alarm’ with no type [-fpermissive]
   38 |         Alarm(){}
      |         ^~~~~
answer.code: In function ‘int Alarm::Alarm()’:
answer.code:38:17: warning: no return statement in function returning non-void [-Wreturn-type]
   38 |         Alarm(){}
      |                 ^
answer.code: In function ‘int main()’:
answer.code:123:34: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘std::vector<long long int>::size_type’ {aka ‘long unsigned int’} [-Wformat=]
  123 |                         printf("%d%c",cur.size(),cur.size()?' ':'\n');
      |                                 ~^    ~~~~~~~~~~
      |                                  |            |
      |                                  int          std::vector<long long int>::size_type {aka long unsigned int}
      |                                 %ld
answer.code:125:42: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type’ {aka ‘long long int’} [-Wformat=]
  125 |                                 printf("%d%c",cur[i],i==cur.size()-1?'\n':' ');
      |                                         ~^
      |                                          |
      |                                          int
      |                                         %lld