开场lfw看J,被孪生素数误导,没有看出水题的本质,byf及时提醒后,lfw忘记N=1的情况要特判。之后byf写E,忘记开long long,wa+1。Shl看出A题思路,告诉lfw开始写A,lfw忘记先排序,WA+1。byf看出B题做法,lfw写java过掉,shl与lfw讨论G,lfw开始写G,byf看出C可以hash暴力,lfwG忘记清空一个值,导致特殊情况会加两次,wa+1,byf使用mp作hash,带logn常数TLE,随后转成long long的hash值,使用unordered_map过掉。最后lfw和shl讨论出H,lfw开始写H,H没过样例,shl和byf讨论出D题随机,开始上机写D,其中我们都不知道,swap(a[i],a[len-1]).a[i].pop_back()可以删掉vector中的一个元素,百度耗时。最后D题没过,H题没时间调,可惜。
Lfw和byf多次犯小错误,造成罚时很高,而且最后D题写慢,随机没能多交几次,H题没时间调,可惜。

题解


由于刚打完,先附上代码,后面会更新题解。

Thanks, TuSimple!

参考代码:

 1 #include<bits/stdc++.h>
 2 #define maxl 100010
 3 using namespace std;
 4 
 5 int n,m,ans;
 6 struct node
 7 {
 8     int h,p;
 9 }a[maxl];
10 int b[maxl];
11 int q[maxl];
12 set <int> s1,s2;
13 set <int> :: iterator it;
14 
15 inline void prework()
16 {
17     s1.clear();s2.clear();
18     scanf("%d%d",&n,&m);
19     for(int i=1;i<=n;i++)
20         scanf("%d",&a[i].h);
21     for(int i=1;i<=m;i++)
22         scanf("%d",&b[i]);
23         
24     for(int i=1;i<=n;i++)
25         scanf("%d",&a[i].p);
26     for(int i=1;i<=m;i++)
27     {
28         scanf("%d",&q[i]);
29         if(q[i]==0)
30             s1.insert(b[i]);
31         else
32             s2.insert(b[i]);
33     }
34 }
35 
36 inline bool cmp(const node &x,const node &y)
37 {
38     return x.h<y.h;
39 }
40 
41 inline void mainwork()
42 {
43     sort(a+1,a+1+n,cmp);
44     ans=0;
45     for(int i=1;i<=n;i++)
46     if(a[i].p==0)
47     {
48         it=s2.begin();
49         if(it!=s2.end())
50             if((*it)<a[i].h)
51             {
52                 ans++;
53                 s2.erase(it);
54             }
55     }
56     else
57     {
58         it=s1.upper_bound(a[i].h);
59         if(it!=s1.end())
60             if((*it)>a[i].h)
61             {
62                 ans++;
63                 s1.erase(it);
64             }
65     }
66 }
67 
68 inline void print()
69 {
70     printf("%d\n",ans);
71 }
72 
73 int main()
74 {
75     int t;
76     scanf("%d",&t);
77     for(int i=1;i<=t;i++)
78     {
79         prework();
80         mainwork();
81         print();
82     }
83     return 0;
84 }
View Code

相关文章: