답안 #516777

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
516777 2022-01-22T06:10:54 Z Koosha_mv Bitaro, who Leaps through Time (JOI19_timeleap) C++14
0 / 100
3000 ms 76040 KB
#include <bits/stdc++.h>
using namespace std;
#define dbgv(v) cout<<#v<<" = "; f(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define dbga(a,x,y) cout<<#a<<" = "; f(i,x,y) cout<<a[i]<<" "; cout<<endl
#define erorp(x) cout<<#x<<"={"<<(x.F)<<" , "<<x.S<<"}"<<endl
#define eror(x) cout<<#x<<'='<<(x)<<endl
#define f_(i,a,b) for(int i=a;i>=b;i--)
#define f(i,a,b) for(int i=a;i<b;i++)
#define nb(x) __builtin_popcount(x)
#define all(v) v.begin(),v.end()
#define bit(n,k) (((n)>>(k))&1)
#define Add(x,y) x=(x+y)%mod
#define maxm(a,b) a=max(a,b)
#define minm(a,b) a=min(a,b)
#define lst(x) x[x.size()-1]
#define sz(x) int(x.size())
#define mp make_pair
#define ll long long
#define pb push_back
#define S second
#define F first
#define int ll

const int N=3e5+99;

int n,q,a[N],b[N],c[N],d[N],T[N],Ans[N];
vector<int> Q[N];

struct node{
	int ans,mx,mn;
	node(){
		ans=mx=mn=0;
	}	
} seg[N<<2];

void make(int x){
	if(x==0){
		f(i,0,n){
			a[i]=c[i]+n-i;
			b[i]=d[i]+n-i;
		}
	}
	else{
		f(i,0,n){
			a[i]=c[n-i-1]+n-i;
			b[i]=d[n-i-1]+n-i;
		}
		f(i,0,q){
			if(T[i]==1){
				Q[i][0]=n-Q[i][0];
			}
			else{
				Q[i][0]=n-Q[i][0];
				Q[i][2]=n-Q[i][2];
			}
		}
	}
}
void solve(){
	f(i,0,q){
		int t,x,l,r;
		if(T[i]==1){
			x=Q[i][0],l=Q[i][1],r=Q[i][2];
			a[x]=l+n-x;
			b[x]=r+n-x;
		}
		else{
			int s,e,t,p,ans=0;
			s=Q[i][0],e=Q[i][1],t=Q[i][2],p=Q[i][3];
			//cout<<s<<" "<<e<<" "<<t<<" "<<p<<endl;
			if(s<=t){
				//eror("do");
				int b1=e+n-s,b2=p+n-t;
				f(i,s,t){
					f(j,i+1,t){
						maxm(ans,a[i]-b[j]);
					}
				}
				f(i,s,t){
					//cout<<a[i]<<" "<<b[i]<<endl;
					maxm(ans,b1-b[i]);
					maxm(ans,a[i]-b2);
				}
				maxm(ans,b1-b2);
			}
			maxm(Ans[i],ans);
		}
	}
}

main(){
	cin>>n>>q; n--;
	f(i,0,n){
		cin>>c[i]>>d[i];
		d[i]--;
	}	
	f(i,0,q){
		int t,x,l,r;
		cin>>T[i];
		if(T[i]==1){
			cin>>x>>l>>r;
			x--; r--;
			Q[i].pb(x);
			Q[i].pb(l);
			Q[i].pb(r);
		}
		else{
			int s,e,t,p,ans=0;
			cin>>s>>e>>t>>p;
			s--,t--;
			Q[i].pb(s);
			Q[i].pb(e);
			Q[i].pb(t);
			Q[i].pb(p);
		}
	}
	make(0);
	solve();
	make(1);
	solve();
	f(i,0,q){
		if(T[i]==2){
			cout<<Ans[i]<<'\n';
		}
	}
}

Compilation message

timeleap.cpp: In function 'void solve()':
timeleap.cpp:61:7: warning: unused variable 't' [-Wunused-variable]
   61 |   int t,x,l,r;
      |       ^
timeleap.cpp: At global scope:
timeleap.cpp:91:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   91 | main(){
      | ^~~~
timeleap.cpp: In function 'int main()':
timeleap.cpp:108:16: warning: unused variable 'ans' [-Wunused-variable]
  108 |    int s,e,t,p,ans=0;
      |                ^~~
timeleap.cpp:98:7: warning: unused variable 't' [-Wunused-variable]
   98 |   int t,x,l,r;
      |       ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 16 ms 35656 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3073 ms 76040 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 16 ms 35656 KB Output isn't correct
2 Halted 0 ms 0 KB -