QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#375413#4088. 총 쏘기tuanlinh1230 0ms3796kbC++202.4kb2024-04-03 10:23:102024-04-03 10:23:11

Judging History

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

  • [2024-04-03 10:23:11]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:3796kb
  • [2024-04-03 10:23:10]
  • 提交

answer

#include<bits/stdc++.h>
#define ll int
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ld long double
#define sz(a) ((ll)(a).size())
using namespace std;

const ll inf=1e9;
vector<pair<int, int>> min_shooting_buildings(vector<int> a)
{
    ll n=sz(a);
    vector <pll> p;
    vector <ll> ok, pos(n+1, 0);
    for (ll i=0; i<n; i++) pos[a[i]]=i;
    for (ll i=0; i<n; i++)
    {
        ll Max=0;
        for (ll j:ok)
            if (j<=a[i])
                Max=max(Max, j);
        if (Max)
        {
            p.pb({Max, a[i]});
            for (ll& j:ok)
                if (j==Max)
                {
                    swap(j, ok.back()), ok.pop_back();
                    break;
                }
            continue;
        }
        pair<int, int> Min={inf, 0};
        for (pll j:p)
            if (j.se<=a[i])
                Min=min(Min, j);
        if (Min.se)
        {
            p.pb({Min.se, a[i]}), ok.pb(Min.fi);
            for (pll& j:p)
                if (j==Min)
                {
                    swap(j, p.back()), p.pop_back();
                    break;
                }
        }
        else ok.pb(a[i]);
    }
    vector <pll> ans;
    for (pll& i:p) i={pos[i.fi], pos[i.se]}; 
    for (ll i:ok) p.pb({pos[i], pos[i]});
    sort(p.begin(), p.end());
    for (ll i=0; i<sz(p); i++)
        for (ll j=0; j<i; j++)
        {
            if (p[j].fi<p[i].fi && p[i].se<p[j].se)
            {
                if (a[p[i].se]>a[p[j].fi] && a[p[j].se]>a[p[i].fi])
                    swap(p[i].se, p[j].se);
            }
            else
            {
                if (a[p[j].se]>a[p[i].fi] && a[p[i].se]>a[p[j].fi])
                    swap(p[i].se, p[j].se);
            }
        }
    vector <bool> check(sz(p), 0);
    for (ll i=0; i<sz(p); i++)
    {
        for (ll j=0; j<sz(p); j++)
        {
            if (check[j]) continue;
            auto [p1, p2]=p[j];
            bool ok=1;
            for (ll k=0; k<p1; k++)
                if (a[k]>a[p1]) ok=0;
            for (ll k=0; k<p2; k++)
                if (a[k]>a[p2]) ok=0;
            if (ok)
            {
                ans.pb({a[p[j].fi], a[p[j].se]}), check[j]=1, a[p1]=a[p2]=0;
                break;
            }
        }
    }
    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: 0ms
memory: 3768kb

input:

8
4 3 8 2 1 7 6 5

output:

0

result:

wrong answer Integer parameter [name=m] equals to 0, violates the range [1, 8]

Subtask #2:

score: 0
Wrong Answer

Test #26:

score: 12
Accepted
time: 0ms
memory: 3788kb

input:

8
5 6 7 1 2 8 3 4

output:

4
5 7
6 8
1 3
2 4

result:

ok Correct

Test #27:

score: -12
Wrong Answer
time: 0ms
memory: 3792kb

input:

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

output:

6
10 14
9 12
2 6
4 8
7 16
11 15

result:

wrong answer Incorrect

Subtask #3:

score: 0
Wrong Answer

Test #51:

score: 9
Accepted
time: 0ms
memory: 3772kb

input:

1
1

output:

1
1 1

result:

ok Correct

Test #52:

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

input:

2
1 2

output:

1
1 2

result:

ok Correct

Test #53:

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

input:

2
2 1

output:

2
2 2
1 1

result:

ok Correct

Test #54:

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

input:

3
1 3 2

output:

0

result:

wrong answer Integer parameter [name=m] equals to 0, violates the range [1, 3]

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%