QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#728177#7738. Equivalent RewritingGordensoulWA 115ms22644kbC++1429.3kb2024-11-09 14:43:232024-11-09 14:43:26

Judging History

你现在查看的是最新测评结果

  • [2024-11-09 14:43:26]
  • 评测
  • 测评结果:WA
  • 用时:115ms
  • 内存:22644kb
  • [2024-11-09 14:43:23]
  • 提交

answer

#define _CRT_SECURE_NO_WARNINGS
//#pragma GCC optimize(3, "Ofast", "inline")
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
#include<array>
#include<random>
using namespace std;
#define for1 for(int i = 1;i <= n;i++)
#define for0 for(int i = 0;i < n;i++) 
#define forj1 for(int j = 1;j <= n;j++) 
#define forj0 for(int j = 0;j < n;j++) 
#define form1 for (int j = 1; j <= m; j++)
#define form0 for (int j = 0; j < m; j++)
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define arrn int* arr = new int[n+2];arr[0] = 0,arr[n+1]=0
#define brrn int* brr = new int[n+2];brr[0] = 0,brr[n+1]=0
#define carr for1 cin >> arr[i]
#define carrn arrn;carr 
#define coarr for1 cout<<arr[i]<<" ";cout<<endl
#define yes  cout<<"Yes\n"
#define no cout<<"No\n"
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define endl '\n'
#define blank ' '
#define cn int n;cin>>n
#define cnm int n,m;cin>>n>>m
#define T() int _; cin >> _; while (_--)
#define int  long long
#define  ll long long
#define pii pair<int,int>
const int mode = 998244353;
const int mod = 1e9 + 7;
mt19937_64 rnd(time(0));
typedef uint64_t hash_t;
//chrono::high_resolution_clock::now().time_since_epoch().count()
int ksm(int a, int b = mode - 2)
{
    a %= mode;
    int ans = 1;
    while (b)
    {
        if (b % 2 == 1)
        {
            ans = ans * a % mode; b--;
        }
        a = a * a % mode;
        b >>= 1;
    }
    return ans;
}
int gcd(int a, int b)
{
    if (b == 0)return a;
    return gcd(b, a % b);
}
long long lcm(long long a, long long b)
{
    return (a * b) / gcd(a, b);
}
//const int mod = 1000002361;
bool ccmp(string x, string y)
{
    return x.size() > y.size();
}
long long qpow(int a, int b)
{
    a% mod;
    if (b == 0)return 1ll;
    int ret = 1ll;
    while (b)
    {
        if (b % 2)ret = (ret * a) % mod;
        b >>= 1;
        a = (a * a) % mod;
    }
    return ret % mod;
}

int one(int n)//计算二进制下1的个数
{
    if (n == 0)return 0;
    if (n == 1)return 1;
    int ret = 0;
    for (int i = 0; i < 63; i++)
    {
        int w = n / (1ll << (i + 1));
        ret = (ret + (w * (1ll << i))) % mode;
        int yu = n % (1ll << (i + 1));
        if (yu >= 1ll << i)
        {
            ret = (ret + (yu - (1ll << i) + 1)) % mode;
        }
    }

    return ret % mode;
}
bool isspire(int n)
{
    if (n <= 1)return false;
    if (n == 2)return true;
    for (int i = 2; i <= sqrt(n); i++)
    {
        if (n % i == 0)return false;
    }
    return true;
}


void solve();
signed main() {
    IOS;
    T()
    {
        solve();
     }
    return 0;
}

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int>a(m + 1, 0);
    vector<vector<int>>aa(n + 1);
    vector<int>cnt(m + 1, 0);
    for1
    {
        int x;
        cin >> x;
        while (x--)
        {
            int y;
            cin >> y;
            a[y] = i;
            aa[i].push_back(y);
            cnt[y]++;
        }
    }
    vector<vector<int>>wbwb(n + 1);
    bool f = false;
    for (int i = 1; i <= m; i++)
    {
        if (a[i] != 0)
        {
            wbwb[a[i]].push_back(i);
        }
    }
    int wc = 0;
    for (int i = 2; i <= n; i++)
    {
        sort(aa[i].begin(), aa[i].end());
        sort(wbwb[i].begin(), wbwb[i].end());
        int l = 0, r = 0;
        bool z = false;
        bool zzz = false;
        while (l < aa[i].size() && r < wbwb[i].size())
        {
            if (aa[i][l] > wbwb[i][r])r++;
            else if (aa[i][l] < wbwb[i][r])l++;
            else {
                if(cnt[aa[i][l]]!=1)
                z = true;
                zzz = true;
                l++, r++;
            }
        }
        bool wwr = false;
        if (zzz)wwr = true;
        if ((!z||!wwr)&&i!=1)f = true,wc = i;
    }
    if (f && n != 1) {
        cout << "Yes\n"; 
        cout << wc << " ";
        for1
        {
            if (i != wc)
            cout << i << " ";
        }
        cout << endl;
    }
    else cout << "No\n";
}
   


