답안 #274181

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
274181 2020-08-19T09:31:12 Z AKaan37 Fishing Game (RMI19_fishing) C++17
40 / 100
2000 ms 29272 KB
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;
typedef pair< lo,PII > PIII;
typedef pair< lo,PIII > PIIII;
typedef pair< lo,PIIII > PIIIII;

#define int long long
#define fi first
#define se second
#define mp make_pair
#define endl "\n"
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n*2;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo inf = 1000000000000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 502;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t,c[li];
int cev;
string s;
map<PIIIII,int> dp;
vector<int> v;

inline int mul(int x,int y){
	return (x%mod)*(y%mod)%mod;
}

inline int add(int x,int y){
	if(x+y>=mod)return x+y-mod;
	return x+y;
}

inline int f(int x,int y,int z,int kim,int last){
	int cevv=0;
	//~ if(x==0 && z==0 && kim==1)return 1;
	//~ if(y==0 && x==0 && kim==2)return 1;
	//~ if(z==0 && y==0 && kim==3)return 1;
	//~ if(z==0 && last==0 && kim==3)return 1;
	if(x==0 && y==0 && z==0)return 1;
	if(dp.find({x,{y,{z,{kim,last}}}})!=dp.end())return dp[{x,{y,{z,{kim,last}}}}];
	//~ cout<<x<<" : : "<<y<<" : ;"<<z<<endl;
	if(kim==1){
		if(x==0 && z==0)cevv=add(cevv,f(x,y,z,2,0));
		for(int i=1;i<=x;i++)cevv=add(cevv,f(x-1,y,z,2,1));
		for(int i=1;i<=z;i++)cevv=add(cevv,f(x,y+1,z-1,2,0));
	}
	if(kim==2){
		if(y==0 && x==0)cevv=add(cevv,f(x,y,z,2,last));
		for(int i=1;i<=y;i++)cevv=add(cevv,f(x,y-1,z,3,1));
		for(int i=1;i<=x;i++)cevv=add(cevv,f(x-1,y,z+1,3,last));
	}
	if(kim==3){
		//~ if(last && y==0)cevv=add(cevv,f(x,y,z,1,0));
		for(int i=1;i<=z;i++)cevv=add(cevv,f(x,y,z-1,1,0));
		if(last)for(int i=1;i<=y;i++)cevv=add(cevv,f(x+1,y-1,z,1,0));
	}
	return dp[{x,{y,{z,{kim,last}}}}]=cevv;
}

main(void){
	scanf("%lld %lld",&n,&t);
	while(t--){
		dp.clear();
		//~ memset(dp,-1,sizeof(dp));
		FOR{
			scanf("%lld",&a[i]);
		}
		FOR{
			scanf("%lld",&b[i]);
		}
		FOR{
			scanf("%lld",&c[i]);
		}
		int aveb=0,avec=0,bvec=0;
		FOR{
			for(int j=1;j<=n*2;j++){
				if(a[i]==b[j])aveb++;
			}
		}
		FOR{
			for(int j=1;j<=n*2;j++){
				if(a[i]==c[j])avec++;
			}
		}
		FOR{
			for(int j=1;j<=n*2;j++){
				if(b[i]==c[j])bvec++;
			}
		}
		//~ aveb=2;
		//~ avec=2;
		//~ bvec=2;
		//~ cout<<aveb<<" :: "<<bvec<<" :: "<<avec<<endl;
		printf("%lld\n",f(aveb,bvec,avec,1,0));
	}
	return 0;
}

Compilation message

fishing.cpp:75:10: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   75 | main(void){
      |          ^
fishing.cpp: In function 'int main()':
fishing.cpp:76:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   76 |  scanf("%lld %lld",&n,&t);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~
fishing.cpp:81:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   81 |    scanf("%lld",&a[i]);
      |    ~~~~~^~~~~~~~~~~~~~
fishing.cpp:84:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   84 |    scanf("%lld",&b[i]);
      |    ~~~~~^~~~~~~~~~~~~~
fishing.cpp:87:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   87 |    scanf("%lld",&c[i]);
      |    ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 10 ms 640 KB Output is correct
4 Correct 102 ms 2476 KB Output is correct
5 Execution timed out 2090 ms 10104 KB Time limit exceeded
6 Execution timed out 2083 ms 20888 KB Time limit exceeded
7 Execution timed out 2077 ms 17384 KB Time limit exceeded
8 Execution timed out 2081 ms 28860 KB Time limit exceeded
9 Execution timed out 2079 ms 29104 KB Time limit exceeded
10 Execution timed out 2092 ms 29272 KB Time limit exceeded