QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#676647#7738. Equivalent RewritingONISINOWA 0ms3756kbC++202.0kb2024-10-25 22:47:292024-10-25 22:47:29

Judging History

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

  • [2024-10-25 22:47:29]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3756kb
  • [2024-10-25 22:47:29]
  • 提交

answer

#include <bits/stdc++.h>

//DEBUG:    https://github.com/sharkdp/dbg-macro
#ifdef LOCAL
#include "../dbg-macro-0.5.1/dbg.h"
#else
#define dbg(...) (__VA_ARGS__)
#endif

#define endl '\n'
using namespace std;
typedef long long ll;
typedef long double llf;
const ll MAXN=2e5+10,MOD=998244353,INF=1e9;

ll qpow(ll base,ll exp){ll ans=1;while(exp){if(exp&1)(ans*=base)%=MOD;(base*=base)%=MOD;exp>>=1;}return ans;}
template<class T>ll max_binary_answer(ll l,ll r,T check,bool cmp=true){ll m;while(l<r){m=(l+r+1)/2;if(cmp^!check(m))l=m;else r=m-1;}return l;}
template<class T>ll min_binary_answer(ll l,ll r,T check,bool cmp=true){ll m;while(l<r){m=(l+r)/2;if(cmp^!check(m))r=m;else l=m+1;}return r;}
ll exgcd(ll a,ll b,ll &x,ll &y){ll tmp;return b==0?(x=1,y=0,a):(tmp=exgcd(b,a%b,y,x),y-=(a/b)*x,tmp);}
ll highbit(ll x){for(ll i=1;i<(ll)sizeof(ll)*4;i<<=1)x|=x>>i;return x-(x>>1);}
ll lowbit(ll x){return x&(-x);}
//--------Global declared area--------

//--------Global declared end --------
void solve(int test_num){
	int n,m;
	cin>>n>>m;
	vector<vector<int>> a(m+1),b(n+1);
	vector<int> r(m+1),f(n+1,1e9);
	for(int i=1;i<=n;i++){
		int p;
		cin>>p;
		b[i].push_back(p);
		for(int j=0;j<p;j++){
			int tmp;
			cin>>tmp;
			a[tmp].push_back(i);
			b[i].push_back(tmp);
			r[tmp]=i;
		}
	}
//	dbg(a);
//	dbg(b);
//	dbg(r);
	
	if(n==1){
		cout<<"No"<<endl;
		return;
	}else{
		for(int i=1;i<=m;i++){
			if(a[i].empty()) continue;
			int up=a[i].back();
			//cout<<up<<endl;
			for(int j=0;j<(int)a[i].size()-1;j++){
				f[a[i][j]]=min(f[a[i][j]],up);
			}
			//dbg(f);
		}
		for(int i=1;i<n;i++){
			if(f[i]==1e9){
				cout<<"Yes"<<endl;
				for(int j=1;j<=n;j++){
					if(j==i) continue;
					cout<<j<<' ';
				}
				cout<<i<<endl;
				return;
			}
		}
		cout<<"No"<<endl;
	}
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr),std::cout.tie(nullptr);
	int t=1;
	cin>>t;
	for(int i=1;i<=t;i++){
		solve(i);
		//cout.flush();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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
1 3 2
No
No

result:

ok OK. (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3548kb

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:

No

result:

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