Start: Jul, 03, 2019 08:38:00
2019年度暑期短学期第七天 助教场
End: Jul, 04, 2019 23:00:00
Time elapsed:
Time remaining:

Problem_ID: G
Result: Accepted
Time: 26ms
Memory: 1760kB
Author: 2018212212064
In contest: 1292

#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <string>
#include <iostream>
#include <list>
#include <cstdlib>
#include <bitset>
#define lowbit(x) (x&(-x))
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
const int inf = 0x3f3f3f3f;
using namespace std;
const int mod = 110;
struct node
{
	int k, id, v;
	bool operator < (const node& other)const
	{
		if (v != other.v)
			return v < other.v;
		if (k != other.k)
			return k > other.k;
		return id < other.id;
	}
	node() {}
	node(int _k,int _id,int _v):k(_k),id(_id),v(_v) {}
} temp;

long long qmod(long long a, long long n)
{
	long long ans = 1;
	long long t = a;
	while (n)
	{
		if (n & 1)
			ans = ans * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	if (ans == 0)
		return t;
	return ans;
}

int main()
{
	int T;
	scanf("%d", &T);
	while (T--)
	{
		int n, h, k;
		int v;
		priority_queue<node> q;
		scanf("%d%d%d", &n, &h, &k);
		if (h > k)
			q.push(node(0, 0, h - k));
		for (int i = 1; i <= n; ++i)
		{
			scanf("%d", &v);
			q.push(node(1, i, v));
		}
		int attack = (k * k) % mod;
		int id = 0;
		if (h > k)
		{
			while (1)
			{
				temp = q.top();
				q.pop();
				temp.v -= attack == 0 ? k : attack;
				if (temp.v <= 0)
				{
					id = temp.id;
					break;
				}
				attack = (attack * k) % mod;
				q.push(temp);
			}
		}
		if (id != 0)
		{
			puts("No");
			printf("%d\n", id);
		}
		else
		{
			stack<node> sta;
			while (!q.empty())
			{
				temp = q.top();
				q.pop();
				sta.push(temp);
			}
			puts("Yes");
			while (!sta.empty())
			{
				temp = sta.top();
				sta.pop();
				printf("%d%c", temp.v, " \n"[sta.empty()]);
			}
		}
	}
//	system("pause");
}