QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#238299#7517. Flying Ship Storyfzj2007Compile Error//C++172.1kb2023-11-04 16:20:122023-11-04 16:20:12

Judging History

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

  • [2023-11-04 16:20:12]
  • 评测
  • [2023-11-04 16:20:12]
  • 提交

answer

#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
template<typename T>inline void read(T &x){
    x=0;
    char ch=getchar();
    bool flag=0;
    while(ch>'9'||ch<'0') flag=flag||ch=='-',ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    x=flag?-x:x;
}
template<typename T,typename ...Args>inline void read(T &x,Args &...args){
    read(x),read(args...);
}
template<typename T>inline void prt(T x){
    if(x>9) prt(x/10);
    putchar(x%10+'0');
}
template<typename T>inline void put(T x){
    if(x<0) putchar('-'),x=-x;
    prt(x);
}
template<typename T>inline void put(char ch,T x){
    put(x),putchar(ch);
}
template<typename T,typename ...Args>inline void put(char ch,T x,Args ...args){
    put(ch,x),put(ch,args...);
}
#define N 15
int q,n;
struct node{
	int x,y,w;
	inline bool operator<(const node &b)const{
		return w>b.w;
	}
}t[N],p[N];
inline void modify(){
	for(int i=1;i<=n;i++)
		for(int j=n;j>i;j--)
			if(t[j]<t[j-1]) swap(t[j],t[j-1]);
	for(int i=1;i<n;i++) assert(t[j]<t[j+1]);
	int state=0,x=0,y=0,u=0,v=0,m=0;
	for(int i=1;i<=n;i++){
		if(!state) state=1,x=t[i].x,y=t[i].y,p[++m]=t[i];
		else if(state==1){
			if(t[i].x==x&&t[i].y==y) continue;
			if(t[i].x==x) state=2;
			else if(t[i].y==y) state=3;
			else state=4,u=x,v=t[i].y,x=t[i].x;
			p[++m]=t[i];
		}else if(state==2){
			if(t[i].x!=x) state=5,y=t[i].y,p[++m]=t[i];
		}else if(state==3){
			if(t[i].y!=y) state=5,x=t[i].x,p[++m]=t[i];
		}else if(state==4){
			int a=t[i].x!=x&&t[i].y!=y,b=t[i].x!=u&&t[i].y!=v;
			if(!a&&!b) continue;
			if(a&&b) state=6;
			else if(a) state=5,x=u,y=v;
			else if(b) state=5;
			p[++m]=t[i];
		}else if(state==5){
			if(t[i].x!=x&&t[i].y!=y) p[++m]=t[i],state=6;
		}
	}
	n=m;
	for(int i=1;i<=n;i++) t[i]=p[i];
}
int main(){
	read(q);
	for(int T=1,x,y,w,op,ans=0;T<=q;T++){
		read(op,x,y),x^=ans,y^=ans;
		if(op==1){
			read(w),w^=ans;
			t[++n]=(node){x,y,w};
			modify();
		}else{
			ans=0;
			for(int i=1;i<=n;i++){
				if(t[i].x!=x&&t[i].y!=y){
					ans=t[i].w;
					break;
				}
			}
			if(!flag) put('\n',ans);
		}
	}
	return 0;
}

詳細信息

In file included from /usr/include/c++/11/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:33,
                 from answer.code:1:
answer.code: In function ‘void modify()’:
answer.code:41:39: error: ‘j’ was not declared in this scope
   41 |         for(int i=1;i<n;i++) assert(t[j]<t[j+1]);
      |                                       ^
answer.code: In function ‘int main()’:
answer.code:85:29: error: ‘flag’ was not declared in this scope
   85 |                         if(!flag) put('\n',ans);
      |                             ^~~~