ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#199 | #6. 「WyOJ Round 1」持 · 山海为肩 | __vector__ | 0 | 37ms | 5684kb | C++23 | 1.3kb | 2025-04-18 08:08:16 | 2025-04-18 13:17:48 |
answer
#include<iostream>
#include<vector>
#include<set>
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
using namespace std;
const int N=1e6+10;
int n,sum,res,a[N],b[N];
set <int> sa;
set <pii> sb;
vector <pii> rv;
bool check(int x,int y)
{
sb.erase({a[x],x}),sb.insert({a[x]-1,x});
if(y!=x) sb.erase({a[y],y}),sb.insert({a[y]-1,y});
bool rf=(max((*prev(sb.end())).fi,(sum-(x!=y))/2)<=res-1);
sb.erase({a[x]-1,x}),sb.insert({a[x],x});
if(y!=x) sb.erase({a[y]-1,y}),sb.insert({a[y],y});
return rf;
}
void del(int x,int y)
{
res--,sum-=((x!=y)+1),rv.pb({x,y}),sb.erase({a[x],x}),a[x]--;
if(a[x]) sb.insert({a[x],x});
else sa.erase(x);
if(y!=x)
{
sb.erase({a[y],y}),a[y]--;
if(a[y]) sb.insert({a[y],y});
else sa.erase(y);
}
}
int main()
{
ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i],sum+=a[i];
if(a[i]) sa.insert(i),sb.insert({a[i],i});
}
res=max((*prev(sb.end())).fi,(sum+1)/2),cout<<res<<'\n';
while(sa.size())
{
auto it=sa.begin(); int x=*it,y;
if(check(x,x)) {del(x,x); continue;}
y=*next(it);
if(check(x,y)) {del(x,y); continue;}
del(x,(*prev(sb.end())).se);
}
for(pii te:rv) cout<<te.fi<<' '<<te.se<<'\n';
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5408kb
input:
841 5 0.002262 paper rock rock scissors scissors 0.000665 rock paper paper scissors paper 0.001132 s...
output:
5 1 1 1 1 1 1 1 1 1 1
result:
wrong answer 1st words differ - expected: '0.689135', found: '5'
Test #2:
score: 0
Wrong Answer
time: 4ms
memory: 5684kb
input:
320 1 0.001734 rock 0.000432 rock 0.003306 scissors 0.000322 paper 0.000380 rock 0.000817 scissors 0...
output:
1 1 1
result:
wrong answer 1st words differ - expected: '0.728099', found: '1'
Test #3:
score: 0
Wrong Answer
time: 4ms
memory: 5264kb
input:
19 2 0.086520 scissors rock 0.028985 rock rock 0.056406 rock scissors 0.010732 scissors rock 0.04471...
output:
2 1 1 1 1
result:
wrong answer 1st words differ - expected: '0.836348', found: '2'
Test #4:
score: 0
Wrong Answer
time: 7ms
memory: 5336kb
input:
100000 12 0.000008 rock rock rock scissors paper scissors paper paper paper scissors paper scissors ...
output:
12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
result:
wrong answer 1st words differ - expected: '0.578764', found: '12'
Test #5:
score: 0
Wrong Answer
time: 3ms
memory: 5612kb
input:
82918 11 0.000009 paper rock rock scissors scissors paper rock paper rock rock paper 0.000000 scisso...
output:
11 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
result:
wrong answer 1st words differ - expected: '0.582727', found: '11'
Test #6:
score: 0
Wrong Answer
time: 6ms
memory: 5416kb
input:
63157 10 0.000004 rock scissors paper scissors paper scissors rock paper rock scissors 0.000007 rock...
output:
10 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
result:
wrong answer 1st words differ - expected: '0.587712', found: '10'
Test #7:
score: 0
Wrong Answer
time: 3ms
memory: 5608kb
input:
100000 12 0.000003 rock rock rock paper paper rock paper paper paper rock rock scissors 0.000001 pap...
output:
12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
result:
wrong answer 1st words differ - expected: '0.578665', found: '12'
Test #8:
score: 0
Wrong Answer
time: 3ms
memory: 5476kb
input:
72055 11 0.000006 rock scissors scissors rock scissors scissors scissors scissors rock scissors scis...
output:
11 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
result:
wrong answer 1st words differ - expected: '0.584229', found: '11'
Test #9:
score: 0
Wrong Answer
time: 2ms
memory: 5684kb
input:
49463 12 0.000024 rock paper scissors paper rock scissors rock paper paper paper paper paper 0.00000...
output:
12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
result:
wrong answer 1st words differ - expected: '0.584658', found: '12'
Test #10:
score: 0
Wrong Answer
time: 4ms
memory: 5412kb
input:
100000 12 0.000007 rock paper scissors paper paper scissors rock rock scissors rock scissors paper 0...
output:
12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
result:
wrong answer 1st words differ - expected: '0.578092', found: '12'