last night BC and CF
数据支撑这个观点
the claim is backed with data
crank: 上下摆动!
programming contest winners are used to cranking solutions out fast
and that you performed better at the job if you were more reflective and went slowly and made sure things were right
hit the nail on the head
一针见血
今天遇到了一个 GCC编译需要动态链接库的问题,DLL,按道理设置静态链接就好了,如果本地有dll的话,
改成-static静态链接,也就是编译时直接链接到exe,这样不同机器都可以跑,但是却没有按照预期。
推荐一个数学题,偏数论题的网站,小胖发给我的。
https://projecteuler.net/problem=1
第一题和14年微软校招笔试第一题一样,beautiful string, 最好的方法就是编码 大法。但是我比赛的时候由于紧张,没有想到这个方法,导致改了很多次,浪费了时间。
最后写的是这个版本
while(cin>>str)
{
int i, n=str.size();bool ok=1;
for(i=1;str[i]==str[0] && i<n;i++);
if(i*3==n)
{
if(!(str[0]!=str[i] && str[0]!=str[2*i] && str[i]!=str[2*i])) {puts("NO");continue;}
string s2(i, str[i]);
string s3(i, str[2*i]);
if(s2!=str.substr(i, i) || s3!=str.substr(2*i, i)) {puts("NO");continue;}
puts("YES");
}
else puts("NO");
}
瞿神指导的编码大法应该来说是最简洁安全的
while(cin>>str)
{
v.clear();
int cnt=0;n=str.size();
for(int i=0;i<n;i++)
{
if(i && str[i]!=str[i-1])
{
v.push_back({str[i-1], cnt});
cnt=1;
}
else cnt++;
}
v.push_back({str[n-1],cnt});
cout<<v.size()<<" "<<v[0].cnt<<" "<<v[1].cnt<<" "<<v[2].cnt<<endl;
if(v.size()==3 && v[0].cnt==v[1].cnt && v[1].cnt==v[2].cnt &&
v[0].c!=v[1].c && v[0].c!=v[2].c && v[1].c!=v[2].c)
puts("YES");
else puts("NO");
}
第二题没啥算法,直接map就好了,数据结构题,掐输入这种其实对面试没啥帮助
CF第一题虽然复杂度写高了,但是不影响结果。第二题是一道思维题,一开始没有想清楚,就写。一定拿个一般的例子走一遍,确定无误了,再写。
其实就是算每颗子树的最长路径,从下往上递推,然后再从上往下算差值。