QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#216215#2881. Multithreaded Programkaruna#RE 7ms4584kbC++171.7kb2023-10-15 16:45:132023-10-15 16:45:14

Judging History

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

  • [2023-10-15 16:45:14]
  • 评测
  • 测评结果:RE
  • 用时:7ms
  • 内存:4584kb
  • [2023-10-15 16:45:13]
  • 提交

answer

#include <bits/stdc++.h>
#define ff first
#define ss second
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 100;
const int MAXM = 10000;

int N, K, sum;
int B[MAXM+10];
vector<pii> A[MAXN+10];
map<string, int> M1, M2;
vector<int> ans;
bool chk[MAXN+10];

int getnum(map<string, int> &M, string S)
{
	if(M.find(S)!=M.end()) return M[S];
	return M[S]=M.size()+1;
}

int main() {
	cin.tie(0); ios_base::sync_with_stdio(0);
	
	cin>>N;
	for(int i=1; i<=N; i++)
	{
		int sz;
		cin>>sz;
		sum+=sz;
		while(sz--)
		{
			string S;
			cin>>S;
			int x, y;
			for(int j=0; j<S.size(); j++)
			{
				if(S[j]=='=')
				{
					x=getnum(M1, string(S.begin(), S.begin()+j));
					y=getnum(M2, string(S.begin()+j+1, S.end()));
					break;
				}
			}
			A[i].push_back({x, y});
		}	
	}

	int sz;
	cin>>sz;
	string ttt; getline(cin, ttt);
	while(sz--)
	{
		string S;
		getline(cin, S);
		int x, y;
		for(int j=0; j<S.size(); j++)
		{
			if(S[j]==' ')
			{
				x=getnum(M1, string(S.begin(), S.begin()+j));
				y=getnum(M2, string(S.begin()+j+1, S.end()));
				break;
			}
		}
		B[x]=y;
	}

	for(int i=1; i<=N; i++)
	{
		for(auto &[x, y] : A[i])
		{
			if(B[x]==y) y=1;
			else y=0;
		}
	}

	while(1)
	{
		int t=0;
		for(int i=1; i<=N; i++)
		{
			if(A[i].empty()) continue;
			if(chk[A[i].back().first]) { t=i; break; }
			if(A[i].back().second) { t=i; break; }
		}
		if(!t)
		{
			if(ans.size()<sum)
			{
				cout<<"No\n";
				return 0;
			}
			break;
		}
		ans.push_back(t);
		chk[A[t].back().first]=true;
		A[t].pop_back();
	}
	cout<<"Yes\n";
	reverse(ans.begin(), ans.end());
	for(auto it : ans) cout<<it<<" ";
	cout<<"\n";
}

详细

Test #1:

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

input:

2
2
a=1
b=2
2
b=1
a=2
2
a 1
b 1

output:

No

result:

ok Ok

Test #2:

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

input:

3
5
start=1
counter=1111
counter=10
counter=3333
finish=1
4
start=2
counter=20
counter=10
finish=2
3
start=3
qwerty=787788
finish=3
4
counter 10
start 1
finish 1
qwerty 787788

output:

Yes
3 3 3 2 2 1 1 1 1 2 2 1 

result:

ok Ok

Test #3:

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

input:

3
3
cabababa=1
abacaba=1
babcbab=2
3
babcbab=1
cabababa=2
abacaba=2
3
babcbab=42
abacaba=42
cabababa=42
3
abacaba 1
babcbab 2
cabababa 42

output:

Yes
3 3 2 2 1 3 2 1 1 

result:

ok Ok

Test #4:

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

input:

100
100
smmhquvgjx=247136123
pybczmehmt=839411797
zopbsphrup=582478114
idgsybbejh=730374518
phoycmsxao=729846517
bhdxbmtqio=967044899
qjzehtbmuf=108641296
pownoizhwl=123976754
rxybqsoqij=913990849
gkdmbpazlo=360578547
bcufpdznrb=316190010
tcqqjnqglh=760097352
qgnufooojy=430399601
wifsqesaag=56570089...

output:

Yes
100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 ...

result:

ok Ok

Test #5:

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

input:

100
100
qsnwfpfwip=443164863
eusiwkzogm=70729371
ndqvfbhzpx=675885587
onuojvixib=848054796
kojkjqahes=814302212
azpudaivoo=133490435
yicihzlpmt=338895756
fatjvsdxsd=372128887
jvtoesayir=91134631
rlindhykbc=641822580
qawekkhydv=157354914
reqbsdptfm=907441580
mkslwmmyni=487546812
ylrrfzhirj=126649865
...

output:

Yes
100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 ...

result:

ok Ok

Test #6:

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

input:

100
100
paakedsdcj=537472201
ptlkqyobpp=839384683
qruqxuohfy=106866301
deltxyelrl=501777748
qparhscolt=483222981
fdmnperkpj=316983098
ldtuylxvga=26377226
nmochztkbh=869269562
dfcrmbsejj=927541998
rvitophrga=844151633
fjmsshfkav=193529115
gvliuqqlni=412904252
hqiueqvztu=238266408
eqftsxoffu=770345180...

output:

No

result:

ok Ok

Test #7:

score: -100
Runtime Error

input:

100
100
rgswjlhgsd=732363536
tutwxhuipw=620422431
rhzsvmxmqy=251793297
hrumcohbmc=583402876
kygxsczbrp=549154712
zkyckoaxvv=905632703
yxfpuhfrvf=20988013
hwbkufecuj=108991114
vtyifcskqe=374691674
xvijveegvo=844829717
inqfoamgwx=76187683
dqjvzxxqdf=365576892
ghbasgqvwx=338152732
ynsrkirkmq=246999547
...

output:


result: