QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#382133 | #5095. 九王唱 | valeriu | 0 | 2ms | 7260kb | C++20 | 2.2kb | 2024-04-08 03:24:03 | 2024-04-08 03:24:08 |
answer
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using ld = long double;
//#define int ll
#define sz(x) ((int)(x).size())
using pii = pair<int,int>;
using tii = tuple<int,int,int>;
const int nmax = 5e3 + 5;
int atrc[nmax][nmax];
int rez[nmax];
void gen(int n, int seed) {
if(seed != 0) {
std::mt19937 rnd(seed);
for(int i = 1; i <= n; ++i) {
for(int j = 1; j <= n + 1; ++j) {
atrc[i][j] = j;
swap(atrc[i][j], atrc[i][rnd() % j + 1]);
}
}
}
else {
for(int i = 1; i <= n; i++)
for(int j = 1; j <= n + 1; j++)
cin >> atrc[i][j];
}
return;
}
queue<int> Bbypoz[nmax];
vector<int> occ;
int atrkill[nmax];
int n;
void addLine(int T) {
int mn = -1;
for(int i = 1; i <= n + 1; i++) {
if(occ[i] == 1) continue;
if(mn == -1) mn = i;
else if(atrc[T][i] < atrc[T][mn]) mn = i;
}
atrkill[T] = mn;
occ[mn] = 1;
for(int i = 1; i <= n + 1; i++)
if(occ[i] == 1 && atrc[T][i] <= atrc[T][mn]) Bbypoz[i].emplace(T);
return;
}
signed main() {
cin.tie(0) -> sync_with_stdio(0);
int seed;
cin >> n >> seed;
gen(n, seed);
occ = vector<int>(n + 2, 0);
for(int i = n; i > 0; i--) addLine(i);
for(int i = 1; i <= n + 1; i++) if(occ[i] == 0) rez[1] = i;
for(int p = n; p > 1; p--) { // putem sa nu ne prostim si sa inseram linia la final
int L = p, value = atrkill[L];
Bbypoz[value].pop();
occ[value] = 0;
while(!Bbypoz[value].empty()) {
L = Bbypoz[value].front();
Bbypoz[value].pop();
occ[value] = 1;
swap(atrkill[L], value);
occ[value] = 0;
Bbypoz[value].pop();
}
addLine(p);
for(int i = 1; i <= n + 1; i++) if(occ[i] == 0) rez[p] = i;
}
for(int i = 1; i <= n; i++) cout << rez[i] << ' ';
cout << '\n';
}
/**
* AXAXAXAXAXAXAXAXA NU TE CRED
* Adica, are sens, pt ca gen, orice chestie de jos sigur va muri ca rezultat al unei asemenea actiuni
* dar what the fuck man AXAXAXAXAAXAXAAXAXAXA
*/
详细
Subtask #1:
score: 0
Runtime Error
Test #1:
score: 8
Accepted
time: 2ms
memory: 6956kb
input:
8 0 6 1 3 2 9 7 8 4 5 6 1 3 2 9 7 8 4 5 6 1 3 2 9 7 8 4 5 6 1 3 2 9 7 8 4 5 6 1 3 2 9 7 8 4 5 6 1 3 2 9 7 8 4 5 6 1 3 2 9 7 8 4 5 6 1 3 2 9 7 8 4 5
output:
5 5 5 5 5 5 5 5
result:
ok 8 numbers
Test #2:
score: 0
Accepted
time: 2ms
memory: 6964kb
input:
8 0 4 7 8 6 1 3 2 9 5 5 8 9 7 2 4 3 1 6 6 9 1 8 3 5 4 2 7 7 1 2 9 4 6 5 3 8 8 2 3 1 5 7 6 4 9 9 3 4 2 6 8 7 5 1 1 4 5 3 7 9 8 6 2 2 5 6 4 8 1 9 7 3
output:
7 7 7 7 7 7 7 7
result:
ok 8 numbers
Test #3:
score: 0
Accepted
time: 2ms
memory: 7260kb
input:
8 0 5 2 6 8 7 9 1 3 4 4 1 5 7 6 8 9 2 3 3 9 4 6 5 7 8 1 2 2 8 3 5 4 6 7 9 1 1 7 2 4 3 5 6 8 9 9 6 1 3 2 4 5 7 8 8 5 9 2 1 3 4 6 7 7 4 8 1 9 2 3 5 6
output:
6 6 6 6 6 6 6 6
result:
ok 8 numbers
Test #4:
score: 0
Accepted
time: 2ms
memory: 7020kb
input:
8 0 2 3 9 1 5 7 6 4 8 2 3 9 1 6 8 7 4 5 2 3 9 1 4 8 6 5 7 2 3 9 1 8 4 5 6 7 2 3 9 1 8 6 7 5 4 2 3 9 1 6 4 7 8 5 2 3 9 1 4 6 5 7 8 2 3 9 1 7 8 5 6 4
output:
3 3 3 3 3 3 3 3
result:
ok 8 numbers
Test #5:
score: -8
Runtime Error
input:
7 0 8 1 5 4 7 6 3 2 8 1 5 7 2 6 4 3 8 1 5 2 7 3 4 6 8 1 5 3 6 7 2 4 8 1 5 4 6 7 2 3 8 1 5 3 7 4 2 6 8 1 5 4 3 2 6 7
output:
result:
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%