太后悔了,这次题目这么简单, 我没打,加不了分了啊啊啊啊啊啊,去年最难那次打了,分不高,所以后面没打了,不想浪费钱,结果这次这么简单,md太后悔了。
题目列表
词频统计
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
bool vis[102];
int a[102],b[102];
int main()
{
ios::sync_with_stdio(false);
cout.tie(0);
cin.tie(0);
int n, m;
cin >> n >> m;
int k;
for (int i = 1; i <= n; i++)
{
cin >> k;
int x;
for (int j = 1; j <= k; j++)
{
cin >> x;
b[x]++;
vis[x]=1;
}
for(int j=1;j<=m;j++)
{
if(vis[j])
{
a[j]++;
vis[j]=0;
}
}
}
for(int i=1;i<=m;i++)
{
cout<<a[i]<<' '<<b[i]<<endl;
}
}
相似度计算
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
set<string>st,v;
int main()
{
ios::sync_with_stdio(false);
cout.tie(0);
cin.tie(0);
int n, m;
cin >> n >> m;
string s;
for (int i = 1; i <= n; i++)
{
cin >> s;
int len = s.size();
for (int j = 0; j < len; j++)
{
if (s[j] < 'a')
s[j] += 'a' - 'A';
}
st.insert(s);
v.insert(s);
}
int ans=0;
for (int i = 1; i <= m; i++)
{
cin >> s;
int len = s.size();
for (int j = 0; j < len; j++)
{
if (s[j] < 'a')
s[j] += 'a' - 'A';
}
st.insert(s);
auto it=v.find(s);
if(it!=v.end())
{
ans++;
v.erase(it);
}
}
cout<<ans<<endl<<st.size();
}
化学方程式配平
#include <bits/stdc++.h>
#define int long long
#define endl "\n"
using namespace std;
int n, m;
double a[50][50];
void solve()
{
bool vis[50]={0};
cin >> n;
for (int i = 1; i < 50; i++)
{
for (int j = 1; j < 50; j++)a[i][j] = 0.0;
}
string s;
int cnt = 0;
map<string, int>mp;
int num ;
for (int i = 1; i <= n; i++)
{
string t = "";
cin >> s;
int j = 0;
int len = s.size();
num = 0;
while (j < len)
{
// cout<<s[j]<<endl;
if (s[j] >= '0' && s[j] <= '9')
{
num *= 10;
num += s[j] - '0';
}
else
{
if (num != 0)
{
// cout << ":" << t << ":" << endl;
if (mp[t] == 0)
{
++cnt;
mp[t] = cnt;
}
a[mp[t]][i] = num;
num = 0;
t = "";
}
t += s[j];
}
j++;
}
if (num != 0)
{
// cout << ":" << t << ":" << endl;
if (mp[t] == 0)
{
++cnt;
mp[t] = cnt;
}
a[mp[t]][i] = num * 1.0;
}
}
for (int j = 1; j <= n; j++)
{
int tg = 0;
a[tg][j] = 100.0;
for (int i = 1; i <= cnt; i++)
if(!vis[i])
{
if (fabs(a[i][j]) > 1e-6 && a[i][j] < a[tg][j])
{
tg = i;
}
}
if (tg == 0)continue;
vis[tg]=1;
for (int i = 1; i <= cnt; i++)
if (i != tg)
{
double b = a[i][j] / a[tg][j];
for (int g = j; g <= n; g++)
{
a[i][g] -= b * a[tg][g];
}
}
}
int ans = 0;
for (int i = 1; i <= cnt; i++)
{
bool flag = 0;
for (int j = 1; j <= n; j++)
{
if (fabs(a[i][j]) > 1e-6)flag = 1;
}
ans += flag;
}
if (ans < n)cout << "Y" << endl;
else cout << "N" << endl;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
while (t--)
{
solve();
}
return 0;
}
十滴水
看似1e9其实只有3e5,正解是链表,我懒得写,写了一版暴力,拿了55分溜了。
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
int c, m, n, mm;
int l,r;
struct str
{
int x, w;
} a[300010];
bool cmp(str a, str y)
{
return a.x < y.x;
}
void bao()
{
while (l > 0 && a[l].w == 0)l--;
while (r <= mm && a[r].w == 0)r++;
if (l > 0)
{
a[l].w += 1;
}
if (r <= mm)
{
a[r].w += 1;
}
if (l > 0 && a[l].w >= 5)
{
m--;
a[l].w = 0;
bao();
}
if (r <= mm && a[r].w >= 5)
{
m--;
a[r].w = 0;
bao();
}
}
void doo(int p)
{
a[p].w++;
if (a[p].w < 5)return;
m--;
a[p].w = 0;
l=p - 1;
r=p + 1;
bao();
}
map<int, int>mp;
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin >> c >> m >> n;
mm = m;
for (int i = 1; i <= mm; i++)
{
cin >> a[i].x >> a[i].w;
if (a[i].w <= 0)m--;
}
sort(a + 1, a + 1 + mm, cmp);
int p;
for (int i = 1; i <= mm; i++)
{
mp[a[i].x] = i;
}
// cout<<"aaaaaaaaa:"<<endl;
// for (int i = 1; i <= mm; i++)
// {
// cout << a[i].w << " ";
// }
// cout << endl;
while (n--)
{
cin >> p;
doo(mp[p]);
cout << m << endl;
}
return 0;
}