QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#131592#4676. Amalgamated ArtichokesPetroTarnavskyi#Compile Error//C++172.9kb2023-07-27 18:25:022023-07-27 18:25:04

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-27 18:25:04]
  • 评测
  • [2023-07-27 18:25:02]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define FILL(a, b) memset(a, b, sizeof(a))

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;

const int N = 74;
const int MAX = 17474;
const int INF = 1e9 + 47;

int dp[MAX][N][N];
int mn[4][N][N];
char c[N][N];


void create(int l0, int dx, int l1, int dy, int t, int idx)
{
	FOR (i, 0, 50)
	{
		FOR (j, 0, 50)
		{
			int x = l0 + dx * i;
			int y = l1 + dy * j;
			mn[t][x][y] = (-dx * x) + (-dy * y) + dp[idx][x][y];
			int nx = x - dx;
			int ny = y - dy;
			if (nx >= 0 && nx < 50) mn[t][x][y] = min(mn[t][x][y], mn[t][nx][y]);
			if (ny >= 0 && ny < 50) mn[t][x][y] = min(mn[t][x][y], mn[t][x][ny]);
		}
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	FOR (i, 0, N) FOR (j, 0, N) c[i][j] = 'a';
	
	int n, m;
	cin >> n >> m;
	FOR (i, 0, n) FOR (j, 0, m) cin >> c[i][j];
	
	FOR (i, 0, N) FOR (j, 0, N) dp[0][i][j] = INF;
	dp[0][0][0] = 0;
	
	string s;
	cin >> s;
	s += '*';
	FOR (step, 0, SZ(s))
	{
		create(0, 1, 0, 1, 0, step);
		create(0, 1, 49, -1, 1, step);
		create(49, -1, 0, 1, 2, step);
		create(49, -1, 49, -1, 3, step);
		
		FOR (t, 0, 4)
		{
			cout << t << '\n';
			FOR (i, 0, 3)
			{
				FOR (j, 0, 3)
					cout << mn[t][i][j] << ' ';
				cout << '\n';
			}
			cout << "\n\n";
		}
		
		FOR (i, 0, n)
		{
			FOR (j, 0, m)
			{
				if (c[i][j] == s[step])
				{
					dp[step + 1][i][j] = INF;
					dp[step + 1][i][j] = min(dp[step + 1][i][j], i + j + mn[0][i][j]);
					dp[step + 1][i][j] = min(dp[step + 1][i][j], i - j + mn[1][i][j]);
					dp[step + 1][i][j] = min(dp[step + 1][i][j], - i + j + mn[2][i][j]);
					dp[step + 1][i][j] = min(dp[step + 1][i][j], - i - j + mn[3][i][j]);
					cerr << step << ' ' << i << ' ' << j << ' ' << dp[step + 1][i][j] << '\n';
				}
				else
					dp[step + 1][i][j] = INF;
			}
		}
	}
	int ans = INF;
	FOR (i, 0, n) FOR (j, 0, m) ans = min(ans, dp[SZ(s)][i][j]);
	cout << ans << '\n';
	return 0;
}

0
0 0 0 
0 0 0 
0 0 0 


1
0 1000000048 1000000049 
0 1000000047 1000000048 
0 1000000046 1000000047 


2
0 0 0 
1000000048 1000000047 1000000046 
1000000049 1000000048 1000000047 


3
0 1000000048 1000000049 
1000000048 1000000049 1000000050 
1000000049 1000000050 1000000051 


0
1000000047 1000000046 0 
1000000046 1000000045 0 
1000000045 1000000044 0 


1
4 4 4 
4 4 4 
4 4 4 


2
4 3 0 
4 3 2 
4 3 2 


3
4 4 4 
4 5 6 
4 5 6 


0
1000000047 1000000046 1000000045 
1000000046 1000000045 1000000044 
0 0 0 


1
7 7 7 
6 6 6 
0 5 5 


2
4 3 2 
4 3 2 
4 3 2 


3
4 5 6 
4 5 6 
4 5 6 


1

Details

answer.code:104:1: error: expected unqualified-id before numeric constant
  104 | 0
      | ^