QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#303480#7779. Swiss StagePetroTarnavskyi#WA 0ms3572kbC++201.6kb2024-01-12 16:52:082024-01-12 16:52:09

Judging History

你现在查看的是最新测评结果

  • [2024-01-12 16:52:09]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3572kb
  • [2024-01-12 16:52:08]
  • 提交

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'