QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#224994 | #2897. Circle Bounce | PetroTarnavskyi# | Compile Error | / | / | C++17 | 4.1kb | 2023-10-23 20:11:27 | 2023-10-23 20:11:28 |
Judging History
This is the latest submission verdict.
- [2023-10-23 20:11:28]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2023-10-23 20:11:27]
- Submitted
answer
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;
const int N = 8;
map<pair<VI, VI>, tuple<char, VI, VI>> dp[N + 1][N + 2];
map<VI, VI> normDP;
VI norm(VI a)
{
if (normDP.count(a))
return normDP[a];
VI b(SZ(a), -1);
int c = 0;
FOR(i, 0, SZ(a))
{
if (b[i] == -1)
continue;
FOR(j, i, SZ(a))
if (a[i] == a[j])
b[i] = c;
c++;
}
return normDP[a] = b;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout << fixed << setprecision(15);
int n;
cin >> n;
vector<string> v(n + 1);
FOR (i, 0, n + 1)
cin >> v[i];
VI initComp(n + 2), initCnt(n + 2, -1);
iota(ALL(initComp), 0);
if (v[1][0] != '+')
initCnt[0] = v[1][0] - '0';
FOR(i, 0, n + 1)
if (v[0][i] != '+')
initCnt[i + 1] = v[0][i] - '0';
dp[0][0][{initComp, VI(n + 2, -1)}] = {' ', {}, {}};
VI curComp, curCnt;
FOR(i, 0, n + 1)
{
FOR(j, 0, n)
{
char ch = v[i][j + 1];
for (const auto& [x, y] : dp[i][j])
{
const auto& [comp, cnt] = x;
if ((cnt[j + 1] == 0 || cnt[j + 1] == -1) && (cnt[j] > 0 || cnt[j] == -1) && (cnt[j + 2] > 0 && cnt[j + 2] == -1))
{
VI ncomp = comp, ncnt = cnt;
FOR(k, 0, n + 2)
{
if (comp[k] == comp[j + 2])
{
ncomp[k] = comp[j];
}
}
if (cnt[j] != -1)
ncnt[j]--;
if (cnt[j + 2] != -1)
ncnt[j + 2]--;
ncnt[j + 1] = ch == '+' ? -1 : ch - '0';
dp[i][j + 1][{norm(ncomp), ncnt}] = {'/', comp, cnt};
}
if (cnt[j + 1] == 1 || cnt[j + 1] == -1)
{
VI ncnt = cnt;
ncnt[j + 1] = ch == '+' ? -1 : ch - '1';
dp[i][j + 1][{comp, ncnt}] = {'\\', comp, cnt};
}
}
}
for (const auto& [x, y] : dp[i][n])
{
const auto& [comp, cnt] = x;
if (cnt.back() != 0 && cnt.back() != -1)
continue;
if (i == n)
{
curComp = comp;
curCnt = cnt;
break;
}
VI ncomp(n + 2), ncnt(n + 2);
RFOR(k, n + 2, 1)
{
ncomp[k] = comp[k - 1];
ncnt[k] = cnt[k - 1];
}
ncomp[0] = 47;
ncnt[0] = v[i + 1][0] == '+' ? -1 : v[i + 1][0] - '0';
dp[i + 1][0][{norm(ncomp), ncnt}] = {' ', comp, cnt};
}
}
FOR(i, 0, n + 1)
{
FOR(j, 0, n + 1)
{
cout << "i = " << i << ", j = " << j << endl;
for (auto [x, y] : dp[i][j])
{
const auto& [comp, cnt] = x;
cout << "comp\n";
FOR(k, 0, n + 2)
cout << comp[k] << " ";
cout << "\ncnt\n";
FOR(k, 0, n + 2)
cout << cnt[k] << " ";
cout << "\n";
}
}
}
return 0;
assert(SZ(curComp) == n + 2 && SZ(curCnt) == n + 2);
vector<string> ans(n, string(n, ' '));
RFOR(i, n + 1, 1)
{
RFOR(j, n + 1, 0)
{
auto [c, pcomp, pcnt] = dp[i][j][{curComp, curCnt}];
if (j > 0)
{
assert(c == '\\' || c == '/');
ans[i - 1][j - 1] = c;
}
curComp = pcomp;
curCnt = pcnt;
}
}
FOR(i, 0, n)
cout << ans[i] << "\n";
return 0;
}
i = 0, j = 0
comp
0 1 2 3 4 5 6
cnt
-1 -1 -1 -1 -1 -1 -1
i = 0, j = 1
comp
0 1 2 3 4 5 6
cnt
-1 0 -1 -1 -1 -1 -1
i = 0, j = 2
comp
0 1 2 3 4 5 6
cnt
-1 0 -1 -1 -1 -1 -1
i = 0, j = 3
comp
0 1 2 3 4 5 6
cnt
-1 0 -1 1 -1 -1 -1
i = 0, j = 4
comp
0 1 2 3 4 5 6
cnt
-1 0 -1 1 -1 -1 -1
i = 0, j = 5
comp
0 1 2 3 4 5 6
cnt
-1 0 -1 1 -1 -1 -1
i = 1, j = 0
comp
-1 -1 -1 -1 -1 -1 -1
cnt
1 -1 0 -1 1 -1 -1
i = 1, j = 1
comp
-1 -1 -1 -1 -1 -1 -1
cnt
1 -1 0 -1 1 -1 -1
i = 1, j = 2
i = 1, j = 3
i = 1, j = 4
i = 1, j = 5
i = 2, j = 0
i = 2, j = 1
i = 2, j = 2
i = 2, j = 3
i = 2, j = 4
i = 2, j = 5
i = 3, j = 0
i = 3, j = 1
i = 3, j = 2
i = 3, j = 3
i = 3, j = 4
i = 3, j = 5
i = 4, j = 0
i = 4, j = 1
i = 4, j = 2
i = 4, j = 3
i = 4, j = 4
i = 4, j = 5
i = 5, j = 0
i = 5, j = 1
i = 5, j = 2
i = 5, j = 3
i = 5, j = 4
i = 5, j = 5
詳細信息
answer.code:157:1: error: ‘i’ does not name a type 157 | i = 0, j = 0 | ^