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組藍橋都還沒行動起來...不是不想行動,而是在家庭氛圍中使我懶惰。確定要春招了,考研與否還在心底打轉。
心緒糟亂,就不寫了...