QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#673370#7781. Sheep Eat WolvesAlucardCompile Error//C++141.7kb2024-10-24 21:58:112024-10-24 21:58:11

Judging History

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

  • [2024-10-24 21:58:11]
  • 评测
  • [2024-10-24 21:58:11]
  • 提交

answer

#include <bits/stdc++.h>
#include <iostream>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define i128 _int128
#define fi first
#define se second 
#define pb push_back
#define endl '\n'
//#define int long long
 
const ll INF=0x3f3f3f3f;
const ll N=1e2+9;
const int mod=1e4;

inline int read(){
	int ans=0,sign=1;
	char ch = getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-'){
			sign=-1;
		}
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		ans = ans*10 + ch-'0';
		ch = getchar();
	}
	return ans*sign;
}
const int N = 1e2 + 10;
const int mod = 998244353;
int dp[N][N][2];
int x,y,p,q;
void bfs() {
	queue<pair<pair<int,int>,int>>c;
	c.push({{x,y},0});
	dp[x][y][0]=0;
	while (!c.empty()) {
		int nowx=c.front().first.first;
		int nowy=c.front().first.second;
		int flag=c.front().second;
		c.pop();
		for (int i=nowx; i>=0; i--) {
			for (int j=nowy; j>=0; j--) {
				if ((i+j<=p)&&(nowx-i+q>=nowy-j||nowx-i==0)) {
					if (dp[x-nowx+i][y-nowy+j][flag^1]>dp[nowx][nowy][flag]+1) {
						dp[x-nowx+i][y-nowy+j][flag^1]=dp[nowx][nowy][flag]+1;
						c.push({{x-nowx+i,y-nowy+j},flag^1});
					}
					
				}
			}
		}
	}
}
void solved() {
	cin>>x>>y>>p>>q;
	for (int i=0; i<=100; i++) {
		for (int j=0; j<=100; j++) {
			for (int k=0; k<=1; k++) {
				dp[i][j][k]=1e18;
			}
		}
	}
	bfs();
	int minn=1e18;
	for (int i=0; i<=y; i++) {
		minn=min(dp[x][i][1],minn);
	}
	if (minn>=1e18) {
		cout<<"-1\n";
	} else {
		cout<<minn<<"\n";
	}
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int t = 1;
	// cin>>t;
	while (t--) {
		solved();
	}
}

详细

answer.code:37:11: error: conflicting declaration ‘const int N’
   37 | const int N = 1e2 + 10;
      |           ^
answer.code:19:10: note: previous declaration as ‘const ll N’
   19 | const ll N=1e2+9;
      |          ^
answer.code:38:11: error: redefinition of ‘const int mod’
   38 | const int mod = 998244353;
      |           ^~~
answer.code:20:11: note: ‘const int mod’ previously defined here
   20 | const int mod=1e4;
      |           ^~~
answer.code: In function ‘void solved()’:
answer.code:68:45: warning: overflow in conversion from ‘double’ to ‘int’ changes value from ‘1.0e+18’ to ‘2147483647’ [-Woverflow]
   68 |                                 dp[i][j][k]=1e18;
      |                                             ^~~~
answer.code:73:18: warning: overflow in conversion from ‘double’ to ‘int’ changes value from ‘1.0e+18’ to ‘2147483647’ [-Woverflow]
   73 |         int minn=1e18;
      |                  ^~~~