QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#210205#4376. Dragon slayerhazeWA 32ms3900kbC++202.1kb2023-10-11 09:10:452023-10-11 09:10:46

Judging History

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

  • [2023-10-11 09:10:46]
  • 评测
  • 测评结果:WA
  • 用时:32ms
  • 内存:3900kb
  • [2023-10-11 09:10:45]
  • 提交

answer

#include<bits/stdc++.h>
#define irep(i,l,r) for(int i = l; i <= r; ++i)
#define drep(i,r,l) for(int i = r; i >= l; --i)
#define ceil(pp,qq) (((pp)>0)^((qq)>0)?-Abs(pp)/Abs(qq):(pp)%(qq)?(pp)/(qq)+1:(pp)/(qq))
#define floor(pp,qq) (((pp)>0)^((qq)>0)?-ceil(Abs(pp),Abs(qq)):(pp)/(qq))
#define ll long long
#define LL __int128
using namespace std;
ll Abs(ll x){return x > 0 ? x : - x;}
inline ll read(){
	char ch = getchar();
	ll s = 0; bool w = 0;
	while(!isdigit(ch)){if(ch == '-')w = 1;ch = getchar();}
	while(isdigit(ch))s = (s << 3) + (s << 1) + (ch ^ 48), ch = getchar();
	return w ? - s : s;
}

const int itinf = 1e9;
const ll llinf = 4e18;
const int mod = 1000000007;
const int N = 500009;

inline int mul(int nma, int nmb){
	return ((1ll * nma * nmb % mod) + mod) % mod;
}
int dis[16][16][16][16];
void solve(){
	memset(dis, 0x3f, sizeof(dis));
	int n = read(), m = read(), K = read();
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < m; ++j){
			dis[i][j][i][j] = 0;
			if(i + 1 < n)dis[i][j][i + 1][j] = dis[i + 1][j][i][j] = 0;
			if(j + 1 < m)dis[i][j][i][j + 1] = dis[i][j + 1][i][j] = 0;
		}
	}
	array<int,2> S, T;
	int x1 = read(), y1 = read(), x2 = read(), y2 = read();
	S = {x1, y1}, T = {x2, y2};
	for(int i = 1; i <= K; ++ i){
		x1 = read(), y1 = read(), x2 = read() ,y2 = read();
		if(x1 == x2){
			if(x1 == 0)continue;
			if(y1 > y2)swap(y1, y2);
			while(y1 < y2){
				dis[x1 - 1][y1][x1][y1] = 1;
				dis[x1][y1][x1 - 1][y1] = 1;
				++ y1;
			}
		}
		if(y1 == y2){
			if(y1 == 0)continue;
			if(x1 > x2)swap(x1, x2);
			while(x1 < x2){
				dis[x1][y1 - 1][x1][y1] = 1;
				dis[x1][y1][x1][y1 - 1] = 1;
				++ x1;
			}
		}
	}

	cerr << endl;
	irep(kx,0,n-1){
		irep(ky,0,m-1){
			irep(ix,0,n-1){
				irep(iy,0,m-1){
					irep(jx,0,n-1){
						irep(jy,0,m-1){
							dis[ix][iy][jx][jy] = min(dis[ix][iy][jx][jy],
							dis[ix][iy][kx][ky] + dis[kx][ky][jx][jy]);
						}
					}
				}
			}
		}
	}
	printf("%lld\n", dis[S[0]][S[1]][T[0]][T[1]]);
	return;
}

int main(){
	int T = read();
	while(T --){
		solve();
	}
	return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 32ms
memory: 3900kb

input:

10
4 4 4 0 2 3 3
0 2 4 2
1 3 1 0
2 4 2 1
3 1 3 4
3 2 2 0 0 2 1
0 1 3 1
1 0 1 2
3 2 2 0 0 2 1
2 1 2 2
1 0 1 1
15 15 15 3 12 4 1
8 0 8 15
1 11 15 11
1 1 1 15
3 1 3 15
0 10 14 10
14 1 14 14
8 1 8 15
1 5 14 5
0 15 14 15
0 4 14 4
0 2 15 2
11 0 11 15
4 1 4 15
1 11 15 11
1 12 14 12
15 15 15 8 5 14 0
0 12 1...

output:

2
2
0
5
3
6
1
4
1
0

result:

wrong answer 1st lines differ - expected: '1', found: '2'