//int arr[1000001];
//int sm[4000004];
//int mx[4000004];
//int mxcnt[4000004];
//int semx[4000004];
////int semxcnt[400004];
//int ad1[4000004];
//int ad2[4000004];
//int ad3[4000004];
//int ad4[4000004];
//int hismx[4000004];
//void up(int i)
//{
//    int z = i << 1;
//    int y = i << 1 | 1;
//    sm[i] = sm[z] + sm[y];
//    hismx[i] = max({hismx[z], hismx[y]});
//    if (mx[z] > mx[y])
//    {
//        mx[i] = mx[z];
//        mxcnt[i] = mxcnt[z];
//        semx[i] = max(mx[y], semx[z]);
//    }
//    else if (mx[z] < mx[y])
//    {
//        mx[i] = mx[y];
//        mxcnt[i] = mxcnt[y];
//        semx[i] = max(mx[z], semx[y]);
//    }
//    else
//    {
//        mx[i] = mx[z];
//        mxcnt[i] = mxcnt[z] + mxcnt[y];
//        semx[i] = max(semx[z], semx[y]);
//    }
//}
//void build(int l, int r, int i)
//{
//    if (l == r)
//    {
//        sm[i] = arr[l];
//        mx[i] = arr[l];
//        mxcnt[i] = 1;
//        semx[i] = -1e18;
//       // semxcnt[i] = 1;
//        ad1[i] = 0;
//        ad2[i] = 0;
//        ad3[i] = 0;
//        ad4[i] = 0;
//        hismx[i] = arr[l];
//        return;
//    }
//    int mid = (l + r) >> 1;
//    build(l, mid, i << 1);
//    build(mid + 1, r, i << 1 | 1);
//    up(i);
//    ad1[i] = 0;
//    ad2[i] = 0;
//    ad3[i] = 0;
//    ad4[i] = 0;
//}
//
//void lazy(int i, int n,int v1,int v2,int v3,int v4)
//{   
//    hismx[i] = max({ mx[i] + v3, hismx[i]});
//    ad3[i] = max(ad1[i]+v3,ad3[i]);
//    ad4[i] = max(ad2[i] + v4, ad4[i]);
//    sm[i] += v1 * mxcnt[i];
//    sm[i] += v2 * (n-mxcnt[i]);
//    mx[i] += v1;
//    semx[i] += (semx[i] == -1e18) ? 0 : v2;
//    ad1[i] += v1;
//    ad2[i] += v2;
//}
//void down(int i, int z, int y)
//{
//    int l = i << 1;
//    int r = i << 1 | 1;
//    int t = max(mx[l], mx[r]);
//    if(mx[l]>=mx[r])
//    lazy(l, z, ad1[i], ad2[i],ad3[i],ad4[i]);
//    else
//        lazy(l, z, ad2[i], ad2[i],ad4[i],ad4[i]);
//    if (mx[r]==t)
//    lazy(r, y, ad1[i], ad2[i],ad3[i],ad4[i]);
//    else
//        lazy(r, y, ad2[i], ad2[i],ad4[i],ad4[i]);
//    ad1[i] = 0;
//    ad2[i] = 0;
//    ad3[i] = 0;
//    ad4[i] = 0;
//}
//
//array<int, 3> que(int jl, int jr, int l, int r, int i)
//{
//    if (jl <= l && r <= jr)
//    {
//        return { sm[i],mx[i],hismx[i] };
//    }
//    int mid = (l + r) >> 1;
//    down(i, mid - l + 1, r - mid);
//    array<int, 3>ans = { 0,(int)-1e18,(int)-1e18 };
//    if (jl <= mid)
//    {
//        array<int, 3>a = que(jl, jr, l, mid, i << 1);
//        ans[0] += a[0];
//        ans[1] = max(ans[1], a[1]);
//        ans[2] = max(ans[2], a[2]);
//    }
//    if (mid + 1 <= jr)
//    {
//        array<int, 3>a = que(jl, jr, mid + 1, r, i << 1 | 1);
//        ans[0] += a[0];
//        ans[1] = max(ans[1], a[1]);
//        ans[2] = max(ans[2], a[2]);
//    }
//    
//    return ans;
//
//}
//void update(int jl, int jr, int jv, int l, int r, int i)
//{
//    if (jv >= mx[i])return;
//    if (l >= jl && r <= jr&&jv>semx[i])
//    {
//
//        lazy(i, r - l + 1, jv - mx[i], 0ll, jv - mx[i], 0ll);
//    }
//    else
//    {
//        int mid = (l + r) >> 1;
//        down(i, mid - l + 1, r - mid);
//        if (jl <= mid)
//            update(jl, jr, jv, l, mid, i << 1);
//        if (jr >= mid + 1)
//            update(jl, jr, jv, mid + 1, r, i << 1 | 1);
//        up(i);
//    }
//   
//}
//void _add(int jl, int jr, int jv, int l, int r, int i)
//{
//    if (l >= jl && r <= jr)
//    {
//        lazy(i, r - l + 1, jv, jv, jv, jv);
//    }
//    else
//    {
//        int mid = (l + r) >> 1;
//        down(i, mid - l + 1, r - mid);
//        if (jl <= mid)
//            _add(jl, jr, jv, l, mid, i << 1);
//        if (jr >= mid + 1)
//            _add(jl, jr, jv, mid + 1, r, i << 1 | 1);
//        up(i);
//    }
//   
//}


