Submission #73550

# Submission time Handle Problem Language Result Execution time Memory
73550 2018-08-28T12:16:51 Z haitun Fibonacci representations (CEOI18_fib) C++14
0 / 100
4000 ms 616 KB
#include <bits/stdc++.h>
#include <tuple>
//#include "functions.h"
#define FOR(x,y) for(int x = 0; x < y; x++)
#define ALLR(x) x.begin(),x.end()
#define con continue
#define ll long long
#define LINF LLONG_MAX
#define INF INT_MAX
#define pii pair<int,int>
#define vi vector <int>
#define pb push_back
#define F first
#define S second
#define len(x) x.length()
#define sz(x) x.size()
#define SEE(v)	for(auto x : t)	cout << x << " "; cout << endl;
using namespace std;
void rec(ll n, vector <ll> f, ll &ans,vector <ll> vans, vector <vector<ll> > &vector_of_ans) {
	if(n == 0)
	{
		sort(ALLR(vans));
		FOR(j, sz(vector_of_ans))
		{
			if(vans == vector_of_ans[j])  return;
		}
		vector_of_ans.pb(vans);
		ans++;
		//FOR(j, sz(vans))  cout << vans[j] << " ";
		//cout << endl;
		return;
	} else if(n < 0)  return;
	int pos = upper_bound(ALLR(f), n) - f.begin();
	FOR(j, pos) {
		//cout  << n << endl;
		ll temp = f[j];
		f.erase(f.begin() + j);
		if(n - temp >= 0) {
			vans.pb(temp);
			rec(n - temp, f, ans, vans, vector_of_ans);
			vans.erase(vans.end() - 1);
		}
		f.insert(f.begin() + j, temp);
	}
}

int main() {

	/*srand(time(0));

	double a[10], b[10];
	int r = 500000;
	int cnt[3] = {0};

	fstream os;
	os.open("test.txt");
	FOR(j,10) os >> a[j];
	FOR(j,10) os >> b[j];
	os.close();

	double tdmg = 0.0;

	FOR(jbciwb, r)
	{
	  bool cr = false;
	  double patk = a[0], matk = a[2];
	  if((rand() % 100) < a[6])
	  {
	    patk *= 1.5;
	    matk *= 1.3;
	    cnt[0]++;
	    cr = true;
	  }

	  double pdmg = max(patk - b[1], 0.0);
	  double mdmg = max(matk - b[3], 0.0);
	  double dmg = pdmg + mdmg;

	  if((rand() % 100) < b[7])
	  {
	    dmg = 0;
	    if(cr)  cnt[2]++;
	    cnt[1]++;
	  }

	  tdmg += dmg;
	}
	cout << tdmg / double(r) - b[5];
	cout << endl;
	cout << cnt[0] << " " << cnt[1] << " " <<  cnt[2];*/
	
	//freopen("test.txt","r",stdin);

	int n, r;
	cin >> n;

	vector <ll> num(n), t, f = {1,2};
	FOR(j, 106)  f.pb(f[j] + f[j + 1]);
	FOR(j, n)	cin >> num[j];
	
	r = f[num[0] - 1];

	FOR(j, n)
	{
		if(j != 0)
		{
			r += f[num[j] - 1];
		}
		vector <ll> vans;
		vector <vector<ll> > vector_of_ans;

	
/*
	FOR(j, 30) {
		//if(j <= 120)  con;
		ll ans = 0;
		rec(j, f, ans, vans, vector_of_ans);
		//cout << ans << endl;
		cout << "To form " << j << ": " << ans << endl;
		if(ans == 0) {
			cout << endl << j << " !!!!!!\n\n";
			break;
		}
	}
	*/
		ll ans = 0;
		rec(r, f, ans, vans, vector_of_ans);
		//cout << ans << endl;
		cout <<  ans << endl;
	}
		

}

Compilation message

fib.cpp: In function 'void rec(long long int, std::vector<long long int>, long long int&, std::vector<long long int>, std::vector<std::vector<long long int> >&)':
fib.cpp:4:35: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define FOR(x,y) for(int x = 0; x < y; x++)
                                   ^
fib.cpp:23:3: note: in expansion of macro 'FOR'
   FOR(j, sz(vector_of_ans))
   ^~~
# Verdict Execution time Memory Grader output
1 Correct 14 ms 376 KB Output is correct
2 Execution timed out 4034 ms 616 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 376 KB Output is correct
2 Execution timed out 4034 ms 616 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4093 ms 616 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 376 KB Output is correct
2 Execution timed out 4034 ms 616 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 616 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 376 KB Output is correct
2 Execution timed out 4034 ms 616 KB Time limit exceeded
3 Halted 0 ms 0 KB -