QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#883343 | #8328. A Good Problem | arashMLG# | WA | 0ms | 3584kb | C++20 | 1.3kb | 2025-02-05 15:58:01 | 2025-02-05 15:58:02 |
Judging History
answer
#include<bits/stdc++.h>
#ifdef LOCAL
#include "Essentials/algo/debug.h"
#else
#define debug(...) 69
#define debugArr(...) 69
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int MXN = 1003;
const ll inf = 1e18;
#define F first
#define S second
#define pb push_back
#define kill(x) cout<<x<<endl, exit(0);
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define lc (v << 1)
#define rc ((v<<1) |1)
int n, b[MXN];
pii a[MXN];
vector<pii> ans;
void solve(int l=1, int r=n+1) {
if(r-l<=0) return;
int mid = (l+r)>>1;
if(r-l==1) {
while(b[l]<a[l].F) {
ans.pb(pii(2, a[l].S));
b[l]++;
}
return;
}
for(int i=mid; i<r; i++) {
ans.pb(pii(2, a[i].S));
b[i]++;
}
while(b[mid]<a[mid].F) {
ans.pb(pii(1, b[mid]));
for(int i=mid; i<r; i++) b[i]++;
}
solve(mid, r);
solve(l, mid);
}
int32_t main() {
cin.tie(nullptr)->sync_with_stdio(false);
cin >> n;
for(int i=1; i<=n; i++) cin >> a[i].F, a[i].S = i;
sort(a+1, a+n+1);
solve();
assert(sz(ans)<=20000);
cout << sz(ans) << '\n';
for(auto i : ans) cout << i.F << ' ' << i.S << '\n';
return 0;
}
// Jumpsuit, Jumpsuit cover me!
// Jumpsuit, Jumpsuit cover me!
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3584kb
input:
4 2 4 3 1
output:
8 2 3 2 2 1 1 1 2 2 2 2 1 1 1 2 4
result:
ok Correct!
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3584kb
input:
10 4 3 7 3 6 6 10 0 10 9
output:
31 2 6 2 3 2 10 2 7 2 9 1 1 1 2 1 3 1 4 1 5 2 10 2 7 2 9 1 7 1 8 2 7 2 9 2 9 2 3 2 4 2 1 2 5 1 1 1 2 2 1 2 5 2 5 1 5 2 2 1 1 1 2
result:
wrong answer a[9]!=b[9]!