QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#115930 | #5301. Modulo Ruins the Legend | PetroTarnavskyi# | WA | 27ms | 5076kb | C++17 | 2.1kb | 2023-06-27 18:51:28 | 2023-06-27 18:51:29 |
Judging History
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 solve(int realN, VI a, VI sz)
{
int n = SZ(a);
if (SZ(a) <= 7)
{
while (m[a] != 0)
{
PII p = op[a];
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;
}
return;
}
RFOR (i, n - 2, n - 5)
{
if (a[i] == realN) continue;
FOR (j, 0, i)
{
if (a[j] == a[i] + 1)
{
//
}
}
}
}
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(n, a, sz);
cout << SZ(oper) << '\n';
FOR (i, 0, SZ(oper))
{
cout << oper[i].first << ' ' << oper[i].second << '\n';
}
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 27ms
memory: 5076kb
input:
6 24 1 1 4 5 1 4
output:
0 0 0 0 0 0
result:
wrong answer Result not equal to solution.