QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#243437#6621. Luggage LockHe2717970784Compile Error//C++171.7kb2023-11-08 11:20:552023-11-08 11:20:55

Judging History

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

  • [2023-11-08 11:20:55]
  • 评测
  • [2023-11-08 11:20:55]
  • 提交

answer

#unclude<bits/stdc++.h>
using namespace std;
const int INF = 1e8;

int sign(int x) {
	if (x > 0) {
		return 1;
	}
	if (x < 0) {
		return -1;
	}
	return 0;
}

bool judge(int x, int y) {
	x = sign(x), y = sign(y);
	if (x * y < 0) {
		return 0;
	}
	return 1;
}

int solve() {
	string a, b;
	cin >> a >> b;
	vector<int>v(4, 0);
	for (int i = 0; i < 4; i++) {
		v[i] = b[i] - a[i];
	}
	queue<vector<int>>q;
	vector<vector<int>>Vector;
	map<vector<int>, int>vis;
	vis[v] = 1;
	q.push(v);
	Vector.push_back(v);
	int idx = 0;
	while (!q.empty()) {
		vector<int>pre = q.front();
		q.pop();
		for (int i = 0; i < 4; i++) {
			vector<int>now = pre;
			now[i] = (now[i] + 10) % 10;
			if (!vis[now]) {
				vis[now] = 1;
				q.push(now);
				Vector.push_back(now);
			}
			now[i] -= 10;
			if (!vis[now]) {
				vis[now] = 1;
				q.push(now);
				Vector.push_back(now);
			}
		}
	}
	int ans = INF;
	for (int i = 0; i < (int)Vector.size(); i++) {
		int res = 0;
		while (true) {
			int val = INT_MAX;
			int j = 0;
			while (j < 4 && (!Vector[i][j])) {
				j++;
			}
			for (; j < 4; j++) {
				if ((val == INT_MAX || val == 0) || (sign(Vector[i][j]) == sign(val) && abs(Vector[i][j]) < abs(val))) {
					val = Vector[i][j];
				}
				else if (sign(Vector[i][j]) != sign(val)) {
					break;
				}
			}
			if ((val == INT_MAX) || (val == 0)) {
				break;
			}
			res += abs(val);
			for (int k = 0; k < j; k++) {
				if (Vector[i][k] == 0) {
					continue;
				}
				Vector[i][k] -= val;
			}
		}
		ans = min(ans, res);
	}
	return ans;
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int t = 0;
	cin >> t;
	while (t--) {
		int ans = solve();
		cout << ans << endl;
	}
	return 0;
}

Details

answer.code:1:2: error: invalid preprocessing directive #unclude; did you mean #include?
    1 | #unclude<bits/stdc++.h>
      |  ^~~~~~~
      |  include
answer.code: In function ‘int solve()’:
answer.code:24:9: error: ‘string’ was not declared in this scope
   24 |         string a, b;
      |         ^~~~~~
answer.code:1:1: note: ‘std::string’ is defined in header ‘<string>’; did you forget to ‘#include <string>’?
  +++ |+#include <string>
    1 | #unclude<bits/stdc++.h>
answer.code:25:9: error: ‘cin’ was not declared in this scope
   25 |         cin >> a >> b;
      |         ^~~
answer.code:1:1: note: ‘std::cin’ is defined in header ‘<iostream>’; did you forget to ‘#include <iostream>’?
  +++ |+#include <iostream>
    1 | #unclude<bits/stdc++.h>
answer.code:25:16: error: ‘a’ was not declared in this scope
   25 |         cin >> a >> b;
      |                ^
answer.code:25:21: error: ‘b’ was not declared in this scope
   25 |         cin >> a >> b;
      |                     ^
answer.code:26:9: error: ‘vector’ was not declared in this scope
   26 |         vector<int>v(4, 0);
      |         ^~~~~~
answer.code:1:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
  +++ |+#include <vector>
    1 | #unclude<bits/stdc++.h>
answer.code:26:16: error: expected primary-expression before ‘int’
   26 |         vector<int>v(4, 0);
      |                ^~~
answer.code:28:17: error: ‘v’ was not declared in this scope
   28 |                 v[i] = b[i] - a[i];
      |                 ^
answer.code:30:9: error: ‘queue’ was not declared in this scope
   30 |         queue<vector<int>>q;
      |         ^~~~~
answer.code:1:1: note: ‘std::queue’ is defined in header ‘<queue>’; did you forget to ‘#include <queue>’?
  +++ |+#include <queue>
    1 | #unclude<bits/stdc++.h>
answer.code:30:22: error: expected primary-expression before ‘int’
   30 |         queue<vector<int>>q;
      |                      ^~~
answer.code:31:23: error: expected primary-expression before ‘int’
   31 |         vector<vector<int>>Vector;
      |                       ^~~
answer.code:32:9: error: ‘map’ was not declared in this scope
   32 |         map<vector<int>, int>vis;
      |         ^~~
answer.code:1:1: note: ‘std::map’ is defined in header ‘<map>’; did you forget to ‘#include <map>’?
  +++ |+#include <map>
    1 | #unclude<bits/stdc++.h>
answer.code:32:20: error: expected primary-expression before ‘int’
   32 |         map<vector<int>, int>vis;
      |                    ^~~
answer.code:33:9: error: ‘vis’ was not declared in this scope
   33 |         vis[v] = 1;
      |         ^~~
answer.code:33:13: error: ‘v’ was not declared in this scope
   33 |         vis[v] = 1;
      |             ^
answer.code:34:9: error: ‘q’ was not declared in this scope
   34 |         q.push(v);
      |         ^
answer.code:35:9: error: ‘Vector’ was not declared in this scope
   35 |         Vector.push_back(v);
      |         ^~~~~~
answer.code:38:24: error: expected primary-expression before ‘int’
   38 |                 vector<int>pre = q.front();
      |                        ^~~
answer.code:41:32: error: expected primary-expression before ‘int’
   41 |                         vector<int>now = pre;
      |                                ^~~
answer.code:42:25: error: ‘now’ was not declared in this scope
   42 |                         now[i] = (now[i] + 10) % 10;
      |                         ^~~
answer.code:60:35: error: ‘INT_MAX’ was not declared in this scope
   60 |                         int val = INT_MAX;
      |                                   ^~~~~~~
answer.code:1:1: note: ‘INT_MAX’ is defined in header ‘<climits>’; did you forget to ‘#include <climits>’?
  +++ |+#include <climits>
    1 | #unclude<bits/stdc++.h>
answer.code:66:105: error: ‘abs’ was not declared in this scope; did you mean ‘ans’?
   66 |                                 if ((val == INT_MAX || val == 0) || (sign(Vector[i][j]) == sign(val) && abs(Vector[i][j]) < abs(val))) {
      |                                                                                                         ^~~
      |                                                                                                         ans
answer.code:76:32: error: ‘abs’ was not declared in this scope; did you mean ‘ans’?
   76 |                         res += abs(val);
      |                                ^~~
      |                                ans
answer.code:84:23: error: ‘min’ was not declared in this scope
   84 |                 ans = min(ans, res);
      |                       ^~~
answer.code: In function ‘int main()’:
answer.code:90:9: error: ‘ios’ has not been declared
   90 |         ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
      |         ^~~
answer.code:90:34: error: ‘cin’ was not declared in this scope
   90 |         ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
      |                                  ^~~
answer.code:90:34: note...