//int mul(int a, int b) {
//    return (int)((1ll * a * b) % mod);
//}
//int binpow(int a, int pw) {
//    int b = 1;
//    while (pw) {
//        if (pw & 1)
//            b = mul(b, a);
//        a = mul(a, a);
//        pw >>= 1;
//    }
//    return b;
//}
//int inv(int a) {
//    return binpow(a, mod - 2);
//}
//const int N = 1000001;
//int ff[N], rr[N];
//void precalc() {
//    ff[0] = 1;
//    for (int i = 1; i < N; i++)
//        ff[i] = mul(ff[i - 1], i);
//    rr[N - 1] = inv(ff[N - 1]);
//    for (int i = N - 2; i > -1; i--)
//        rr[i] = mul(rr[i + 1], i + 1);
//}
//int C(int n, int k) {
//    if (n < 0 || k < 0 || n < k)
//        return 0;
//    return mul(ff[n], mul(rr[k], rr[n - k]));
//}
//
//int add(int a, int b) {
//    if (a + b >= mod)
//        return a + b - mod;
//    return a + b;
//}
//int arr[100001];
//int mn[400004];
//int mx[400004];
//int sm[400004];
//int laz[400004];
//int change[400004];
//bool vis[400004];
//array<int, 3> build(int l, int r, int i)
//{
//    if (l == r)
//    {
//        sm[i] = arr[l];
//        mx[i] = arr[l];
//        mn[i] = arr[l];
//        laz[i] = 0;
//        return{ sm[i],mx[i],mn[i] };
//    }
//    int mid = (l + r) >> 1;
//    array<int, 3> a = build(l, mid, i << 1);
//    array<int, 3> b = build(mid + 1, r, i << 1 | 1);
//    sm[i] = a[0] + b[0];
//    mx[i] = max(a[1], b[1]);
//    mn[i] = min(a[2], b[2]);
//    laz[i] = 0;
//    return { sm[i],mx[i],mn[i] };
//}
//void lazy(int i, int n, int v)
//{
//    if (vis[i])
//    {
//        sm[i] = n * change[i];
//        mx[i] = change[i];
//        mn[i] = change[i];
//        laz[i] = change[i];
//    }
//    if (v != 0) {
//        sm[i] += n * v;
//        mx[i] += v;
//        mn[i] += v;
//        laz[i] += v;
//    }
//}
//void down(int i, int z, int y)
//{
//    if (laz[i] != 0 || vis[i])
//    {
//        lazy(i << 1, z, laz[i]);
//        lazy(i << 1 | 1, y, laz[i]);
//    }
//    laz[i] = 0; vis[i] = false;
//}
//void up(int i)
//{
//    sm[i] = sm[i << 1] + sm[i << 1 | 1];
//    mx[i] = max(mx[i << 1], mx[i << 1 | 1]);
//    mn[i] = min(mn[i << 1], mn[i << 1 | 1]);
//}
//array<int, 3> que(int jl, int jr, int l, int r, int i)
//{
//    if (jl <= l && r <= jr)
//    {
//        return{ sm[i],mx[i],mn[i] };
//    }
//    int mid = (l + r) >> 1;
//    down(i, mid - l + 1, r - mid);
//    array<int, 3>ans = { 0,-1e18,1e18 };
//    if (jl <= mid)
//    {
//        array<int, 3>a = que(jl, jr, l, mid, i << 1);
//        ans[0] += a[0];
//        ans[1] = max(a[1], ans[1]);
//        ans[2] = min(a[2], ans[2]);
//    }
//    if (jr >= mid + 1)
//    {
//        array<int, 3>a = que(jl, jr, mid + 1, r, i << 1 | 1);
//        ans[0] += a[0];
//        ans[1] = max(a[1], ans[1]);
//        ans[2] = min(a[2], ans[2]);
//    }
//    return ans;
//}
//void _add(int jl, int jr, int jv, int l, int r, int i)
//{
//    if (l >= jl && r <= jr)
//    {
//        lazy(i, r - l + 1, jv);
//    }
//    else
//    {
//        int mid = (l + r) >> 1;
//        down(i, mid - l + 1, r - mid);
//        if (jl <= mid)
//            _add(jl, jr, jv, l, mid, i << 1);
//        if (jr >= mid + 1)
//            _add(jl, jr, jv, mid + 1, r, i << 1 | 1);
//        up(i);
//    }
//}void update(int jl, int jr, int jv, int l, int r, int i)
//{
//    if (l >= jl && r <= jr)
//    {
//        change[i] = jv;
//        vis[i] = true;
//        laz[i] = 0;
//        lazy(i, r - l + 1, laz[i]);
//    }
//    else
//    {
//        int mid = (l + r) >> 1;
//        down(i, mid - l + 1, r - mid);
//        if (jl <= mid)
//            update(jl, jr, jv, l, mid, i << 1);
//        if (jr >= mid + 1)
//            update(jl, jr, jv, mid + 1, r, i << 1 | 1);
//        up(i);
//    }
//}
//int mul(int a, int b) {
//        return (int)((1ll * a * b) % mod);
//    }
//    int binpow(int a, int pw) {
//        int b = 1;
//        while (pw) {
//            if (pw & 1)
//                b = mul(b, a);
//            a = mul(a, a);
//            pw >>= 1;
//        }
//        return b;
//    }
//    int inv(int a) {
//        return binpow(a, mod - 2);
//    }
//    const int N = 100001;
//    int ff[N], rr[N];
//    void precalc() {
//        ff[0] = 1;
//        for (int i = 1; i < N; i++)
//            ff[i] = mul(ff[i - 1], i);
//        rr[N - 1] = inv(ff[N - 1]);
//        for (int i = N - 2; i > -1; i--)
//            rr[i] = mul(rr[i + 1], i + 1);
//    }
//    int C(int n, int k) {
//        if (n < 0 || k < 0 || n < k)
//            return 0;
//        return mul(ff[n], mul(rr[k], rr[n - k]));
//    }
//    
//    int add(int a, int b) {
//        if (a + b >= mod)
//            return a + b - mod;
//        return a + b;
//    }
//namespace string_hash
//{#define LL long long
//    const int N = 1e6 + 20;
//    const int mod1 = 998244353;
//    const int mod2 = 1e9 + 7;
//    const int P = 1000007;
//    LL p1[N], p2[N];
//    // 双模数初始化
//    void mod_init()
//    {
//        p1[0] = p2[0] = 1;
//        for (int i = 1; i < N; i++)
//        {
//            p1[i] = p1[i - 1] * P % mod1;
//            p2[i] = p2[i - 1] * P % mod2;
//        }
//    }
//    struct Hash_String
//    {
//        string str;
//        int string_size;
//        vector<LL> h1, h2;
//        Hash_String(string s) : str(s), h1(s.size() + 1), h2(s.size() + 1)
//        {
//            str = ' ' + str;
//            string_size = str.size() - 1;
//            for (int i = 1; i < str.size(); i++)
//            {
//                h1[i] = (h1[i - 1] * P + str[i]) % mod1;
//                h2[i] = (h2[i - 1] * P + str[i]) % mod2;
//            }
//        }
//        pair<LL, LL> get(int l, int r)
//        {
//            if (l > r)
//                return { 0, 0 };
//            // assert(l <= r && l >= 1 && r <= string_size);
//            LL res1 = ((h1[r] - h1[l - 1] * p1[r - l + 1] % mod1) % mod1 + mod1) % mod1;
//            LL res2 = ((h2[r] - h2[l - 1] * p2[r - l + 1] % mod2) % mod2 + mod2) % mod2;
//            return { res1, res2 };
//        }
//        ll oneget(int l, int r) // 用于没办法用pair,只能用一个整数,但是单hash又会错的情况
//        {
//            if (l > r)
//                return 0;
//            LL res1 = ((h1[r] - h1[l - 1] * p1[r - l + 1] % mod1) % mod1 + mod1) % mod1;
//            LL res2 = ((h2[r] - h2[l - 1] * p2[r - l + 1] % mod2) % mod2 + mod2) % mod2;
//            return (res1 + P * res2);
//        }
//        pair<LL, LL> get_substring(int l1, int r1, int l2, int r2)
//        {
//            auto [v1, v2] = get(l1, r1);
//            auto [vv1, vv2] = get(l2, r2);
//            return make_pair((v1 * p1[r2 - l2 + 1] % mod1 + vv1) % mod1, (v2 * p2[r2 - l2 + 1] % mod2 + vv2) % mod2);
//            // get_hash(l1, r1) * p[r2 - l2 + 1] + get_hash(l2, r2)
//        }
//    };
//};
//using namespace string_hash;
// int arr[100001];
//int sm1[400004];
//int sm0[400004];
//int mx1[400004];
//int mx0[400004];
//int pre1[4000004];
//int suf1[4000004];
//int pre0[4000004];
//int suf0[4000004];
//bool revers[400004];
//int change[400004];
//bool vis[400004];
//void up(int i, int l, int r)
//{
//    int mid = (l + r) >> 1;
//    sm1[i] = sm1[i << 1] + sm1[i << 1 | 1];
//    sm0[i] = sm0[i << 1] + sm0[i << 1 | 1];
//    mx1[i] = max({ mx1[i << 1],mx1[i << 1 | 1] ,suf1[i << 1] + pre1[i << 1 | 1] });
//    mx0[i] = max({ mx0[i << 1], mx0[i << 1 | 1] ,suf0[i << 1] + pre0[i << 1 | 1] });
//    if (pre1[i << 1] == mid - l + 1)
//        pre1[i] = pre1[i << 1] + pre1[i << 1 | 1];
//    else pre1[i] = pre1[i << 1];
//    if (pre0[i << 1] == mid - l + 1)
//        pre0[i] = pre0[i << 1] + pre0[i << 1 | 1];
//    else pre0[i] = pre0[i << 1];
//    if (suf1[i << 1 | 1] == r - mid)
//        suf1[i] = suf1[i << 1 | 1] + suf1[i << 1];
//    else suf1[i] = suf1[i << 1 | 1];
//    if (suf0[i << 1 | 1] == r - mid)
//        suf0[i] = suf0[i << 1 | 1] + suf0[i << 1];
//    else suf0[i] = suf0[i << 1 | 1];
//}
//void build(int l, int r, int i)
//{
//    if (l == r)
//    {
//        sm1[i] = arr[l];
//        sm0[i] = 1-arr[l];
//        mx1[i] = sm1[i];
//        mx0[i] = sm0[i];
//        pre1[i] = sm1[i];
//        pre0[i] = sm0[i];
//        suf1[i] = sm1[i];
//        suf0[i] = sm0[i];
//        vis[i] = false;
//        revers[i] = false;
//        change[i] = 0;
//        //return{ sm1[i],sm0[i],mx1[i],mx0[i],pre1[i],pre0[i],suf1[i],suf0[i] };
//        return;
//    }
//    int mid = (l + r) >> 1;
//    build(l, mid, i << 1);
//    build(mid + 1, r, i << 1 | 1);
//    up(i, l, r);
//    vis[i] = false;
//    revers[i] = false;
//    change[i] = 0;
//    //return{ sm1[i],sm0[i],mx1[i],mx0[i],pre1[i],pre0[i],suf1[i],suf0[i] };
//}
//void ulazy(int i, int n,int v)
//{
//        if (v == 1) {
//            sm1[i] = n;
//            sm0[i] = 0;
//            mx1[i] = n;
//            mx0[i] = 0;
//            pre1[i] = n;
//            pre0[i] = 0;
//            suf1[i] = n;
//            suf0[i] = 0;
//        }
//        else
//        {
//            sm1[i] = 0;
//            sm0[i] = n;
//            mx1[i] = 0;
//            mx0[i] = n;
//            pre1[i] = 0;
//            pre0[i] = n;
//            suf1[i] = 0;
//            suf0[i] = n;
//        }
//        change[i] = v;
//        vis[i] = true;
//        revers[i] = false;
//}
//void rlazy(int i, int n)
//{
//        swap(sm1[i], sm0[i]);
//        swap(mx1[i], mx0[i]);
//        swap(pre1[i], pre0[i]);
//        swap(suf1[i], suf0[i]);
//        revers[i] = !revers[i];
//}
//void down(int i, int z, int y)
//{
//    if (vis[i])
//    {
//        ulazy(i << 1, z,change[i]);
//        ulazy(i << 1 | 1, y,change[i]);
//        vis[i] = false;
//    }
//    if (revers[i])
//    {
//        rlazy(i << 1, z);
//        rlazy(i << 1 | 1, y);
//        revers[i] = false;
//    }
//}
//int ques(int jl, int jr, int l, int r, int i)
//{
//    if (jl <= l && r <= jr)
//    {
//        return sm1[i];
//    }
//    int mid = (l + r) >> 1;
//    int ans = 0;
//    down(i, mid - l + 1, r - mid);
//    //array<int, 4>ans = { 0,-1e18,0,0 };
//    if (jl <= mid)
//    {
//        ans+= ques(jl, jr, l, mid, i << 1);
//
//    }
//    if (mid + 1 <= jr)
//    {
//        ans+=  ques(jl, jr, mid + 1, r, i << 1 | 1);
//
//    }
//    return ans;
//
//}
//array<int, 4> que(int jl, int jr, int l, int r, int i)
//{
//    if (jl <= l && r <= jr)
//    {
//        return{ sm1[i],mx1[i],pre1[i],suf1[i] };
//    }
//    int mid = (l + r) >> 1;
//    down(i, mid - l + 1, r - mid);
//    //array<int, 4>ans = { 0,-1e18,0,0 };
//    if (jr <= mid)
//    {
//       return que(jl, jr, l, mid, i << 1);
//        
//    }
//    if ( mid + 1<=jl)
//    {
//       return  que(jl, jr, mid + 1, r, i << 1 | 1);
//       
//    }
//    array<int, 4>a = que(jl, jr, l, mid, i<<1);
//    array<int, 4>b = que(jl, jr, mid + 1, r, i<<1|1);
//    int z = 0, zz = 0;
//    if (a[2] == mid - max(jl,l) + 1)z = a[2] + b[2];
//    else z = a[2];
//    if (b[3] == min(jr,r) - mid)zz = b[3] + a[3];
//    else zz = b[3];
//    return{ a[0] + b[0],max({a[1],b[1],a[3] + b[2]}),z,zz };
//    
//}
//void _reverse(int jl, int jr, int l, int r, int i)
//{
//    if (l >= jl && r <= jr)
//    {
//        rlazy(i, r - l + 1);
//    }
//    else
//    {
//        int mid = (l + r) >> 1;
//        down(i, mid - l + 1, r - mid);
//        if (jl <= mid)
//            _reverse(jl, jr, l, mid, i << 1);
//        if (jr >= mid + 1)
//            _reverse(jl, jr, mid + 1, r, i << 1 | 1);
//        up(i,l,r);
//    }
//}void update(int jl, int jr, int jv, int l, int r, int i)   
//{
//    if (l >= jl && r <= jr)
//    {
//       
//        ulazy(i, r - l + 1,jv);
//    }
//    else
//    {
//        int mid = (l + r) >> 1;
//        down(i, mid - l + 1, r - mid);
//        if (jl <= mid)
//            update(jl, jr, jv, l, mid, i << 1);
//        if (jr >= mid + 1)
//            update(jl, jr, jv, mid + 1, r, i << 1 | 1);
//        up(i,l,r);
//    }
//}
//const int NN = 2049;
//int tree1[NN][NN];
//int tree2[NN][NN];
//int tree3[NN][NN];
//int tree4[NN][NN];
//int n, m;
////int lowbit(int i)
////{
////    return(i & -i);
////}
//void add1(int x, int y, int v)
//{
//    int v1 = v;
//    int v2 = v * x;
//    int v3 = v * y;
//    int v4 = x * y * v;
//    for (int i = x; i <= n; i += (lowbit(i)))
//    {
//        for (int j = y; j <= m; j += lowbit(j))
//        {
//            tree1[i][j] += v1;
//            tree2[i][j] += v2;
//            tree3[i][j] += v3;
//            tree4[i][j] += v4;
//        }
//    }
//}
//void add1(int a, int b, int c, int d,int v)
//{
//    add1(a, b, v);
//    add1(c+1, b, -v);
//    add1(a, d+1, -v);
//    add1(c+1, d+1, v);
//}
//int query1(int x, int y)
//{
//    int ans = 0;
//    for (int i = x; i > 0; i -= lowbit(i))
//    {
//        for (int j = y; j > 0; j -= lowbit(j))
//        {
//            ans += ((x+1)*(y+1)*tree1[i][j]);
//            ans -= ((y+1)*tree2[i][j]);
//            ans -= ((x+1)*tree3[i][j]);
//            ans += tree4[i][j];
//        }
//    }
//    return ans;
//}
//int query(int a, int b, int c, int d)
//{
//    return query1(a-1, b-1) + query1(c, d) - query1(a - 1, d) - query1(c, b - 1);
//}
/*   int tree1[114514];
   int tree2[114514];
   int n;
   void add1(int* tree,int i, int v)
   {
       while (i <= n)
       {
           tree[i] += v;
           i += (i & -i);
       }
   }
   void add12(int l, int r, int v)
   {
       add1(tree1,l, v);
       add1(tree1,r+1, -v);
       add1(tree2,l, (l - 1) * v);
       add1(tree2,r+1, -(r * v));
   }
   int query1(int * tree,int i)
   {
       int ans = 0;
       while (i)
       {
           ans += tree[i];
           i -= (i & -i);
       }
       return ans;
   }
   int query(int l,int r)
   {
       return r * query1(tree1, r) - query1(tree2, r) - (l - 1) * query1(tree1, l - 1) + query1(tree2, l - 1);
   }*/
   /* auto adj = [&]() {//set维护中位数板子
       if (ma.size() >= mi.size() + 3)
       {
           auto a = ma.begin();
           suma += *a;
           sumb -= *a;
           mi.insert(*a);
           ma.erase(a);
       }
       if (ma.size() > mi.size())return;
       auto a = --mi.end();
       suma -= *a;
       sumb += *a;
       ma.insert(*a);
       mi.erase(a);
   };*/
   //    int wwr[1001];
   //int find(int x)
   //{
   //    if (x != wwr[x])
   //    {
   //        int w = find(wwr[x]);
   //        wwr[x] = w;
   //        return w;
   //    }
   //    else
   //    {
   //        return x;
   //    }
   //}
   //void wbwb(int a, int b)
   //{
   //    int fa = find(a);
   //    int fb = find(b);
   //    if (fa != fb)
   //    {
   //        wwr[fa] = fb;
   //       // cnt[fb] += cnt[fa];
   //    }
   //}
       //int prime[1000010] = { 0 };//质数
       //int minp[1000010] = { 0 };//最小质因子
       //void olshai(int n)
       //{
       //    int cnt = 0;
       //    for (int i = 2; i <= n; i++)
       //    {
       //        if (minp[i] == 0) { minp[i] = i; prime[++cnt] = i; }
       //        for (int j = 1; j <= cnt; j++) { if (prime[j] > minp[i] || prime[j] > n / i) break; minp[i * prime[j]] = prime[j]; }
       //    }
       //
       //}
     /*  auto dij = [&](int s, int d[], bool vis[]) {
           priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
           for (int i = 0; i <= 1 * n; i++)
               d[i] = 1e18, vis[i] = 0;
           d[s] = 0;
           q.push({ 0,s });
           while (q.size()) {
               auto t = q.top();
               q.pop();
               int u = t.second;
               if (vis[u]) continue;
               vis[u] = true;
               for (auto ed : arr[u]) {
                   int v = ed.first, w = ed.second;
                   if (d[v] > d[u] + w) {
                       d[v] = d[u] + w;
                       q.push({ d[v],v });
                   }
               }
           }
       };*/
   /*    int mergesort(vector<int>& nums, int l, int r)
       {
           long long ret = 0;
           if (l >= r)
               return 0;
           int mid = (l + r) >> 1;
           ret = (ret + mergesort(nums, l, mid)) % mod;
           ret = (ret + mergesort(nums, mid + 1, r)) % mod;
           int cur1 = l, cur2 = mid + 1, i = l;
           while (cur1 <= mid && cur2 <= r)
           {
               if (nums[cur1] <= nums[cur2])
               {
                   tem[i++] = nums[cur1++];
               }
               else {
       
                   ret = ((ret + mid) % mod - cur1 + 1) % mod;
                   tem[i++] = nums[cur2++];
       
               }
           }
           while (cur1 <= mid)tem[i++] = nums[cur1++];
           while (cur2 <= r)tem[i++] = nums[cur2++];
           for (int i = l; i <= r; i++)
               nums[i] = tem[i];
           return ret % mod;
       }*/
       //int InversePairs(vector<int>& nums) {
       //    tem.resize(nums.size());
       //    return mergesort(nums, 0, nums.size() - 1) % mod;
       //}
       //多重背包模板
       // int n, m;
       //int a[101];
       //int b[101];
       //int c[101];
       //int dp[40000 + 1];
       //int que[50000 + 100000 + 1]; cin >> n >> m;
       //for1
       //{
       //    cin >> a[i] >> b[i] >> c[i];
       //}
       //
       //for1
       //{
       //
       //
       //for (int md = 0; md <= min(m , b[i] - 1); md++)
       //{
       //    int l = 0, r = 0;
       //
       //    for (int j = m - md,k = 0; j >= 0 && k <= c[i]; j -= b[i],k++)
       //    {
       //        while (l < r && dp[que[r - 1]] <= dp[j] + a[i] * ((que[r - 1] - j) / b[i]))
       //        {
       //            r--;
       //        }
       //        que[r++] = j;
       //
       //    }
       //    for (int j = m - md; j >= 0; j -= b[i])
       //    {
       //
       //        dp[j] = dp[que[l]] + a[i] * ((j - que[l]) / b[i]);  
       //        if (j == que[l])l++;
       //        int wwr = j - b[i] * (c[i] + 1);
       //        if (wwr >= 0)
       //        { 
       //            while (l < r && dp[que[r - 1]] <= dp[wwr] + a[i] * ((que[r - 1] - wwr) / b[i]))
       //                r--;
       //            que[r++] = wwr;
       //        }
       //    }
       //}
       //
       //}
       //cout << dp[m] << endl;..
       //  vector :c.assign(beg, end)	将另外一个容器[x.begin(), x.end()) 里的内容拷贝到c中
       //vector<int>::iterator it;
       // 相当于声明了一个迭代器类型的变量it
       //less<int> 表示数字大的优先级大,堆顶为最大的数字
       //greater<int>表示数字小的优先级大,堆顶为最小的数字,优先队列比较要写结构体cmp
       //mp.lower_bound()	返回一个迭代器,指向键值 >= key的第一个元素
       //mp.upper_bound()	返回一个迭代器,指向键值 > key的第一个元素             for(auto [x, y] : mp)
       //getline(cin, s)会获取前一个输入的换行符,需要在前面添加读取换行符的语句。如:getchar() 或 cin.get()
       //tolower(s[i])	转换为小写
       //toupper(s[i])	转换为大写
       //transform(s.begin(), s.end(), s.begin(), ::tolower);//转换小写
       //transform(s.begin(), s.end(), s.begin(), ::toupper);//转换大写 find返回-1是找不到
       //bitset<n> a(s)	a是string对象s中含有的位串的副本
       //bitset<n> a(s, pos, n)	a是s中从位置pos开始的n个位的副本 bitset可以进行位操作可以通过 [] 访问元素 
       //b.count()	b中为1的个数
       //fill(a.begin(), a.end(), x)填充
       //tuple获取对应元素的值通过get<n>(tuple)方法获取, n必须为数字不能是变量
       //tie可以让tuple变量中的三个值依次赋到tie中的三个变量中tie(one, two, three) = t;
       //accumulate(beg, end, init)作用:对一个序列的元素求和init为对序列元素求和的初始值返回值类型:与init 相同
       //atoi(const char*)将字符串转换为int类型int a = atoi(s.c_str());
       //is_sorted(beg, end) 判断序列是否有序(升序),返回bool值
       //iota(beg, end,初始值)让序列递增赋值如 把数组赋值为:0 1 2 3 4 5
       //max_element+min_element找最大最小值
       ////找到a,b,c,d的最大值和最小值
       //mx = max({ a, b, c, d });
       //mn = min({ a, b, c, d });
       //nth_element(beg, nth, end)复杂度: 平均O(N)O(N)寻找第序列第n小的值
       //shuffle(b.begin(), b.end()); 随机打乱序列的顺序
       //reverse(beg, end)对序列进行翻转
       //stable_sort区别在于stable_sort()能够保证相等元素的相对位置,排序时不会改变相等元素的相对位置
       //unique(beg, end)消除重复元素,返回消除完重复元素的下一个位置的地址
       // 消除重复元素一般需要原序列是有序序列 unique 之后 a 数组为 { 1, 2, 3, 6, 3 }前面为无重复元素的数组,后面则是重复元素移到后面,返回a[4]
       //int len = unique(b, b + n) - b;//消除 b 的重复元素,并获取长度

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3888kb

