QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#372992 | #5271. Focusing on Costs | FOY# | WA | 1ms | 3772kb | C++23 | 1.6kb | 2024-03-31 22:28:45 | 2024-03-31 22:28:45 |
Judging History
answer
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <numeric>
using namespace std;
using pii = pair<int, int>;
class Trans {
virtual string getName() = 0;
virtual pii act(pii cur) = 0;
};
int transCount = 6;
pii act(pii cur, int type) {
auto [a, b] = cur;
if (type == 0)
return {b - a, b};
if (type == 1)
return {a, b - a};
if (type == 2)
return {b - a, a};
if (type == 3)
return {b - a, b};
if (type == 4)
return {a, b + a};
if (type == 5)
return {b, a+b};
}
string getName(int type) {
if (type == 0) return "asin cos";
if (type == 1) return "asin tan";
if (type == 2) return "acos tan";
if (type == 3) return "acos sin";
if (type == 4) return "atan sin";
if (type == 5) return "atan cos";
}
int main() {
map<pii, pair<pii, int>> vis;
queue<pii> cur;
cur.push({0, 1});
int x, y; cin >> x >> y;
int a = x, b = y;
cout << a << ' ' << b << endl;
int u = gcd(a,b);
a/=u;
b/=u;
while (vis.count({a*a, b*b}) == 0) {
auto front = cur.front();
cur.pop();
if (abs(front.first) > 1e3 || abs(front.second) > 1e3) continue;
for (int t = 0; t < transCount; t++) {
auto to = act(front, t);
if (to.second <= 0) continue;
if (vis.count(to) == 0) {
vis[to] = {front, t};
cur.push(to);
}
}
}
pii end = {a*a, b*b};
vector<string> path;
while (end != make_pair(0, 1)) {
path.push_back(getName(vis[end].second));
end = vis[end].first;
}
cout << 2*path.size() << endl;
for (int i = path.size()-1; i >= 0; i--) cout << path[i]<< ' ';
cout <<endl;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3772kb
input:
1 1
output:
1 1 2 asin cos
result:
wrong answer Token parameter [name=op[1]] equals to "1", doesn't correspond to pattern "a?(sin|cos|tan)"