QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#375776#4088. 총 쏘기hotboy27030 1ms4900kbC++142.0kb2024-04-03 15:48:452024-04-03 15:48:46

Judging History

你现在查看的是最新测评结果

  • [2024-04-03 15:48:46]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:4900kb
  • [2024-04-03 15:48:45]
  • 提交

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));
            }
        }
    }
}
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;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 17
Accepted
time: 1ms
memory: 4612kb

input:

8
4 3 8 2 1 7 6 5

output:

4
4 8
3 7
2 6
1 5

result:

ok Correct

Test #2:

score: -17
Wrong Answer
time: 1ms
memory: 4576kb

input:

16
12 16 11 15 10 9 8 4 14 13 7 2 6 5 3 1

output:

10
2 3
12 16
11 15
10 14
9 13
4 7
8 17
6 17
5 17
1 17

result:

wrong answer Incorrect

Subtask #2:

score: 0
Wrong Answer

Test #26:

score: 12
Accepted
time: 1ms
memory: 4900kb

input:

8
5 6 7 1 2 8 3 4

output:

4
5 6
7 8
1 2
3 4

result:

ok Correct

Test #27:

score: -12
Wrong Answer
time: 1ms
memory: 4668kb

input:

16
2 4 5 1 9 10 3 6 14 7 8 11 12 16 13 15

output:

8
9 14
1 10
3 16
2 4
5 6
7 8
11 12
13 15

result:

wrong answer Incorrect

Subtask #3:

score: 0
Wrong Answer

Test #51:

score: 9
Accepted
time: 1ms
memory: 4616kb

input:

1
1

output:

1
1 2

result:

ok Correct

Test #52:

score: 0
Accepted
time: 1ms
memory: 4640kb

input:

2
1 2

output:

1
1 2

result:

ok Correct

Test #53:

score: 0
Accepted
time: 0ms
memory: 4612kb

input:

2
2 1

output:

2
2 3
1 3

result:

ok Correct

Test #54:

score: 0
Accepted
time: 1ms
memory: 4608kb

input:

3
1 3 2

output:

2
1 3
2 4

result:

ok Correct

Test #55:

score: 0
Accepted
time: 1ms
memory: 4620kb

input:

3
2 1 3

output:

2
2 3
1 4

result:

ok Correct

Test #56:

score: 0
Accepted
time: 1ms
memory: 4644kb

input:

3
2 3 1

output:

2
2 3
1 4

result:

ok Correct

Test #57:

score: -9
Wrong Answer
time: 0ms
memory: 4608kb

input:

3
3 1 2

output:

2
1 2
3 4

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%