QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#507545 | #9156. 百万富翁 | juruoA | 15 | 1473ms | 119768kb | C++14 | 3.0kb | 2024-08-06 19:11:17 | 2024-08-06 19:11:17 |
Judging History
answer
#include <bits/stdc++.h>
#include "richest.h"
using std::bitset;
using std::cout;
using std::deque;
using std::endl;
using std::greater;
using std::lower_bound;
using std::make_pair;
using std::map;
using std::max;
using std::min;
using std::multimap;
using std::multiset;
using std::nth_element;
using std::pair;
using std::priority_queue;
using std::queue;
using std::reverse;
using std::set;
using std::sort;
using std::sqrt;
using std::stable_sort;
using std::string;
using std::swap;
using std::unique;
using std::upper_bound;
using std::vector;
typedef int li;
typedef long double lf;
inline li read(){
li ans = 0, f = 1;
char ch = getchar();
while(ch < '0' || ch > '9'){
f = (ch == '-') ? -1 : 1;
ch = getchar();
}
while(ch <= '9' && ch >= '0'){
ans = ans * 10 + (ch ^ 48);
ch = getchar();
}
return ans * f;
}
vector<li> v1, v2, v3, rest, rest2;
std::unordered_map<li, li> a[1000010], mpclear;
map<pair<li, li>, li> mp;
li x[] = {2, 2, 2, 2, 3, 6, 19, 183};
li richest(li n, li t, li s){
// FILE *out = fopen("www.ww", "w");
for(li i = 0; i < n; i++) a[i] = mpclear;
if(t == 1){
v1.clear(), v2.clear();
for(li i = 1; i <= n; i++){
for(li j = i + 1; j <= n; j++){
v1.push_back(i - 1);
v2.push_back(j - 1);
}
}
v3 = ask(v1, v2);
li now = 0;
for(li i = 1; i <= n; i++){
for(li j = i + 1; j <= n; j++){
if(v3[now] + 1 == i) a[i][j] = 1;
else a[i][j] = 0;
a[j][i] = !a[i][j];
// fprintf(out, "%d %d %d %d\n", v1[now], v2[now], v3[now] + 1, a[i][j]);
now++;
}
a[i][i] = 1;
}
for(li i = 1; i <= n; i++){
li cnt = 0;
for(li j = 1; j <= n; ++j) cnt += a[i][j];
// fprintf(out, "cnt %d = %d\n", i, cnt);
if(cnt == n){
// fclose(out);
return i - 1;
}
}
}
mp.clear();
for(li i = 0; i < n; i++) rest.push_back(i);
for(li i = 0; i <= 7; i++){
// fprintf(out, "i = %d\n", i); fflush(out);
rest2.clear();
li nn = rest.size();
for(li j = 0; j < nn; j += x[i]){
li r = j + x[i] - 1;
r = min(r, nn - 1);
for(li p = j; p <= r; p++){
for(li q = p + 1; q <= r; q++){
v1.push_back(rest[p]), v2.push_back(rest[q]);
mp[{rest[p], rest[q]}] = v1.size() - 1;
}
}
}
v3 = ask(v1, v2);
for(li j = 0; j < nn; j += x[i]){
li r = j + x[i] - 1;
r = min(r, nn - 1);
for(li p = j; p <= r; p++){
a[rest[p]][rest[p]] = 1;
for(li q = p + 1; q <= r; q++){
a[rest[p]][rest[q]] = 0;
if(v3[mp[{rest[p], rest[q]}]] == rest[p]) a[rest[p]][rest[q]] = 1;
a[rest[q]][rest[p]] = !a[rest[p]][rest[q]];
// v1.push_back(rest[p]), v2.push_back(rest[q]);
// mp[{rest[p], rest[q]}] = v1.size() - 1;
}
}
for(li p = j; p <= r; p++){
li cnt = 0;
for(li q = j; q <= r; q++) cnt += a[rest[p]][rest[q]];
if(cnt == r - j + 1) rest2.push_back(rest[p]);
}
}
rest = rest2;
rest2.clear();
v1.clear(), v2.clear();
}
return rest[0];
}
详细
Pretests
Pretest #1:
score: 15
Accepted
time: 1473ms
memory: 119032kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 0
Time Limit Exceeded
input:
1000000 20 2000000 29091473
output:
Unauthorized output
result:
Final Tests
Test #1:
score: 15
Accepted
time: 1454ms
memory: 119768kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 0
Time Limit Exceeded
input:
1000000 20 2000000 29091471
output:
Unauthorized output