当前位置: 代码迷 >> 综合 >> CF1659D Reverse Sort Sum(思维)
  详细解决方案

CF1659D Reverse Sort Sum(思维)

热度:63   发布时间:2023-12-05 21:34:28.0

有点想法,但是还差点。给个佬的链接。

思路链接:CF1659D. Reverse Sort Sum*_Strezia的博客-CSDN博客

/*keep on going and never give up*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define MAX 0x3f3f3f3f 
#define fast std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int N=2e5+10;
int n,k,t;
int c[N];
int a[N];
void solve() {int n;cin >> n;for(int i = 1; i <= n; i++) {cin >> c[i];a[i] = 1;}int st = 1;while(!c[st]) {a[st] = 0;st++;}for(int i = st; i <= n; i++) {if(c[i] == n) break;int t;if(a[i])t = c[i] - (i - 1);	elset = c[i];if(t + i > n) continue;  a[t + i] = 0;}for(int i = 1; i <= n; i++) {cout << a[i] << ' ';}cout << endl;
}
signed main(){fastcin>>t;while(t--){solve();}
}

  相关解决方案