QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#303480 | #7779. Swiss Stage | PetroTarnavskyi# | WA | 0ms | 3572kb | C++20 | 1.6kb | 2024-01-12 16:52:08 | 2024-01-12 16:52:09 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;
const int N = 107;
const int INF = 1e9;
int X, Y, p, q;
int dpT[N][N][2];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout << fixed << setprecision(15);
FOR(i, 0, N)
FOR(j, 0, N)
FOR(k, 0, 2)
dpT[i][j][k] = INF;
cin >> X >> Y >> p >> q;
queue<pair<PII, int>> Q;
Q.push(MP(MP(X, Y), 0));
dpT[X][Y][0] = 0;
while(!Q.empty())
{
auto [left, t] = Q.front();
auto [x, y] = left;
Q.pop();
//cout << x << " " << y << " " << t << " " << dpT[x][y][t] << endl;
if((x != 0 && y > x + q && t == 1) || ((X - x) != 0 && (Y - y) > (X - x) + q && t == 0))
continue;
if(x == 0 && t == 1)
{
cout << dpT[0][y][1] << "\n";
return 0;
}
if(t == 0)
{
FOR(dx, 0, x + 1)
FOR(dy, 0, y + 1)
if(dx + dy <= p)
{
if(dpT[x - dx][y - dy][1] == INF)
{
dpT[x - dx][y - dy][1] = dpT[x][y][t] + 1;
Q.push(MP(MP(x - dx, y - dy), 1));
}
}
}
else
{
FOR(dx, 0, (X - x) + 1)
FOR(dy, 0, (Y - y) + 1)
if(dx + dy <= p)
{
if(dpT[x + dx][y + dy][0] == INF)
{
dpT[x + dx][y + dy][0] = dpT[x][y][t] + 1;
Q.push(MP(MP(x + dx, y + dy), 0));
}
}
}
}
cout << "-1\n";
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3572kb
input:
0 1
output:
1
result:
wrong answer 1st numbers differ - expected: '4', found: '1'