QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#274994#7626. Quake and Rebuildship2077Compile Error//C++146.0kb2023-12-04 10:13:022024-11-20 20:29:12

Judging History

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

  • [2024-11-20 20:29:12]
  • 自动重测本题所有获得100分的提交记录
  • [2024-11-20 20:27:49]
  • hack成功,自动添加数据
  • (/hack/1219)
  • [2023-12-04 10:13:02]
  • 评测
  • 测评结果:100
  • 用时:1732ms
  • 内存:14876kb
  • [2023-12-04 10:13:02]
  • 提交

answer

#if defined(ONLINE_JUDGE)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt")
#endif
#if defined(LOCAL) or not defined(LUOGU)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast,unroll-loops")
#endif
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include"dbg.h"
#else
#define dbg(...) (__VA_ARGS__)
#endif
namespace Fread{const int SIZE=1<<16;char buf[SIZE],*S,*T;inline char getchar(){if(S==T){T=(S=buf)+fread(buf,1,SIZE,stdin);if(S==T)return'\n';}return *S++;}}namespace Fwrite{const int SIZE=1<<16;char buf[SIZE],*S=buf,*T=buf+SIZE;inline void flush(){fwrite(buf,1,S-buf,stdout);S=buf;}inline void putchar(char c){*S++=c;if(S==T)flush();}struct NTR{~NTR(){flush();}}ztr;}
#define getchar Fread::getchar
#define putchar Fwrite::putchar
#define Setprecision 10
#define between '\n'
template<typename T>struct is_char{static constexpr bool value=(std::is_same<T,char>::value||std::is_same<T,signed char>::value||std::is_same<T,unsigned char>::value);};template<typename T>struct is_integral_ex{static constexpr bool value=(std::is_integral<T>::value||std::is_same<T,__int128>::value)&&!is_char<T>::value;};template<typename T>struct is_floating_point_ex{static constexpr bool value=std::is_floating_point<T>::value||std::is_same<T,__float128>::value;};namespace Fastio{struct Reader{template<typename T>typename std::enable_if_t<std::is_class<T>::value,Reader&>operator>>(T&x){for(auto &y:x)*this>>y;return *this;}template<typename T>typename std::enable_if_t<is_integral_ex<T>::value,Reader&>operator>>(T&x){char c=getchar();short f=1;while(c<'0'||c>'9'){if(c=='-')f*=-1;c=getchar();}x=0;while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+(c^48);c=getchar();}x*=f;return *this;}template<typename T>typename std::enable_if_t<is_floating_point_ex<T>::value,Reader&>operator>>(T&x){char c=getchar();short f=1,s=0;x=0;T t=0;while((c<'0'||c>'9')&&c!='.'){if(c=='-')f*=-1;c=getchar();}while(c>='0'&&c<='9'&&c!='.')x=x*10+(c^48),c=getchar();if(c=='.')c=getchar();else return x*=f,*this;while(c>='0'&&c<='9')t=t*10+(c^48),s++,c=getchar();while(s--)t/=10.0;x=(x+t)*f;return*this;}template<typename T>typename std::enable_if_t<is_char<T>::value,Reader&>operator>>(T&c){c=getchar();while(c=='\n'||c==' '||c=='\r')c=getchar();return *this;}Reader&operator>>(char*str){int len=0;char c=getchar();while(c=='\n'||c==' '||c=='\r')c=getchar();while(c!='\n'&&c!=' '&&c!='\r')str[len++]=c,c=getchar();str[len]='\0';return*this;}Reader&operator>>(std::string&str){str.clear();char c=getchar();while(c=='\n'||c==' '||c=='\r')c=getchar();while(c!='\n'&&c!=' '&&c!='\r')str.push_back(c),c=getchar();return*this;}Reader(){}}cin;const char endl='\n';struct Writer{typedef __int128 mxdouble;template<typename T>typename std::enable_if_t<std::is_class<T>::value,Writer&>operator<<(T x){for(auto &y:x)*this<<y<<between;*this<<'\n';return *this;}template<typename T>typename std::enable_if_t<is_integral_ex<T>::value,Writer&>operator<<(T x){if(x==0)return putchar('0'),*this;if(x<0)putchar('-'),x=-x;static int sta[45];int top=0;while(x)sta[++top]=x%10,x/=10;while(top)putchar(sta[top]+'0'),--top;return*this;}template<typename T>typename std::enable_if_t<is_floating_point_ex<T>::value,Writer&>operator<<(T x){if(x<0)putchar('-'),x=-x;mxdouble _=x;x-=(T)_;static int sta[45];int top=0;while(_)sta[++top]=_%10,_/=10;if(!top)putchar('0');while(top)putchar(sta[top]+'0'),--top;putchar('.');for(int i=0;i<Setprecision;i++)x*=10;_=x;while(_)sta[++top]=_%10,_/=10;for(int i=0;i<Setprecision-top;i++)putchar('0');while(top)putchar(sta[top]+'0'),--top;return*this;}template<typename T>typename std::enable_if_t<is_char<T>::value,Writer&>operator<<(T c){putchar(c);return*this;}Writer&operator<<(char*str){int cur=0;while(str[cur])putchar(str[cur++]);return *this;}Writer&operator<<(const char*str){int cur=0;while(str[cur])putchar(str[cur++]);return*this;}Writer&operator<<(std::string str){int st=0,ed=str.size();while(st<ed)putchar(str[st++]);return*this;}Writer(){}}cout;}
#define cin Fastio::cin
#define cout Fastio::cout
#define endl Fastio::endl
#define fi first
#define se second
constexpr int M=2e5+5; bool flag[M],vis[M],cur[M];
int n,m,x,y,z,op,mn,ans,tp,block,bel[M];vector<int>node[M];
int L[M],R[M],fa[M],jump[M],dep[M],lazy[M];
void rebuild(int x){ flag[x]=1;
	for (int i=L[x];i<=R[x];i++) fa[i]=max(fa[i]-lazy[x],1);
	for (int i=L[x];i<=R[x];i++)
		if (fa[i]<L[x]) jump[i]=fa[i],dep[i]=1;
		else jump[i]=jump[fa[i]],dep[i]=dep[fa[i]]+1,flag[x]=0;
	lazy[x]=0;
}
void upd1(int l,int r,int c){
	for (int i=l;i<=r;i++) fa[i]=max(fa[i]-c,1);
	rebuild(bel[l]);
}
void upd2(int l,int r,int c){
	for (int i=l+1;i<r;i++){lazy[i]+=c;
		if (lazy[i]>R[i]) lazy[i]=R[i];
		if (!flag[i]) rebuild(i);
	}
}
void update(int l,int r,int c){
	if (bel[l]==bel[r]) return upd1(l,r,c),void();
	upd1(l,R[bel[l]],c);upd2(bel[l],bel[r],c);upd1(L[bel[r]],r,c);
}
int Jump(int x){return max(1,jump[x]-lazy[bel[x]]);}
void insert(int x){
	if (vis[x]) return ;
	node[bel[x]].push_back(x);
	vis[x]=1;mn=min(mn,x);
}
void build(int k){ ans=1;mn=n;
	while (k--) cin>>x,insert(x);
	for (int i=bel[n];i;i--)
		if (!node[i].empty()){ bool fl=0;
			for (auto x:node[i]){
				const int tmp=Jump(x);
				fl|=vis[tmp]||cur[tmp];cur[tmp]=1;
			}
			for (auto x:node[i]) cur[x]=0;
			if (!fl){
				if (node[i].size()==1&&node[i][0]==mn) break;
				for (auto x:node[i]){
					const int tmp=Jump(x);
					ans+=dep[x];insert(tmp);
				}
				continue;
			}
			for (int j=R[i];j>=L[i];j--)
				if (vis[j]){
					if (j==mn) break; ans++;
					insert(max(1,fa[j]-lazy[bel[j]]));
				}
		}
	for (int i=0;i<=bel[n];i++){
		for (auto x:node[i]) vis[x]=0;
		node[i].clear();
	}
	cout<<ans<<endl;
}
int main(){ cin>>n>>m;
	for (int i=2;i<=n;i++) cin>>fa[i];
	block=max(2,(int)ceil(sqrt(n)));
	for (int i=1;i<=n;i++) bel[i]=(i-1)/block+1;
	for (int i=1;i<=bel[n];i++) L[i]=R[i-1]+1,R[i]=R[i-1]+block;
	L[1]=2;R[bel[n]]=n;
	for (int i=1;i<=bel[n];i++) rebuild(i);
	while (m--){ cin>>op>>x;
		if (op==1) cin>>y>>z,update(x,y,z);
		if (op==2) build(x);
	}
	return 0;
}

详细

In file included from /usr/include/c++/13/string:43,
                 from /usr/include/c++/13/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52,
                 from answer.code:8:
/usr/include/c++/13/bits/allocator.h: In destructor ‘std::_Vector_base<int, std::allocator<int> >::_Vector_impl::~_Vector_impl()’:
/usr/include/c++/13/bits/allocator.h:184:7: error: inlining failed in call to ‘always_inline’ ‘std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = int]’: target specific option mismatch
  184 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/13/vector:66,
                 from /usr/include/c++/13/queue:63,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:157:
/usr/include/c++/13/bits/stl_vector.h:133:14: note: called from here
  133 |       struct _Vector_impl
      |              ^~~~~~~~~~~~