제출 #1159163

#제출 시각아이디문제언어결과실행 시간메모리
1159163yf_yusufSpring cleaning (CEOI20_cleaning)C++20
컴파일 에러
0 ms0 KiB
#include "arithmetics.h"
//```//    YF YUSUF
#define Free_open(File) freopen((File".in"),"r",stdin);freopen((File".out"),"w",stdout);
#define YF ios_base::sync_with_stdio(0);cout.setf(ios::fixed);
#define YUSUF cout.precision(0);cout.tie(0);cin.tie(0);
#include <bits/stdc++.h>
using namespace std;
#ifdef YF_CHECK
	bool Output=1;
//	#include "g/debug.h"
	//#include "g/bigint.h"
	//#include "g/text.h"
#else
	bool Output=0;
	#define deb(x...) 42 
#endif
using ll  =  long long;
//using ld  =  long double;
using vll =  vector <ll>;
using mll =  map <ll,ll>;
using pll =  pair <ll,ll>;
using vpll=  vector <pll>;
template<class T>T MIN(T&a,T b){a=min(a,b);return a;}
template<class T>T MAX(T&a,T b){a=max(a,b);return a;}
#define revers(a) reverse(all(a))
#define all(a) a.begin(),a.end()
#define sortt(a) sort(all(a))
#define sgr v+v+1,tm+1,tr
#define sgl v+v,tl,tm
#define pb push_back
#define ins insert
#define S second
#define F first
#define int ll
ll BP(ll a,ll b,ll mod=1e9+7){
	if(b==0)return 1;
	ll q=BP(a,b/2,mod);
	return ((q*q)%mod*(b%2?a:1ll))%mod;
}
ll lcm(ll a,ll b){return a/__gcd(a,b)*b;}
ll dup(ll a,ll b){return (a+b-1)/b;}
ll f(ll x){return x*(x+1)/2;}
const int mod=998244353;
const int INF=1e18+7;
const int inf=1e9+7;
const int N  =1e6+7;
ll r,c,q;
bool check(pll A,pll B){
	auto [a,b]=A;
	auto [c,d]=B;
	if(a-c==b-d||c-a==d-b||-(a-c)==b-d||-(c-a)==d-b)return 1;
	return 0;
}
pll PP(ll x,ll y){
	if(x!=y)return {0,0};
	return {r-1,1};
}
pll BB(ll x,ll y){
	if((r-1)%2==(y-x)%2){
		if(check({1,x},{r,y}))return {1,1};
		ll l=1,R=1e9,ans1=1e9,ans2=ans1;
		while(l<=R){
			ll m=(l+R)/2;
			ll f=max(x-1,c-x)+1;
			ll s=(m-1)*(c-1);
//			if(m<=10)cout<<f<<" "<<s<<" "<<s+f<<" "<<r<<" : "<<m<<" : "<<l<<" "<<R<<" : " <<"";
			if(s+f>=r){
				ans1=m;
				R=m-1;
			}
			else{
				l=m+1;
			}
//			if(m<=10)cout<<l<<" "<<R<<"\n";
		}
		l=1;R=1e9;
		while(l<=R){
			ll m=(l+R)/2;
			ll f=min(x-1,c-x)+1;
			ll s=(m-1)*(c-1);
			if(s+f>=r){
				ans2=m;
				R=m-1;
			}
			else{
				l=m+1;
			}
		}
//		cout<<"ans1 "<<ans1<<" : "<<max(x-1,c-x)+1<<" "<<(ans1-1)*(c-1)<<"\n";
//		cout<<"ans1 "<<ans1<<" : "<<max(x-1,c-x)+1<<" "<<(ans1)*(c-1)<<"\n";
//		cout<<"ans2 "<<ans2<<" : "<<min(x-1,c-x)+1<<" "<<(ans2-1)*(c-1)<<"\n";
//		cout<<"ans2 "<<ans2<<" : "<<min(x-1,c-x)+1<<" "<<(ans2)*(c-1)<<"\n";
		ll posx=0;
		ll posy=0;
		if(x-1>c-x){
			posx=x+(c-1)*(ans1-1);
			if(ans1%2) posy=1;
			else posy=c;
		}
		else{
			posx=c-x+1+(c-1)*(ans1-1);
			if(ans1%2==0) posy=1;
			else posy=c;
		}
		if(posx-abs(posy-y)<r)ans1++;
		if(x-1<c-x){
			posx=x+(c-1)*(ans1-1);
			if(ans1%2) posy=1;
			else posy=c;
		}
		else{
			posx=c-x+1+(c-1)*(ans1-1);
			if(ans1%2==0) posy=1;
			else posy=c;
		}
		if(posx-abs(posy-y)<r)ans2++;
//		cout<<ans1<<" "<<ans2<<" : \n";
		if(ans1==ans2){
			return {ans1,2};
		}
		else{
			return {ans1,1};
		}
	}
	return {0,0};
//	return {inf,inf};
}
pll RR(ll x,ll y){
	if(x==y)return {1,1};
	else return {2,2};
}
pll KK(ll x,ll y){
	return {0,0};
}
pll QQ(ll x,ll y){
	if(x==y || check({1,x},{r,y}))return {1,1};
	else{
		pll R=RR(x,y);
		pll B=BB(x,y);
//		cout<<R.F<<" "<<R.S<<" : "<<B.F<<" "<<B.S<<"\n";
		return {R.F,R.S+2+(B.F==R.S)*(B.S)};
	}
}

void YF_MAIN(ll TEST){
	cin>>c>>r>>q;
	while(q--){
		char troop;ll x,y;
		cin>>troop>>x>>y;
		pll ans;
		if(troop=='P')ans=PP(x,y);
		if(troop=='B')ans=BB(x,y);
		if(troop=='K')ans=KK(x,y);
		if(troop=='R')ans=RR(x,y);
		if(troop=='Q')ans=QQ(x,y);
		cout<<ans.F<<" "<<ans.S<<"\n";
	}
}
bool TECT=0;
bool CASE=0;
bool OUTP=1;
//ll FACT[N],inv[N],FMOD=1e9+7;
//ll PER(ll n,ll k){return FACT[n] *inv[n-k]%FMOD;}
//ll CNK(ll n,ll k){return PER(n,k)*inv[k  ]%FMOD;}
//ll lg[N];
void BEFORE(){
	return;
//	for(int i=2;i<=200000;i++){
//		lg[i]=lg[i/2]+1;
//	}
//	FACT[0]=inv[0]=1;
//	for(int i=1;i<=1e5;i++){
//		FACT[i]=FACT[i-1]*i%FMOD;
//		inv[i]=BP(FACT[i],FMOD-2,FMOD);
//	}
}
signed main(){
	if(OUTP){YF YUSUF}
//	Free_open("TEST");
	cout<<(Output ? "\nYF_OUTPUT:\n\n" : "");
	int TEST=1;
	if(TECT)
		cin>>TEST;
	BEFORE();
	for(int T=1;T<=TEST;T++){
		if(CASE)
			cout<<"Case "<<T<<": ";
		YF_MAIN(T);
		cout<<(T==TEST ? "" : "\n");
	}
	return 0;
}
//```

컴파일 시 표준 에러 (stderr) 메시지

cleaning.cpp:1:10: fatal error: arithmetics.h: No such file or directory
    1 | #include "arithmetics.h"
      |          ^~~~~~~~~~~~~~~
compilation terminated.