Rezultati

Up. imeNalogaJezikRezultatČas oddaje
luftkanali-2019 Revolver C++ 100/100OK 09. maj '19 @ 19:00

Test Točke Porabljen spomin Porabljen čas Status
#1 [več] 14/14 3,391 MiB 0,053 s OK
#2 [več] 14/14 3,395 MiB 0,034 s OK
#3 [več] 14/14 3,285 MiB 0,000 s OK
#4 [več] 14/14 3,305 MiB 0,123 s OK
#5 [več] 14/14 3,305 MiB 0,056 s OK
#6 [več] 15/15 3,395 MiB 0,044 s OK
#7 [več] 15/15 3,383 MiB 0,050 s OK

Ocenjevani program (rovelver.cpp):
#include <iostream>
#include <vector>
#include <iomanip>
#include <string.h>
using namespace std;

int zaporedno[100];
int beli;
int vsi;

pair<long double, vector<bool> > mem[101][20];
bool ok[101][20];

void put(int a) {
	for (int i = 0; i < a; i++)
		cout << "\t";
}

pair<long double, vector<bool> > f(int n, int rem) {
	if (ok[n][rem]) return mem[n][rem];
	if (rem == 0) return {1, {}};
	auto ap = f(n+1, rem-1);
	auto bp = f(2, rem-1);
	long double a = ((long double) zaporedno[n] / zaporedno[n-1]) * ap.first; 
	long double b = ((long double) beli / vsi) * bp.first; 
	ok[n][rem] = true;
	if (a>b) {
		ap.second.push_back(0);
		return mem[n][rem] = {a, ap.second};
	} else {
		bp.second.push_back(1);
		return mem[n][rem] = {b, bp.second};
	}
	//put(5-rem);
	//cout << n << " " << a << " " << b << "\n";
}

int main() {
	int T;
	cin >> T;
	while (T--) {
		int n, p;
		cin >> n >> p;
		cin.clear();cin.ignore(9999,'\n');
		string s;
		cin >> s;
		vsi=n;
		memset(zaporedno, 0, sizeof(zaporedno));
		beli=0;
		for (int i = 0; i < n; i++) {
			int j = i;
			int c = 1;
			while (s[j] == '.') {
				zaporedno[c++]++;
				j += 1;
				j %= n;
			}
			if (s[i] == '.') beli++;
		}
		//for (int i =0; i < n; i++)
		//	cout << zaporedno[i] << " ";
		memset(ok, 0, sizeof(ok));
		auto res = f(2, p-1);
		cout << fixed <<  setprecision(12) << res.first*(long double)beli/vsi << "\n";
		for (auto r: res.second) {
			cout << (r? "ROLL" : "FIRE") << "\n";
		}
	}
}