QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#645020 | #8339. Rooted Tree | xiaoxiao__# | WA | 0ms | 3812kb | C++20 | 2.3kb | 2024-10-16 16:31:30 | 2024-10-16 16:31:30 |
Judging History
answer
#include<iostream>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
#include<bitset>
using namespace std;
using ll=long long;
typedef pair<int,int>pii;
#define fi first
#define se second
const int N=1e4+10;
int n,a[N],b[N];
int brr[]={61,62,124,125,187,188,218,219,249,250,312,313,343,344,374,375,437,438,468,469,499,500,562,563,625,626,688,689,719,720,750,751,813,814,844,845,875,876,938,939,969,970,1000};
int arr[]={62,60,125,123,188,186,219,217,250,248,313,311,344,342,375,373,438,436,469,467,500,498,563,561,626,624,689,687,720,718,751,749,814,812,845,843,876,874,939,937,970,968,1001};
void Silverwolf(){
cin>>n;
vector<pii>vt;
for(int i=1;i<=n;i++)cin>>b[i];
auto cal=[&](auto &&cal,int l,int r,int lst)->void{
// cout<<l<<" "<<r<<" "<<lst<<endl;
int mid=l+r>>1;
if(l==r){
if(l==lst)return;
for(int i=1;i<=n;i++){
if(b[i]==l)
{
for(int j=lst;j<l;j++)vt.push_back({2,i});
}
}
return;
}
bool flag=false;
if(lst==l)flag=true;
if(lst!=l)
{
for(int i=1;i<=n;i++)
{
if(b[i]>=l&&b[i]<=r)
{
vt.push_back({2,i});
flag=true;
}
}
}
int now=lst+1;
if(!flag)return ;
if(flag)while(now<l)vt.push_back({1,now++});
cal(cal,mid+1,r,l);
cal(cal,l,mid,l);
};
cal(cal,0,1001,0);
cout<<vt.size()<<'\n';
for(auto [x,y]:vt)
{
cout<<x<<" "<<y<<endl;
}
// int res1=0,res2=0;
// for(auto [x,y]:vt){
// if(x==1){
// res1++;
// for(int i=1;i<=n;i++){
// if(a[i]==y)a[i]++;
// }
// }else a[y]++,res2++;
// }
// for(int i=1;i<=n;i++){
// if(a[i]!=b[i])cout<<i<<' ';
// }
// for(int i=1;i<=n;i++)cout<<(a[i]==b[i])<<' ';cout<<'\n';
// cout<<res1<<' '<<res2<<'\n';
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
//int T;cin>>T;while(T--)
Silverwolf();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3812kb
input:
6 2
output:
2 2 1 1 1
result:
wrong answer 1st numbers differ - expected: '18', found: '2'