input:

3
3 6
3 3 1 5
2 5 3
2 2 6
2 3
3 1 3 2
2 3 1
1 3
2 2 1

output:

Yes
3 1 2 
No
No

result:

ok OK. (3 test cases)

Test #2:

score: 0
Accepted
time: 0ms
memory: 3836kb

input:

1
10 5
2 2 4
4 1 3 4 2
1 2
3 2 1 4
4 5 2 4 3
3 2 5 4
3 5 4 2
3 1 3 2
5 1 4 2 3 5
1 4

output:

Yes
8 1 2 3 4 5 6 7 9 10 

result:

ok OK. (1 test case)

Test #3:

score: 0
Accepted
time: 0ms
memory: 3768kb

input:

1
20 5
5 4 1 2 5 3
2 5 3
3 5 1 2
5 4 5 1 3 2
3 4 2 5
5 3 1 5 4 2
5 5 1 2 3 4
1 3
4 5 1 2 3
4 4 1 3 5
2 5 2
4 2 3 5 1
3 2 4 5
5 2 3 4 1 5
4 5 2 4 3
1 2
2 4 3
4 4 5 3 1
5 4 1 5 3 2
3 5 1 3

output:

Yes
18 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 19 20 

result:

ok OK. (1 test case)

Test #4:

score: 0
Accepted
time: 0ms
memory: 3836kb

