QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#115938 | #5307. Subgraph Isomorphism | PetroTarnavskyi# | Compile Error | / | / | C++17 | 2.4kb | 2023-06-27 19:12:57 | 2023-06-27 19:12:59 |
Judging History
你现在查看的是测评时间为 2023-06-27 19:12:59 的历史记录
- [2023-10-15 17:26:06]
- 管理员手动重测本题所有提交记录
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2023-06-27 19:12:59]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-06-27 19:12:57]
- 提交
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
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
map<VI, int> m;
map<VI, PII> op;
void brute(int n)
{
VI v(n);
iota(ALL(v), 1);
m[v] = 0;
queue<VI> q;
q.push(v);
while (!q.empty())
{
auto b = q.front();
q.pop();
int a = m[b];
FOR (x, 1, n - 2)
{
FOR (y, 1, n - x)
{
VI vec;
FOR (i, 0, y) vec.PB(b[n - y + i]);
FOR (i, x, n - y) vec.PB(b[i]);
FOR (i, 0, x) vec.PB(b[i]);
if (!m.count(vec))
{
m[vec] = a + 1;
op[vec] = {y, x};
q.push(vec);
}
}
}
}
}
vector<PII> oper;
void zrobyty(VI& a, VI& sz, PII p)
{
int x = 0, y = 0;
FOR (i, 0, p.first) x += sz[i];
FOR (i, 0, p.second) y += sz[SZ(a) - 1 - i];
oper.PB({x, y});
VI na, nsz;
FOR (i, 0, p.second)
{
na.PB(a[n - p.second]);
nsz.PB(sz[n - p.second]);
}
FOR (i, p.first, n - p.second)
{
na.PB(a[i]);
nsz.PB(sz[n - p.second]);
}
FOR (i, 0, p.first)
{
na.PB(a[i]);
nsz.PB(sz[n - p.second]);
}
a = na;
sz = nsz;
}
void solve(VI a, VI sz)
{
int n = SZ(a);
if (SZ(a) <= 7)
{
while (m[a] != 0)
{
PII p = op[a];
zrobyty(a, sz, p);
}
return;
}
RFOR (i, n - 2, n - 5)
{
if (a[i] == n) continue;
FOR (j, 0, i)
{
if (a[j] == a[i] + 1)
{
int k = a[j];
zrobyty(a, sz, {i + 1, 1});
zrobyty(a, sz, {n - 1 - (i - j), 1});
VI na;
FOR (i, 0, n) if (a[i] != k) na.PB(a[i]);
VI nsz;
FOR (i, 0, k) nsz.PB(sz[i]);
sz.back() += sz[k];
FOR (i, k + 1, n) nsz.PB(sz[i]);
}
}
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
for (int i = 4; i <= 7; i++) brute(i);
int t;
cin >> t;
while (t--)
{
int n;
cin >> n;
VI a(n);
FOR (i, 0, n) cin >> a[i];
if (n == 3)
{
if (a[2] < a[0])
cout << "1\n1 1\n";
else
cout << "0\n";
continue;
}
VI sz(n, 1);
solve(a, sz);
cout << SZ(oper) << '\n';
FOR (i, 0, SZ(oper))
{
cout << oper[i].first << ' ' << oper[i].second << '\n';
}
}
return 0;
}
详细
answer.code: In function ‘void zrobyty(VI&, VI&, PII)’: answer.code:63:25: error: ‘n’ was not declared in this scope 63 | na.PB(a[n - p.second]); | ^ answer.code:66:26: error: ‘n’ was not declared in this scope 66 | FOR (i, p.first, n - p.second) | ^ answer.code:6:43: note: in definition of macro ‘FOR’ 6 | #define FOR(i, a, b) for (int i = (a); i<(b); ++i) | ^ answer.code:74:27: error: ‘n’ was not declared in this scope 74 | nsz.PB(sz[n - p.second]); | ^