这最后一场,本来半场的时候就已经开始坐牢了,但是还真就给我写出来了,不过好像还是签到题...
上了一点难度,坐牢1.5h,那个图论想了个分层图,但是不会写
好不容易完整参加了一场,仅作记录
我已经能够想象暑期多校时候的场景了,开题—坐牢

1001
/*
6:00 -18 -> 12
flg -= h
24 - flg
*/
#include <bits/stdc++.h>
using namespace std;
void solve()
{
int m; cin >> m;
while(m--)
{
string s, t; cin >> s; cin >> t;
int h = stoi(s.substr(0,2));
int w = stoi(t.substr(1));
int flg = (t[0] == '+' ? 1 : -1);
int nh;
if(h < w && flg < 0)
{
nh = (h + w) % 24;
}// 6 - 18 (h + w) %24
else nh = (h + flg * w) % 24;
string ans = s.substr(2);
bool add = 0;
if(nh<10) add = 1;
ans = to_string(nh) + ans;
if(add) ans = "0" + ans;
cout << ans << '\n';
}
}
int main()
{
int t; cin >> t;while(t--)
solve();return 0;
}
1003
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 5e5 + 10;
int cnt[N];
void solve() {
int n; cin >> n;
fill(cnt,cnt+n+1,0);
int mx = 0;
for(int i = 1, x; i <= n; i++)
{
cin >> x;
cnt[x]++;
mx = max(mx,x);
}
ll ans = 0;
for(int d = 1; d <= mx; d++)
{
for(int m = d; m+d <= mx; m+=d)
{
if(cnt[m] && cnt[m+d]) ans += 1LL*cnt[m]*cnt[m+d];
}
}
cout << ans << '\n';
}
int main() {
ios::sync_with_stdio(0);cin.tie(0);
int _; cin >> _; while(_--)
solve();return 0;
}
1005
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 2e5 + 10;
int n, m, a[N], t;
void solve()
{
cin >> t >> n >> m;
for(int i = 1; i <= n; i++) cin >> a[i];
sort(a+1,a+n+1);
ll sum = 0;
for(int i = 1; i <= m; ++i) sum += a[i];
if(sum>t)
{
cout << -1 << '\n';
return;
}
int ans = (t - sum)/40;
cout << ans << '\n';
}
int main()
{
ios::sync_with_stdio(0);cin.tie(0);
int t; cin >> t; while(t--)
solve();return 0;
}
1008
/*
dp[i]:前i个人选择到的最大值
贪心?
每个人先选择最大值,并且计数,
不对,这是相互影响的
还是dp,限制人数,这样的dp好像做过,菜肴那道
P5664,给我找到了
Yazid 不希望品尝太多同一食材做出的菜,因此他要求每种主要食材至多在一半的菜(即 ⌊k/2⌋ 道菜)中被使用
就算找到了,我也不懂啊...因为之前就没理解,难崩
还得肝洛谷
how to do?
再想想,今天估计就哉在这里了,头一次做这么多AWA
如果暴力怎么做?
双DP?最大和次大肯定要
钦定第k个是不n/2个人选择,然后就是max(sum)?
那要怎么玩?
*/
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define dwn(i,a,b) for(int i = a; i >= b; i--)
#define vi vector<int>
#define all(v) v.begin(), v.end()
typedef long long ll;
template <typename T> bool chkmin(T &x, T y) {return y < x ? x = y, 1 : 0;}
template <typename T> bool chkmax(T &x, T y) {return y > x ? x = y, 1 : 0;}
const int N = 110, M = 1010;
int n, m, a[N][M], cnt[N];
vector<pair<int,int>> mx, smx;
void solve(){
cin >> n >> m;
mx.assign(n+1,{0,-1}), smx.assign(n+1,{0,-1});
for(int i = 1; i <= n; ++i)
{
for(int j = 1; j <= m;++j)
{
cin>>a[i][j];
if(a[i][j] > mx[i].first)
{
smx[i] = mx[i]; // 继承
mx[i] = {a[i][j], j};
}
else if(a[i][j] > smx[i].first) smx[i] = {a[i][j], j};
}
}
ll sum = 0;
for(auto [val, pos] : mx)
{
sum += val;
cnt[pos]++;
}
bool flg = 0;
int F = n/2;
for(int i = 1; i <= m; ++i) if(cnt[i]>F)flg = 1;
if(flg)
{
cout << sum << '\n';
}else{
ll ans = 0;
for(int k = 1; k <= m; k++)
{
ll sk = 0;
vector<int> vec(n);
for(int i = 0, op; i < n; i++)
{
if(mx[i+1].first == k) op = smx[i+1].first;
else op = mx[i+1].first;
sk += op;
vec[i] = a[i+1][k] - op;
}
sort(vec.begin(), vec.end(), greater<int>());
for(int i = 0; i <= F; ++i) sk += vec[i];
ans = max(ans, sk);
}
cout << ans << '\n';
}
}
int main(){
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int _;cin>>_;while(_--)
solve();return 0;
}
昨天玩了一天hdu,一点书没读,也是考试月前最后的狂欢了,踏上每天9h的复习之路了,下次就是暑假更新博客了,maybe~

浙公网安备 33010602011771号