MCPcopy Create free account
hub / github.com/acm-clan/algorithm-stone / main

Function main

user/codeforces/1607D.Blue-Red Permutation.cpp:13–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11}
12
13int main()
14{
15
16 scanf("%d",&T);
17 begin:
18 while(T--)
19 {
20 vector<int> blue,red;
21 scanf("%d",&n);
22 for(int i=1;i<=n;i++)
23 {
24 scanf("%d",&a[i]);
25 }
26 cin>>s+1;
27 for(int i=1;i<=n;i++)
28 {
29 if(s[i]=='B') blue.push_back(a[i]);
30 else red.push_back(a[i]);
31 }
32 sort(blue.begin(),blue.end());
33 sort(red.begin(),red.end(),cmp);
34 for(int i=0;i<red.size();i++)
35 {
36 if(red[i]>n-i)
37 {
38 cout<<"NO"<<endl;
39 goto begin;
40 }
41 }
42 for(int i=0;i<blue.size();i++)
43 {
44 if(blue[i]<i+1)
45 {
46 cout<<"NO"<<endl;
47 goto begin;
48 }
49 }
50 cout<<"YES"<<endl;
51 }
52
53
54
55 return 0;
56}

Callers

nothing calls this directly

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected