QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#375786 | #4088. 총 쏘기 | hotboy2703 | 0 | 1ms | 4868kb | C++14 | 2.0kb | 2024-04-03 15:51:18 | 2024-04-03 15:51:18 |
answer
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
#define pll pair <ll,ll>
#define fi first
#define se second
#define sz(a) (ll((a).size()))
#define BIT(mask,i) (((mask) >> (i))&1)
#define MASK(i) (1LL << (i))
#define MP make_pair
namespace{
const ll MAXN = 1e5;
ll n;
ll a[MAXN+100];
ll b[MAXN+100];
ll rev[MAXN+100];
vector <pair <int,int> > ans;
void solve(){
set <ll> s;
for (ll i = 1;i <= n;i ++)s.insert(i);
for (ll i = 1;i <= n;i ++){b[i] = n + 1 - a[i];rev[b[i]] = i;}
vector <ll> lds;
ll inv[MAXN+100];
while (sz(s)){
vector <pll> tr;
for (auto x:s){
for (auto y:s){
if (x < y && a[x] < a[y]){
tr.push_back({x,y});
}
}
}
pll best;
ll cur_best = -1;
ll single=*s.begin();
for (auto i:s){
inv[i] = 0;
for (auto j:s){
ll l = min(i,j),r = max(i,j);
if (a[l] > a[r])inv[i]++;
}
}
for (auto x:tr){
ll sus = inv[x.fi] + inv[x.se] - (a[x.fi] > a[x.se]);
if (sus > cur_best){
cur_best = sus;
best = x;
}
}
for (auto x:s){
if (inv[x] > inv[single])single = x;
}
if (cur_best != -1){
s.erase(best.fi);
s.erase(best.se);
ans.push_back(MP(a[best.fi],a[best.se]));
}
else{
s.erase(single);
ans.push_back(MP(a[single],n+1));
}
}
sort(ans.begin(),ans.end());
}
}
std::vector<std::pair<int, int>> min_shooting_buildings(std::vector<int> H){
n = sz(H);
for (ll i = 1;i <= n;i ++)a[i] = H[i-1];
solve();
return ans;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 4608kb
input:
8 4 3 8 2 1 7 6 5
output:
4 1 5 2 6 3 7 4 8
result:
wrong answer Incorrect
Subtask #2:
score: 0
Wrong Answer
Test #26:
score: 0
Wrong Answer
time: 0ms
memory: 4576kb
input:
8 5 6 7 1 2 8 3 4
output:
4 1 2 3 4 5 6 7 8
result:
wrong answer Incorrect
Subtask #3:
score: 0
Wrong Answer
Test #51:
score: 9
Accepted
time: 1ms
memory: 4556kb
input:
1 1
output:
1 1 2
result:
ok Correct
Test #52:
score: 0
Accepted
time: 1ms
memory: 4868kb
input:
2 1 2
output:
1 1 2
result:
ok Correct
Test #53:
score: -9
Wrong Answer
time: 1ms
memory: 4604kb
input:
2 2 1
output:
2 1 3 2 3
result:
wrong answer Incorrect
Subtask #4:
score: 0
Skipped
Dependency #3:
0%
Subtask #5:
score: 0
Skipped
Dependency #4:
0%
Subtask #6:
score: 0
Skipped
Dependency #5:
0%
Subtask #7:
score: 0
Skipped
Dependency #1:
0%