input:

1
40 10
2 4 1
10 5 8 2 3 6 7 4 1 10 9
3 10 9 7
1 9
10 10 5 6 9 2 8 3 1 4 7
7 8 4 7 5 2 3 6
5 2 6 5 1 10
6 6 5 4 8 7 1
3 4 9 8
9 9 10 4 2 1 8 7 5 3
2 5 7
9 8 6 1 2 9 7 5 10 3
2 8 1
8 8 3 10 9 1 4 5 6
2 3 4
5 5 3 6 2 7
10 3 2 8 9 10 1 7 4 6 5
2 1 9
1 1
3 3 7 4
5 2 6 5 7 1
7 3 2 4 9 10 6 1
1 4
5 6 4 5 ...

output:

Yes
36 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 37 38 39 40 

result:

ok OK. (1 test case)

Test #5:

score: 0
Accepted
time: 0ms
memory: 3840kb

input:

1
100 20
12 10 5 11 13 12 14 7 15 19 18 3 1
10 16 11 19 8 10 15 5 12 13 14
12 16 8 11 15 2 18 14 13 20 4 12 7
10 3 9 1 7 19 6 2 14 8 20
7 17 18 20 3 9 6 10
4 1 4 19 9
13 14 17 16 11 13 8 10 19 18 7 5 20 1
13 10 15 3 2 9 1 17 7 20 13 19 18 16
2 17 9
10 20 19 13 14 16 17 8 12 18 15
5 2 16 14 6 19
1 14...

