QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#440173 | #6739. Teleport | suibian_xiaozhao | Compile Error | / | / | C++20 | 5.5kb | 2024-06-13 11:10:33 | 2024-06-13 11:10:33 |
Judging History
answer
#include<bits/stdc++.h>
using i64 = long long;
using namespace std;
const int dx[4] = {0, 0, -1, 1};
const int dy[4] = {-1, 1, 0, 0};
int f[5001 * 5001];
int find(int x) {
int t = x;
while (f[x] != x) {
x = f[x];
}
while (f[t] != t) {
t = f[t];
f[t] = x;
}
return x;
}
// void solve() {
// int n, k; cin >> n >> k;
// vector<string> s(n);
// for (int i = 0; i < n; ++i) cin >> s[i];
// vector dis(n, vector<int>(n, -1));
// queue<pair<int, int>> q;
// q.emplace(0, 0);
// dis[0][0] = 0;
// iota(f, f + (n + 1) * (n + 1), 0);
// while (!q.empty()) {
// auto [x, y] = q.front();
// q.pop();
// for (int k = 0; k < 4; ++k) {
// int nx = x + dx[k];
// int ny = y + dy[k];
// if (0 <= nx && nx < n && 0 <= ny && ny < n && dis[nx][ny] == -1 && s[nx][ny] == '.') {
// q.emplace(nx, ny);
// dis[nx][ny] = dis[x][y] + 1;
// }
// }
// while (1) {
// int p = find(x * (n + 1) + y);
// int nx = p / (n + 1), ny = p % (n + 1);
// if (nx == n || ny == n || nx + ny > x + y + k)
// break;
// if (dis[nx][ny] == -1 && s[nx][ny] == '.') {
// q.emplace(nx, ny);
// dis[nx][ny] = dis[x][y] + 1;
// }
// f[nx * (n + 1) + ny] = (ny + 1) * (n + 1) + nx;
// }
// }
// cout << dis[n - 1][n - 1] << '\n';
// }
signed main() {
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int n, k; cin >> n >> k;
vector<string> s(n);
for (int i = 0; i < n; ++i) cin >> s[i];
vector dis(n, vector<int>(n, -1));
queue<pair<int, int>> q;
q.emplace(0, 0);
dis[0][0] = 0;
iota(f, f + (n + 1) * (n + 1), 0);
while (!q.empty()) {
auto [x, y] = q.front();
q.pop();
for (int k = 0; k < 4; ++k) {
int nx = x + dx[k];
int ny = y + dy[k];
if (0 <= nx && nx < n && 0 <= ny && ny < n && dis[nx][ny] == -1 && s[nx][ny] == '.') {
q.emplace(nx, ny);
dis[nx][ny] = dis[x][y] + 1;
}
}
while (1) {
int p = find(x * (n + 1) + y);
int nx = p / (n + 1), ny = p % (n + 1);
if (nx == n || ny == n || nx + ny > x + y + k)
break;
if (dis[nx][ny] == -1 && s[nx][ny] == '.') {
q.emplace(nx, ny);
dis[nx][ny] = dis[x][y] + 1;
}
f[nx * (n + 1) + ny] = (ny + 1) * (n + 1) + nx;
}
}
cout << dis[n - 1][n - 1] << '\n';
return 0;
}#include<bits/stdc++.h>
using i64 = long long;
using namespace std;
const int dx[4] = {0, 0, -1, 1};
const int dy[4] = {-1, 1, 0, 0};
int f[5001 * 5001];
int find(int x) {
int t = x;
while (f[x] != x) {
x = f[x];
}
while (f[t] != t) {
t = f[t];
f[t] = x;
}
return x;
}
// void solve() {
// int n, k; cin >> n >> k;
// vector<string> s(n);
// for (int i = 0; i < n; ++i) cin >> s[i];
// vector dis(n, vector<int>(n, -1));
// queue<pair<int, int>> q;
// q.emplace(0, 0);
// dis[0][0] = 0;
// iota(f, f + (n + 1) * (n + 1), 0);
// while (!q.empty()) {
// auto [x, y] = q.front();
// q.pop();
// for (int k = 0; k < 4; ++k) {
// int nx = x + dx[k];
// int ny = y + dy[k];
// if (0 <= nx && nx < n && 0 <= ny && ny < n && dis[nx][ny] == -1 && s[nx][ny] == '.') {
// q.emplace(nx, ny);
// dis[nx][ny] = dis[x][y] + 1;
// }
// }
// while (1) {
// int p = find(x * (n + 1) + y);
// int nx = p / (n + 1), ny = p % (n + 1);
// if (nx == n || ny == n || nx + ny > x + y + k)
// break;
// if (dis[nx][ny] == -1 && s[nx][ny] == '.') {
// q.emplace(nx, ny);
// dis[nx][ny] = dis[x][y] + 1;
// }
// f[nx * (n + 1) + ny] = (ny + 1) * (n + 1) + nx;
// }
// }
// cout << dis[n - 1][n - 1] << '\n';
// }
signed main() {
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int n, k; cin >> n >> k;
vector<string> s(n);
for (int i = 0; i < n; ++i) cin >> s[i];
vector dis(n, vector<int>(n, -1));
queue<pair<int, int>> q;
q.emplace(0, 0);
dis[0][0] = 0;
iota(f, f + (n + 1) * (n + 1), 0);
while (!q.empty()) {
auto [x, y] = q.front();
q.pop();
for (int k = 0; k < 4; ++k) {
int nx = x + dx[k];
int ny = y + dy[k];
if (0 <= nx && nx < n && 0 <= ny && ny < n && dis[nx][ny] == -1 && s[nx][ny] == '.') {
q.emplace(nx, ny);
dis[nx][ny] = dis[x][y] + 1;
}
}
while (1) {
int p = find(x * (n + 1) + y);
int nx = p / (n + 1), ny = p % (n + 1);
if (nx == n || ny == n || nx + ny > x + y + k)
break;
if (dis[nx][ny] == -1 && s[nx][ny] == '.') {
q.emplace(nx, ny);
dis[nx][ny] = dis[x][y] + 1;
}
f[nx * (n + 1) + ny] = (ny + 1) * (n + 1) + nx;
}
}
cout << dis[n - 1][n - 1] << '\n';
return 0;
}
Details
answer.code:97:2: error: stray ‘#’ in program 97 | }#include<bits/stdc++.h> | ^ answer.code:97:11: error: ‘bits’ was not declared in this scope 97 | }#include<bits/stdc++.h> | ^~~~ answer.code:97:16: error: ‘stdc’ was not declared in this scope; did you mean ‘std’? 97 | }#include<bits/stdc++.h> | ^~~~ | std answer.code:97:11: error: ‘bits’ was not declared in this scope 97 | }#include<bits/stdc++.h> | ^~~~ answer.code:97:16: error: ‘stdc’ was not declared in this scope; did you mean ‘std’? 97 | }#include<bits/stdc++.h> | ^~~~ | std answer.code:97:11: error: ‘bits’ was not declared in this scope 97 | }#include<bits/stdc++.h> | ^~~~ answer.code:97:16: error: ‘stdc’ was not declared in this scope; did you mean ‘std’? 97 | }#include<bits/stdc++.h> | ^~~~ | std answer.code:97:11: error: ‘bits’ was not declared in this scope 97 | }#include<bits/stdc++.h> | ^~~~ answer.code:97:16: error: ‘stdc’ was not declared in this scope; did you mean ‘std’? 97 | }#include<bits/stdc++.h> | ^~~~ | std answer.code:97:11: error: ‘bits’ was not declared in this scope 97 | }#include<bits/stdc++.h> | ^~~~ answer.code:97:16: error: ‘stdc’ was not declared in this scope; did you mean ‘std’? 97 | }#include<bits/stdc++.h> | ^~~~ | std answer.code:97:11: error: ‘bits’ was not declared in this scope 97 | }#include<bits/stdc++.h> | ^~~~ answer.code:97:16: error: ‘stdc’ was not declared in this scope; did you mean ‘std’? 97 | }#include<bits/stdc++.h> | ^~~~ | std answer.code:97:11: error: ‘bits’ was not declared in this scope 97 | }#include<bits/stdc++.h> | ^~~~ answer.code:97:16: error: ‘stdc’ was not declared in this scope; did you mean ‘std’? 97 | }#include<bits/stdc++.h> | ^~~~ | std answer.code:97:11: error: ‘bits’ was not declared in this scope 97 | }#include<bits/stdc++.h> | ^~~~ answer.code:97:16: error: ‘stdc’ was not declared in this scope; did you mean ‘std’? 97 | }#include<bits/stdc++.h> | ^~~~ | std answer.code:97:11: error: ‘bits’ was not declared in this scope 97 | }#include<bits/stdc++.h> | ^~~~ answer.code:97:16: error: ‘stdc’ was not declared in this scope; did you mean ‘std’? 97 | }#include<bits/stdc++.h> | ^~~~ | std answer.code:97:3: error: ‘include’ does not name a type 97 | }#include<bits/stdc++.h> | ^~~~~~~ answer.code:101:11: error: redefinition of ‘const int dx [4]’ 101 | const int dx[4] = {0, 0, -1, 1}; | ^~ answer.code:5:11: note: ‘const int dx [4]’ previously defined here 5 | const int dx[4] = {0, 0, -1, 1}; | ^~ answer.code:102:11: error: redefinition of ‘const int dy [4]’ 102 | const int dy[4] = {-1, 1, 0, 0}; | ^~ answer.code:6:11: note: ‘const int dy [4]’ previously defined here 6 | const int dy[4] = {-1, 1, 0, 0}; | ^~ answer.code:104:5: error: redefinition of ‘int f [25010001]’ 104 | int f[5001 * 5001]; | ^ answer.code:8:5: note: ‘int f [25010001]’ previously declared here 8 | int f[5001 * 5001]; | ^ answer.code:106:5: error: redefinition of ‘int find(int)’ 106 | int find(int x) { | ^~~~ answer.code:10:5: note: ‘int find(int)’ previously defined here 10 | int find(int x) { | ^~~~ answer.code:155:8: error: redefinition of ‘int main()’ 155 | signed main() { | ^~~~ answer.code:59:8: note: ‘int main()’ previously defined here 59 | signed main() { | ^~~~