QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#592202 | #6636. Longest Strictly Increasing Sequence | Kandarp08 | AC ✓ | 0ms | 3564kb | C++20 | 2.1kb | 2024-09-26 21:09:42 | 2024-09-26 21:09:43 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MOD 1000000007
#define HASH_MOD1 998244353
#define HASH_MOD2 1000000009
#define HASH 31
#define ll long long
#define int long long
typedef __gnu_pbds::tree<int, __gnu_pbds::null_type, less<int>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update> ordered_set;
template <typename T>
istream& operator>> (istream& in, vector<T>& a)
{
for (int i = 0; i < a.size(); ++i)
in >> a[i];
return in;
}
template <typename T>
ostream& operator<< (ostream& out, vector<T>& a)
{
for (int i = 0; i < a.size(); ++i)
out << a[i] << " ";
out << "\n";
return out;
}
template <typename T>
ostream& operator<< (ostream& out, set<T>& s)
{
for (int x : s)
out << x << " ";
out << "\n";
return out;
}
template <typename T>
ostream& operator<< (ostream& out, vector<pair<T, T>>& v)
{
for (int i = 0; i < v.size(); ++i)
out << v[i].first << " " << v[i].second << "\n";
return out;
}
ll modinv(ll a)
{
return a <= 1 ? a : MOD - (MOD / a) * modinv(MOD % a) % MOD;
}
ll binpow(ll x, ll y)
{
ll ans = 1;
while (y > 0)
{
if (y % 2 == 1)
ans *= x;
x = x * x;
y = y / 2;
x %= MOD;
ans %= MOD;
}
return ans;
}
void solve()
{
int n, i;
cin >> n;
vector<int> b(n);
cin >> b;
vector<int> a(n);
int prev_len = 0;
int prev_num = 0;
for (i = 0; i < n; ++i)
{
if (b[i] < prev_len || b[i] > prev_len + 1)
{
cout << "NO\n";
return;
}
if (b[i] == prev_len)
a[i] = prev_num;
else
a[i] = prev_num + 1;
prev_num = a[i];
prev_len = b[i];
}
cout << "YES\n";
cout << a;
}
int32_t main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t = 1;
cin >> t;
while (t--)
{
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3560kb
input:
2 6 1 2 3 2 5 7 2 1 2
output:
NO YES 1 2
result:
ok t=2 (2 test cases)
Test #2:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
3483 5 2 3 5 1 1 2 8 1 10 1 2 3 4 4 5 6 6 6 7 10 1 1 2 2 2 2 3 4 4 5 2 5 8 3 7 10 8 5 4 1 3 3 8 10 1 2 2 2 2 2 2 3 3 3 10 1 1 2 3 4 5 5 5 5 6 9 1 2 3 4 5 5 6 6 7 7 8 8 8 8 9 1 2 5 8 9 8 3 5 10 1 2 3 3 3 3 4 4 4 5 5 7 1 6 4 3 7 5 6 8 6 1 5 5 10 1 2 2 3 4 4 4 4 5 5 3 10 4 5 3 1 5 3 5 2 8 1 2 1 3 7 8 3...
output:
NO NO YES 1 2 3 4 4 5 6 6 6 7 YES 1 1 2 2 2 2 3 4 4 5 NO NO NO YES 1 2 2 2 2 2 2 3 3 3 YES 1 1 2 3 4 5 5 5 5 6 YES 1 2 3 4 5 5 6 6 7 NO NO YES 1 2 3 3 3 3 4 4 4 5 NO NO YES 1 2 2 3 4 4 4 4 5 5 NO NO NO NO NO NO YES 1 1 1 2 2 3 3 4 4 NO NO NO NO NO NO NO YES 1 2 3 3 3 4 4 4 5 5 YES 1 1 2 2 2...
result:
ok t=3483 (3483 test cases)