output:

Yes
98 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 99 100 

result:

ok OK. (1 test case)

Test #6:

score: 0
Accepted
time: 1ms
memory: 4224kb

input:

1
5000 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1...

output:

Yes
4999 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...

result:

ok OK. (1 test case)

Test #7:

score: 0
Accepted
time: 36ms
memory: 9880kb

input:

1
5000 200
2 121 161
35 27 5 1 189 173 2 37 107 140 172 108 53 163 19 127 102 174 71 178 42 72 74 167 118 120 175 28 75 128 106 190 112 86 171 13
109 110 109 183 17 77 159 188 157 56 14 104 55 179 121 171 64 123 196 140 38 29 134 130 163 108 187 42 68 26 156 138 80 143 182 4 174 67 63 76 79 69 142 3...

output:

Yes
4995 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...

result:

ok OK. (1 test case)

Test #8:

score: 0
Accepted
time: 73ms
memory: 14512kb

input:

1
5000 1000
146 147 426 393 758 104 385 277 218 753 477 377 54 465 635 918 97 453 576 270 57 189 230 227 332 345 358 14 178 969 817 840 620 828 837 94 922 844 789 106 250 952 745 212 693 296 677 368 625 150 103 55 266 756 525 60 91 683 364 852 877 792 312 315 997 27 50 866 759 327 557 56 49 947 644 ...

output:

Yes
4955 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...

result:

ok OK. (1 test case)

Test #9:

score: 0
Accepted
time: 73ms
memory: 14516kb

input:

1
4999 1000
799 991 88 253 814 577 620 74 338 485 560 435 835 130 279 536 637 188 612 876 634 950 755 534 727 272 657 357 810 113 800 41 439 125 763 311 724 623 976 525 725 869 209 975 888 683 428 4 91 448 936 885 140 233 967 556 369 522 263 483 784 96 808 70 42 391 109 333 778 422 121 862 430 746 6...

output:

Yes
4943 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...

result:

ok OK. (1 test case)

Test #10:

score: 0
Accepted
time: 85ms
memory: 13372kb

input:

1
5000 5000
2081 3619 2779 2556 4025 163 2942 2539 4075 189 2823 2189 3571 1168 1474 3383 649 1432 2052 1218 645 1053 1833 2651 3651 1611 1512 1267 3727 4182 2237 4827 3905 3335 3268 1627 2212 3697 2241 884 4015 4902 1504 2223 484 3001 2908 4619 4321 2875 4501 87 2442 3850 2760 834 3985 1807 1880 26...

output:

Yes
4981 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...

result:

ok OK. (1 test case)

Test #11:

score: 0
Accepted
time: 80ms
memory: 12860kb

input:

1
1000 5000
2728 456 1809 201 2171 4389 1597 1911 2218 3081 3818 486 3732 263 2483 2923 527 867 782 3405 3803 4039 838 3743 3589 2153 2818 2946 997 11 899 2656 2024 4474 4802 2978 2070 3056 1919 2475 2205 2563 4339 3179 2508 195 3943 3710 4441 3440 3923 4842 3916 4481 912 3076 4866 710 254 4324 1546...

output:

Yes
876 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 ...

result:

ok OK. (1 test case)

Test #12:

score: 0
Accepted
time: 0ms
memory: 3996kb

input:

1
10 5000
4665 1548 2583 767 790 1820 825 4120 4957 4179 3273 2273 4509 457 3495 667 206 1152 4353 1992 4211 315 4334 905 4043 2826 1094 1708 4132 1046 3359 137 3773 4602 4557 83 605 4257 3514 4430 4968 2253 3041 786 2356 320 1504 1734 4095 1738 2512 3667 140 1487 594 276 3290 4273 4321 87 3343 4451...

output:

Yes
4 1 2 3 5 6 7 8 9 10 

result:

ok OK. (1 test case)

Test #13:

score: 0
Accepted
time: 81ms
memory: 13552kb

input:

1
4999 4999
1640 2673 1066 1994 4702 3817 839 2285 742 4086 1810 4349 4925 4974 4073 3186 3272 4258 893 3357 942 1513 1881 1371 2140 1512 4472 524 2119 3396 1236 4311 4605 1337 910 586 944 1016 4661 1041 2765 481 4021 4994 712 1233 3011 2070 123 356 2703 3891 2559 1158 640 1127 1488 2836 1912 3975 4...

output:

Yes
4896 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...

result:

ok OK. (1 test case)

Test #14:

score: 0
Accepted
time: 0ms
memory: 3704kb

input:

1
10 10
2 1 2
2 2 3
2 3 4
2 4 5
2 5 6
2 6 7
2 7 8
2 8 9
2 9 10
1 10

output:

No

result:

ok OK. (1 test case)

Test #15:

score: 0
Accepted
time: 12ms
memory: 10968kb

input:

1
100000 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1...

output:

Yes
99999 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 10...

result:

ok OK. (1 test case)

Test #16:

score: 0
Accepted
time: 67ms
memory: 21112kb

input:

