
Untitled
By: a guest on
Aug 12th, 2012 | syntax:
C++ | size: 1.44 KB | hits: 13 | expires: Never
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <limits.h>
#include <limits>
#include <stdio.h>
#include <stdlib.h>
#include <cstring>
#include <sstream>
using namespace std;
int Z, n, m, ti, ans[1000005], x[1000005];
set <int> s;
int main(){
scanf("%d", &Z);
while(Z--){
scanf("%d %d", &n, &m);
memset(x, 0, sizeof x);
memset(ans, -1, sizeof ans);
bool wrong = false;
for(int i = 0; i < m; i++){
scanf("%d", &ti);
--ti;
if(ti == -1){
s.insert(i);
ans[i] = 0;
}else{
set <int> :: iterator d = s.lower_bound(x[ti]);
if(d == s.end())wrong = true;
else{
ans[(*d)] = ti + 1;
s.erase(d);
}
x[ti] = i;
}
}
if(wrong)printf("NO\n");
else{
printf("YES\n");
bool first = true;
for(int i = 0; i < m; i++)
if(ans[i] != -1){
if(first)first = false;
else printf(" ");
printf("%d", ans[i]);
}
printf("\n");
}
s.clear();
}
return 0;
}