QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#673373#7781. Sheep Eat WolvesAlucardCompile Error//C++141.5kb2024-10-24 22:00:312024-10-24 22:00:32

Judging History

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

  • [2024-10-24 22:00:32]
  • 评测
  • [2024-10-24 22:00:31]
  • 提交

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;
}


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 solve() {
	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";
	}
}

Details

/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/13/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x24): undefined reference to `main'
collect2: error: ld returned 1 exit status