QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#507101 | #9156. 百万富翁 | 251Sec | 15 | 656ms | 103928kb | C++14 | 5.8kb | 2024-08-06 10:52:24 | 2024-08-06 10:52:25 |
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<int> VVVVV1, VVVVV2, VVVVV3;
li a[2010][2010];
vector<li> RESSSST, RESSSST2;
std::map<pair<li, li>, li> mp;
int richest(li n, li t, li s){
// FILE *out = fopen("www.ww", "w");
// cout << n << " " << t << " " << s << endl;
VVVVV1.clear(), VVVVV2.clear(), VVVVV3.clear(), RESSSST2.clear(), RESSSST.clear(), mp.clear();
memset(a, 0, sizeof a);
if(t == 1){
VVVVV1.clear(), VVVVV2.clear();
for(li i = 1; i <= n; i++){
for(li j = i + 1; j <= n; j++){
VVVVV1.push_back(i - 1);
VVVVV2.push_back(j - 1);
}
}
VVVVV3 = ask(VVVVV1, VVVVV2);
li now = 0;
for(li i = 1; i <= n; i++){
for(li j = i + 1; j <= n; j++){
if(VVVVV3[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", VVVVV1[now], VVVVV2[now], VVVVV3[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();
// fprintf(out, "?"); fflush(out);
RESSSST.clear();
li cnt = 0;
for(li i = 0; i < n; i++) RESSSST.push_back(i);
for(li i = 1; i <= 12; i++){
// if(i == 10 || i == 12) continue;
if(i == 11 || i == 9 || i == 7) mp.clear();
VVVVV1.clear(), VVVVV2.clear();
// fprintf(out, "i = %d, size = %d\n", i, (li)RESSSST.size());
for(li j = 0; j < (li)RESSSST.size(); j += 2){
if(j + 1 < (li)RESSSST.size()){
if(i == 12 || i == 10 || i == 8 || i == 6){
RESSSST2.push_back(VVVVV3[mp[{RESSSST[j], RESSSST[j + 1]}]]);
// fprintf(out, "winner %d %d = %d(%d)\n", RESSSST[j], RESSSST[j + 1], mp[{RESSSST[j], RESSSST[j + 1]}], VVVVV3[mp[{RESSSST[j], RESSSST[j + 1]}]]);
} else{
VVVVV1.push_back(RESSSST[j]), VVVVV2.push_back(RESSSST[j + 1]);
}
}
}
if(i == 11 || i == 9 || i == 7 || i == 5){
// fprintf(out, "%d %d\n",(li) RESSSST.size(), cnt + (li)VVVVV1.size());
for(li j = 0; j < (li)RESSSST.size(); j += 4){
// fprintf(out, "RESSSST %d = %d\n", 0 + j, RESSSST[0 + j]);
// fprintf(out, "RESSSST %d = %d\n", 1 + j, RESSSST[1 + j]);
// fprintf(out, "RESSSST %d = %d\n", 2 + j, RESSSST[2 + j]);
// fprintf(out, "RESSSST %d = %d\n", 3 + j, RESSSST[3 + j]);
if(j + 2 < (li)RESSSST.size()){
VVVVV1.push_back(RESSSST[j]), VVVVV2.push_back((RESSSST[j + 2]));
mp[{RESSSST[j], RESSSST[j + 2]}] = VVVVV1.size() - 1;
// fprintf(out, "mp %d %d = %d\n", RESSSST[j], RESSSST[j + 2], mp[{RESSSST[j], RESSSST[j + 2]}]);
VVVVV1.push_back(RESSSST[j + 1]), VVVVV2.push_back((RESSSST[j + 2]));
mp[{RESSSST[j + 1], RESSSST[j + 2]}] = VVVVV1.size() - 1;
// fprintf(out, "mp %d %d = %d\n", RESSSST[j + 1], RESSSST[j + 2], mp[{RESSSST[j + 1], RESSSST[j + 2]}]);
if(j + 3 < (li)RESSSST.size()){
VVVVV1.push_back(RESSSST[j]), VVVVV2.push_back((RESSSST[j + 3]));
mp[{RESSSST[j], RESSSST[j + 3]}] = VVVVV1.size() - 1;
// fprintf(out, "mp %d %d = %d\n", RESSSST[j], RESSSST[j + 3], mp[{RESSSST[j], RESSSST[j + 3]}]);
VVVVV1.push_back(RESSSST[j + 1]), VVVVV2.push_back((RESSSST[j + 3]));
mp[{RESSSST[j + 1], RESSSST[j + 3]}] = VVVVV1.size() - 1;
// fprintf(out, "mp %d %d = %d\n", RESSSST[j + 1], RESSSST[j + 3], mp[{RESSSST[j + 1], RESSSST[j + 3]}]);
}
}
}
// fprintf(out, "%d %d\n",(li) RESSSST.size(), cnt + (li)VVVVV1.size());
}
// fprintf(out, "%d %d\n", (li)VVVVV1.size(), (li)VVVVV2.size()); fflush(out);
if(i != 12 && i != 10 && i != 8 && i != 6) VVVVV3 = ask(VVVVV1, VVVVV2);
if(i != 12 && i != 10 && i != 8 && i != 6) cnt += VVVVV3.size();
li now = 0;
if(i != 12 && i != 10 && i != 8 && i != 6) for(li j = 0; j < (li)RESSSST.size(); j += 2){
if(j + 1 < (li)RESSSST.size()){
RESSSST2.push_back((VVVVV3[now]));
now++;
} else{
RESSSST2.push_back(RESSSST[j]);
}
}
VVVVV1.clear(), VVVVV2.clear();
RESSSST = RESSSST2;
// fprintf(out, "%d %d\n", (li)RESSSST.size(), cnt); fflush(out);
RESSSST2.clear();
}
// fprintf(out, "%d\n", (li)RESSSST.size()); fflush(out);
for(li i = 0; i < (li)RESSSST.size(); i++){
for(li j = i + 1; j < (li)RESSSST.size(); j++){
VVVVV1.push_back(RESSSST[i]), VVVVV2.push_back((RESSSST[j]));
}
}
VVVVV3 = ask(VVVVV1, VVVVV2);
li now = 0;
li nn = RESSSST.size();
for(li i = 0; i < nn; i++){
for(li j = i + 1; j < nn; j++){
a[i][j] = 0;
if(VVVVV3[now] == RESSSST[i]) a[i][j] = 1;
now++;
a[j][i] = !a[i][j];
}
a[i][i] = 1;
}
for(li i = 0; i < nn; i++){
li cnt = 0;
for(li j = 0; j < nn; j++){
cnt += a[i][j];
}
if(cnt == nn) return RESSSST[i];
}
VVVVV1.clear(), VVVVV2.clear();
assert(0 > 1);
return 1;
}
//int main(){
// // freopen("wonderful.ans", "r", stdin);
// // freopen("www.ww", "w", stdout);
//
// return 0;
//}
详细
Pretests
Pretest #1:
score: 15
Accepted
time: 656ms
memory: 40332kb
input:
1000 1 499500 957319859
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Pretest #2:
score: 0
Wrong Answer
time: 224ms
memory: 103680kb
input:
1000000 20 2000000 29091473
output:
Wrong answer 4459638610240858557 0.000000 6906350380861515327
result:
points 0.0 Wrong answer
Final Tests
Test #1:
score: 15
Accepted
time: 646ms
memory: 38992kb
input:
1000 1 499500 957319857
output:
Correct 7127326332295218295 1.000000 1331569654267968081
result:
points 1.0 Correct
Test #2:
score: 0
Wrong Answer
time: 213ms
memory: 103928kb
input:
1000000 20 2000000 29091471
output:
Wrong answer 4459638610240858557 0.000000 6906350380861515327
result:
points 0.0 Wrong answer