QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#673367 | #7781. Sheep Eat Wolves | Alucard | Compile Error | / | / | C++14 | 1.7kb | 2024-10-24 21:57:24 | 2024-10-24 21:57:24 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
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) {
// cout<<"对岸是:"<<flag<<"当前岸上的羊:"<<nowx<<"当前岸上的狼"<<nowy<<"转移的羊:"<<i<<"转移的狼:"<<j<<"转移后的羊:"<<x-nowx+i<<"转移后的狼"<<y-nowy+j<<"\n";
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();
}
}
————————————————
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/hanghang20030820/article/details/140839351
詳細信息
answer.code:61:1: error: extended character — is not valid in an identifier 61 | ———————————————— | ^ answer.code:61:1: error: extended character — is not valid in an identifier answer.code:61:1: error: extended character — is not valid in an identifier answer.code:61:1: error: extended character — is not valid in an identifier answer.code:61:1: error: extended character — is not valid in an identifier answer.code:61:1: error: extended character — is not valid in an identifier answer.code:61:1: error: extended character — is not valid in an identifier answer.code:61:1: error: extended character — is not valid in an identifier answer.code:61:1: error: extended character — is not valid in an identifier answer.code:61:1: error: extended character — is not valid in an identifier answer.code:61:1: error: extended character — is not valid in an identifier answer.code:61:1: error: extended character — is not valid in an identifier answer.code:61:1: error: extended character — is not valid in an identifier answer.code:61:1: error: extended character — is not valid in an identifier answer.code:61:1: error: extended character — is not valid in an identifier answer.code:61:1: error: extended character — is not valid in an identifier answer.code:63:77: error: extended character 。 is not valid in an identifier 63 | 版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。 | ^ answer.code:61:1: error: ‘————————————————’ does not name a type 61 | ———————————————— | ^~~~~~~~~~~~~~~~