A(水题)
#include <bits/stdc++.h>
using namespace std;
struct node {
int x, y;
bool operator<(const node k) const {
return x < k.x;
}
} a[105];
int main()
{
int n, m, x, y;
cin >> n >> m;
for(int i = 0; i < n; ++i)
cin >> a[i].x >> a[i].y;
sort(a, a+n);
int now = 0;
for(int i = 0; i < n; ++i)
{
if(now >= a[i].x)
now = max(now, a[i].y);
}
if(now >= m) printf("YES\n");
else printf("NO\n");
return 0;
}
B(思维水题)
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e4+5;
vector<int> g[maxn];
int ans, n, col[maxn];
void dfs(int u, int fa)
{
if(col[u] != col[fa]) ++ans;
for(int i = 0; i < g[u].size(); ++i)
{
int v = g[u][i];
if(v == fa) continue;
dfs(v, u);
}
}
int main()
{
scanf("%d", &n);
for(int i = 2; i <= n; ++i)
{
int p;
scanf("%d", &p);
g[i].push_back(p);
g[p].push_back(i);
}
for(int i = 1; i <= n; ++i)
scanf("%d", &col[i]);
col[0] = -1, ans = 0;
dfs(1, 0);
printf("%d\n", ans);
return 0;
}
C(卡我英文水题)
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+5;
int h, a[maxn], key;
vector<int> ans;
int main()
{
scanf("%d", &h);
key = 0;
for(int i = 0; i <= h; ++i)
scanf("%d", &a[i]);
for(int i = 0; i < h; ++i)
if(a[i] != 1 && a[i+1] != 1)
key = i+1;
if(!key) puts("perfect");
else
{
int now = 0, pos, val;
puts("ambiguous");
for(int i = 0; i <= h; ++i)
{
for(int j = 1; j <= a[i]; ++j)
ans.push_back(now);
if(i == key)
{
pos = ans.size()-1;
val = now-1;
}
now += a[i];
}
for(int i = 0; i < ans.size(); ++i)
{
if(i) printf(" ");
printf("%d", ans[i]);
}
printf("\n");
ans[pos] = val;
for(int i = 0; i < ans.size(); ++i)
{
if(i) printf(" ");
printf("%d", ans[i]);
}
printf("\n");
}
return 0;
}
时间总是过得炒鸡快...
回家了一周,瘫了一周...
真是好久没做题了,比赛也结束了一个多月了,没有刷题的动力了,复习期末考试以及做学期项目,学期末尾的几天也被占去了,头条面试结束四周多了,三面的通知还是没来,肯定是凉了,答了网络,却凉了OS,二面的算法题想的肯定是最优了,但是不知道为什么感觉面试官好像没明白...感觉是中途多次来电话导致电脑断网给面试官留下坏印象了。准备重学OS、组成原理、网络、数据结构各类基础以及转型Java组蓝桥都还没行动起来...不是不想行动,而是在家庭氛围中使我懒惰。确定要春招了,考研与否还在心底打转。
心绪糟乱,就不写了...