Submission
Status:
[PP-SSSSSSSSSSSS]
Subtask/Task Score:
{0/100}
Score: 0
User: Wha
Problemset: forex
Language: cpp
Time: 0.002 second
Submitted On: 2026-03-07 22:01:30
#include <bits/stdc++.h>
using namespace std;
int mn = 621;
int sel = 621;
float ex[32][32];
void recur(int origin, int from, int to, int n, float product, int progress) {
if (progress > n || progress > mn) { return; }
if (origin == to) {
if (product >= 1.01) {
sel = min(sel, origin + 1);
mn = min(mn, progress);
return;
}
}
for (int i = 0; i < n; i++) {
if (to == i) { continue; }
recur(origin, to, i, n, product * ex[to][i], progress + 1);
}
}
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
float t;
cin >> t;
ex[i][j] = t;
}
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (i == j) { continue; }
recur(i, i, j, n, ex[i][j], 1);
}
}
if (mn > 50) {
cout << "-1\n";
}else {
cout << sel << " " << mn << "\n";
}
return 0;
}