QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#713385 | #8333. Gift | wowowwo# | WA | 0ms | 3796kb | C++23 | 1.6kb | 2024-11-05 19:11:52 | 2024-11-05 19:11:53 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
struct node{
int x;
int y;
}num[1000010];
bool cmp(node a,node b){
return a.x>b.x;
}
struct op{
int ope;
int x;
};
vector<op> st;
void slove(){
int n;
int temp=0;
scanf("%d",&n);
for(int i=1;i<=n;i++){
int x;
scanf("%d",&x);
if(x==0) temp++;
num[i].x=x;
num[i].y=i;
}
sort(num+1,num+n+1,cmp);
n-=temp;
int x=(int)sqrt(n);
int j=0;
int ans=0;
while(j+x<n){
for(int i=j+1;i<=j+x;i++){
st.push_back({2,num[i].y});
ans++;
// printf("2 %d\n",num[i].y);
}
int len=num[j+x].x-1;
for(int i=1;i<=len;i++){
st.push_back({1,i});
ans++;
}
for(int i=j+1;i<=j+x;i++){
for(int q=num[j+x].x;q<num[i].x;q++){
st.push_back({2,num[i].y});
ans++;
}
}
j+=x;
}
for(int i=j+1;i<=n;i++){
st.push_back({2,num[i].y});
ans++;
}
int len=num[n].x-1;
for(int i=1;i<=len;i++){
st.push_back({1,i});
ans++;
}
for(int i=j+1;i<=n;i++){
for(int q=num[n].x;q<num[i].x;q++){
st.push_back({2,num[i].y});
ans++;
}
}
printf("%d\n",ans);
for(int i=0;i<ans;i++){
printf("%d %d\n",st[i].ope,st[i].x);
}
return ;
}
int main(){
int T=1;
// scanf("%d",&T);
while(T--) slove();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3796kb
input:
6 1 2 1 3 1 4 1 5 1 6 2 3
output:
10 2 6 2 4 1 1 1 2 2 6 2 2 2 1 2 2 2 3 2 5
result:
wrong answer Output contains longer sequence [length = 21], but answer contains 1 elements