1
100000 100
30 31 100 5 89 85 53 86 19 62 20 57 81 3 60 82 32 64 27 63 1 94 17 22 8 33 12 23 88 2 11
94 95 89 78 8 74 31 36 5 41 98 99 32 53 88 33 87 40 83 70 21 35 51 81 92 3 37 90 62 1 46 29 20 85 75 65 82 91 22 97 61 12 27 26 77 18 68 15 79 28 84 58 49 54 6 66 59 72 45 17 80 48 34 4 96 19 57 94 ...

output:

Yes
99999 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 10...

result:

ok OK. (1 test case)

Test #17:

score: 0
Accepted
time: 77ms
memory: 20512kb

input:

1
100000 1000
53 469 776 408 563 495 552 288 343 745 650 179 791 839 389 881 474 194 27 739 795 103 143 522 261 197 123 923 355 731 154 412 231 600 641 651 247 668 877 535 908 792 90 578 827 841 486 901 402 761 356 433 798 369
526 710 298 313 926 775 961 979 45 549 214 81 805 635 174 930 687 243 619...

output:

Yes
99953 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 10...

result:

ok OK. (1 test case)

Test #18:

score: 0
Accepted
time: 84ms
memory: 19400kb

input:

1
100000 10000
2094 5226 2958 8712 7230 6625 2487 4520 9360 2727 5423 5170 3199 3725 2419 9194 1946 9942 7780 9861 692 2218 5879 9116 3253 1191 710 8703 759 3019 3581 3648 105 6123 8494 6356 8000 3056 4478 2646 7457 2437 9669 4132 4585 8874 2930 9024 6773 132 4309 6496 8138 3514 531 4782 5854 1722 5...

output:

Yes
99938 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 10...

result:

ok OK. (1 test case)

Test #19:

score: 0
Accepted
time: 115ms
memory: 22644kb

input:

1
100000 100000
13036 23902 71466 9482 98728 78471 22915 2470 5999 53211 25994 3996 11349 30511 56448 17277 78308 18316 42069 38636 63127 26256 63985 57249 58305 64366 17839 28518 18980 95945 36316 6076 69530 96509 6940 6039 56048 41847 82118 41054 49670 95896 45891 74636 90736 75413 27251 87730 683...

output:

Yes
99838 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 10...

result:

ok OK. (1 test case)

Test #20:

score: 0
Accepted
time: 0ms
memory: 4260kb

input:

1
5000 100
75 80 60 100 11 49 87 84 71 37 92 2 46 24 41 95 20 42 70 74 43 76 68 82 89 15 4 35 72 9 88 93 28 3 64 75 53 97 29 8 48 61 14 1 65 66 10 13 56 21 96 52 83 67 77 30 34 57 99 47 44 91 7 55 59 50 22 63 36 90 31 45 94 40 32 86
43 80 25 67 32 5 65 63 46 81 75 88 100 3 42 62 93 23 76 70 1 60 43 ...

output:

Yes
4999 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...

result:

ok OK. (1 test case)

Test #21:

score: 0
Accepted
time: 4ms
memory: 5068kb

input:

1
5000 1000
588 107 686 736 517 845 211 644 553 738 430 476 252 504 471 297 958 534 484 602 514 855 989 58 957 261 380 308 316 807 42 328 364 239 73 163 215 915 844 401 112 714 873 946 716 230 951 655 294 120 10 712 683 819 415 63 745 433 321 15 542 670 690 377 956 866 697 37 416 269 488 645 986 631...

output:

Yes
4999 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...

result:

ok OK. (1 test case)

Test #22:

score: 0
Accepted
time: 6ms
memory: 5048kb

input:

1
5000 10000
2844 3485 9550 710 9862 1742 4261 3401 7862 8774 2066 6172 4182 3952 8588 7798 4471 9240 8355 3687 1282 4605 5038 4511 6460 7072 8161 7977 8564 3062 4731 6511 7854 8039 3908 8061 3691 6049 5433 1876 2772 5197 1426 881 1294 7260 6082 6478 2157 1710 8281 487 9210 545 9888 3886 6834 8549 3...

output:

Yes
2892 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...

result:

ok OK. (1 test case)

Test #23:

score: 0
Accepted
time: 12ms
memory: 7080kb

input:

1
5000 100000
39293 10913 5181 19479 73743 73041 44034 79530 53967 42351 11365 1224 25452 97871 63229 80000 8498 27936 81102 81043 59677 93828 44118 63275 53964 66063 26803 73527 72659 38043 86078 59238 11483 36144 7084 20768 41417 61851 74604 18748 13113 32530 38112 32969 30342 70998 60607 33987 15...

output:

Yes
1131 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...

result:

ok OK. (1 test case)

Test #24:

score: 0
Accepted
time: 36ms
memory: 15844kb

input:

1
100000 100000
1 99697
2 99697 62499
2 62499 65369
2 65369 38767
2 38767 49004
2 49004 41714
2 41714 25240
2 25240 40929
2 40929 74271
2 74271 97963
2 97963 88205
2 88205 44238
2 44238 73947
2 73947 88038
2 88038 34453
2 34453 94958
2 94958 48075
2 48075 26199
2 26199 66549
2 66549 43887
2 43887 35...

output:

Yes
89286 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 10...

result:

ok OK. (1 test case)

Test #25:

score: 0
Accepted
time: 14ms
memory: 10320kb

input:

1
50000 100000
1 46703
2 46703 55497
2 55497 23493
2 23493 17355
2 17355 85641
2 85641 40451
2 40451 91219
2 91219 41048
2 41048 12518
2 12518 24389
2 24389 41038
2 41038 57974
2 57974 1865
2 1865 75723
2 75723 90283
2 90283 20878
2 20878 13239
2 13239 55992
2 55992 21622
2 21622 32181
2 32181 8511
...

output:

Yes
14899 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 10...

result:

ok OK. (1 test case)

Test #26:

score: 0
Accepted
time: 21ms
memory: 13348kb

input:

1
100000 50000
1 17436
2 17436 38563
2 38563 6072
2 6072 44215
2 44215 23698
2 23698 6361
2 6361 10273
2 10273 19571
2 19571 9471
2 9471 12671
2 12671 31584
2 31584 31896
2 31896 2213
2 2213 28535
2 28535 32050
2 32050 14148
2 14148 22955
2 22955 19097
2 19097 19557
2 19557 354
2 354 18536
2 18536 3...

output:

Yes
99999 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 10...

result:

ok OK. (1 test case)

Test #27:

score: 0
Accepted
time: 19ms
memory: 11548kb

input:

1
100000 10000
1 1670
2 1670 9903
2 9903 8088
2 8088 386
2 386 8535
2 8535 8326
2 8326 997
2 997 5841
2 5841 1028
2 1028 1627
2 1627 2622
2 2622 7211
2 7211 5508
2 5508 1647
2 1647 6224
2 6224 4630
2 4630 8145
2 8145 5415
2 5415 4098
2 4098 5354
2 5354 8742
2 8742 6205
2 6205 1258
2 1258 3625
2 3625...

output:

Yes
99999 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 10...

result:

ok OK. (1 test case)

Test #28:

score: 0
Accepted
time: 19ms
memory: 11504kb

input:

1
100000 9999
1 1714
2 1714 7447
2 7447 7246
2 7246 2788
2 2788 3876
2 3876 7970
2 7970 5074
2 5074 6179
2 6179 2036
2 2036 7908
2 7908 6148
2 6148 1571
2 1571 1333
2 1333 988
2 988 1311
2 1311 1045
2 1045 1352
2 1352 5177
2 5177 5601
2 5601 8933
2 8933 2175
2 2175 5244
2 5244 7087
2 7087 6886
2 688...

output:

Yes
99999 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 10...

result:

ok OK. (1 test case)

Test #29:

score: 0
Accepted
time: 7ms
memory: 10456kb

input:

1
50000 100000
1 25288
2 25288 60248
2 60248 40896
2 40896 3119
2 3119 15191
2 15191 20054
2 20054 37056
2 37056 48410
2 48410 15293
2 15293 6218
2 6218 62584
2 62584 59101
2 59101 67460
2 67460 78740
2 78740 67628
2 67628 45650
2 45650 10725
2 10725 74693
2 74693 81131
2 81131 41197
2 41197 59032
2...

output:

No

result:

ok OK. (1 test case)

Test #30:

score: 0
Accepted
time: 25ms
memory: 13504kb

input:

1
100000 50000
1 16235
2 16235 5024
2 5024 5075
2 5075 15612
2 15612 1874
2 1874 46975
2 46975 23015
2 23015 22230
2 22230 24685
2 24685 27514
2 27514 19421
2 19421 3372
2 3372 30435
2 30435 47871
2 47871 41270
2 41270 29787
2 29787 7743
2 7743 16624
2 16624 27627
2 27627 423
2 423 9245
2 9245 16307...

output:

Yes
99999 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 10...

result:

ok OK. (1 test case)

Test #31:

score: 0
Accepted
time: 18ms
memory: 11480kb

input:

1
100000 10000
1 1702
2 1702 2977
2 2977 6117
2 6117 3553
2 3553 5771
2 5771 8991
2 8991 6852
2 6852 1631
2 1631 7411
2 7411 9172
2 9172 3814
2 3814 7048
2 7048 4376
2 4376 7515
2 7515 6310
2 6310 8715
2 8715 6085
2 6085 5902
2 5902 175
2 175 1347
2 1347 8011
2 8011 3487
2 3487 7329
2 7329 936
2 936...

output:

Yes
99999 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 10...

result:

ok OK. (1 test case)

Test #32:

score: 0
Accepted
time: 11ms
memory: 11836kb

input:

1
100000 9999
1 269
2 269 4842
2 4842 9066
2 9066 6409
2 6409 919
2 919 4609
2 4609 2210
2 2210 9333
2 9333 1082
2 1082 419
2 419 1588
2 1588 4379
2 4379 9750
2 9750 5183
2 5183 5999
2 5999 4545
2 4545 9101
2 9101 377
2 377 451
2 451 8999
2 8999 726
2 726 7163
2 7163 6671
2 6671 4989
2 4989 7806
2 7...

output:

Yes
99999 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 10...

result:

ok OK. (1 test case)

Test #33:

score: 0
Accepted
time: 29ms
memory: 15768kb

input:

1
100000 100000
1 40715
2 40715 69975
2 69975 81076
2 81076 50941
2 50941 61666
2 61666 58686
2 58686 77487
2 77487 43412
2 43412 11756
2 11756 38852
2 38852 25829
2 25829 14629
2 14629 40633
2 40633 79986
2 79986 7237
2 7237 95744
2 95744 98665
2 98665 75424
2 75424 75964
2 75964 99876
2 99876 3449...

output:

No

result:

ok OK. (1 test case)

Test #34:

score: 0
Accepted
time: 0ms
memory: 3756kb

input:

1
10 10
6 7 1 6 8 2 5
3 7 1 4
2 1 5
2 5 3
6 3 6 2 4 8 9
3 6 2 9
3 2 9 8
3 9 8 4
2 8 4
1 4

output:

No

result:

ok OK. (1 test case)

Test #35:

score: 0
Accepted
time: 0ms
memory: 3756kb

input:

1
5 10
8 8 10 5 7 6 3 1 4
4 1 6 5 7
5 7 6 1 10 3
5 6 3 10 9 1
2 3 1

output:

No

result:

ok OK. (1 test case)

Test #36:

score: 0
Accepted
time: 0ms
memory: 3832kb

input:

1
7 8
5 3 1 2 5 6
3 3 5 1
5 5 8 1 6 4
3 8 1 4
4 1 6 2 4
2 6 2
1 2

output:

No

result:

ok OK. (1 test case)

Test #37:

score: 0
Accepted
time: 9ms
memory: 6092kb

input:

1
2 100000
14270 46635 46698 1646 15716 2228 50409 74925 97781 74365 25891 12012 64493 21689 94826 36200 1632 24144 62892 32086 47204 79241 98139 79911 17992 46167 52734 60646 15562 38928 98569 3653 3671 78062 60439 55428 8130 90832 16564 66569 41939 90137 70795 10888 47855 26734 15687 58488 45392 1...

output:

No

result:

ok OK. (1 test case)

Test #38:

score: 0
Accepted
time: 4ms
memory: 5752kb

input:

1
1 100000
36897 18529 93504 47258 14497 23607 217 5522 37137 77238 60045 9885 11754 78586 36262 50169 94021 79684 70802 61672 70563 90359 26273 78607 54598 47388 39719 51290 60373 45630 10944 92439 87100 86543 99975 72598 87465 27042 92093 96656 71345 334 85993 31389 2345 23153 64562 93724 88845 65...

output:

No

result:

ok OK. (1 test case)

Test #39:

score: 0
Accepted
time: 0ms
memory: 3648kb

input:

1
3 3
2 1 3
2 1 2
3 1 2 3

output:

Yes
2 1 3 

result:

ok OK. (1 test case)

Test #40:

score: -100
Wrong Answer
time: 96ms
memory: 3692kb

input:

56035
9 9
7 1 7 3 6 8 4 2
2 8 4
3 6 3 5
3 6 7 2
7 5 3 9 1 2 8 4
6 8 9 7 3 1 6
8 3 4 9 5 1 6 7 8
5 9 8 7 5 1
2 3 2
9 4
1 4
4 3 2 4 1
3 2 3 1
1 1
1 3
3 3 4 1
3 3 2 1
4 3 1 4 2
3 3 4 1
4 10
8 2 7 3 6 1 9 8 5
5 6 4 8 7 5
3 2 8 6
6 3 4 1 8 2 5
10 10
4 3 8 1 2
3 2 9 10
3 1 7 9
6 9 7 10 3 4 8
10 9 3 5 10 8...

output:

Yes
6 1 2 3 4 5 7 8 9 
Yes
7 1 2 3 4 5 6 8 9 
No
Yes
8 1 2 3 4 5 6 7 9 10 
Yes
3 1 2 4 5 6 7 
Yes
5 1 2 3 4 6 
No
Yes
5 1 2 3 4 6 
No
No
Yes
7 1 2 3 4 5 6 8 
Yes
2 1 3 4 
Yes
5 1 2 3 4 6 
Yes
7 1 2 3 4 5 6 8 9 10 
Yes
3 1 2 4 5 
No
Yes
2 1 3 4 
No
Yes
2 1 
No
Yes
5 1 2 3 4 6 7 
Yes
2 1 3 4 5 
No
Yes...

result:

wrong answer jury found an answer but participant did not (test case 113)