NOIP2023 春测 游记
祝大家 rp++ 进省队。
Day -7
开坑。
NOIP 选手不会 Dinic?NOIP 选手不会 Dinic?NOIP 选手不会 Dinic?
速通了。
有 ARC,CF。掉蓝预定。
upd: 都上分了()
Day -6
做了点题,打了 ABC,下分,寄。
ngg 大佬 AC 七题 Orz
Day -5~-1
whk。
Day 0
T1: 典
T2: 考场上推着调着发现
容斥了下就(样例)过了,复杂度是
T3: 由于经验(什),T3 一般都是最难,压在最后做。
看数据范围前以为是 NPC()
状压写挂没调出来。听说样例特水,我连样例都没过,铁定寄了,不如打暴力 awa
T4:
估分:100+100+0+65
代码还没下发,且看洛谷能测多少分。upd: 100+100+65+40?????????????????
本来还想打下 CF,但是时间太阴间了/dk
总结:Genshin Impact!!!!111
贴个代码:
#include <bits/stdc++.h>
using namespace std;
int nxtr[100010], nxtc[100010], prer[100010], prec[100010];
int n, m, q, a[1000010];
bool visr[100010], visc[100010];
struct Query {
int op, x, c;
}qr[1000010];
#define ID(x,y) (((x)-1)*m+(y)-1)
int main()
{
freopen("paint.in", "r", stdin);
freopen("paint.out", "w", stdout);
ios::sync_with_stdio(0);
cin.tie(0);
int T; cin >> T;
while(T--)
{
cin >> n >> m >> q;
for(int i = 1; i <= q; ++i)
{
cin >> qr[i].op >> qr[i].x >> qr[i].c;
}
for(int i = 1; i <= n+1; ++i) prer[i] = i-1, nxtr[i-1] = i;
for(int i = 1; i <= m+1; ++i) prec[i] = i-1, nxtc[i-1] = i;
for(int i = q; i >= 1; --i)
{
if(qr[i].op == 0)
{
if(visr[qr[i].x]) continue;
visr[qr[i].x] = true;
for(int j = nxtc[0]; j != m+1; j = nxtc[j])
a[ID(qr[i].x,j)] = qr[i].c;
prer[nxtr[qr[i].x]] = prer[qr[i].x];
nxtr[prer[qr[i].x]] = nxtr[qr[i].x];
} else {
if(visc[qr[i].x]) continue;
visc[qr[i].x] = true;
for(int j = nxtr[0]; j != n+1; j = nxtr[j])
a[ID(j,qr[i].x)] = qr[i].c;
prec[nxtc[qr[i].x]] = prec[qr[i].x];
nxtc[prec[qr[i].x]] = nxtc[qr[i].x];
}
}
for(int i = 0; i < n; ++i, cout << '\n')
for(int j = 0; j < m; ++j)
{
if(j) cout << ' ';
cout << a[i*m+j];
}
for(int i = 0; i < n*m; ++i) a[i] = 0;
for(int i = 1; i <= q; ++i)
visr[qr[i].x] = visc[qr[i].x] = false;
}
cout.flush();
return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n; int k;
vector <int> pri;
long long qpow(int m, int b)
{
long long ans = 1, Mx = 0x7fffffffffffffffll;
for(int i = 1; i <= b; ++i)
if(ans <= Mx/m)
ans *= m;
else return Mx;
return ans;
}
int Mysq(ll a, int b)
{
int l = 1, r = 1000000010;
while(l < r)
{
int mid = (l+r+1)>>1;
if(qpow(mid, b) <= a) l = mid;
else r = mid-1;
}
return l;
}
int main()
{
freopen("power.in","r",stdin);
freopen("power.out","w",stdout);
ios::sync_with_stdio(0);
cin >> n >> k;
if(k == 1)
{
cout << n << '\n'; cout.flush(); return 0;
}
pri.push_back(2);
pri.push_back(3);
pri.push_back(5);
pri.push_back(7);
pri.push_back(11);
pri.push_back(13);
pri.push_back(17);
pri.push_back(19);
pri.push_back(23);
pri.push_back(29);
pri.push_back(31);
long long ans = 1;
for(int b = k; (1ll<<b) <= n; ++b)
{
long long ans2 = Mysq(n, b);
long long u = ans2; --ans2;
for(int bb = (int)pri.size()-1; bb >= 0; --bb)
{
ans2 -= Mysq(u, pri[bb])-1;
}
for(int bb = 2; bb < (int)pri.size()-1; ++bb)
ans2 += Mysq(u, 3*pri[bb])-1,
ans2 += Mysq(u, 2*pri[bb])-1;
ans2 += Mysq(u, 6)-1;
if(u >= (1ll<<30)) --ans2;
ans += ans2;
}
cout << ans <<'\n'; cout.flush();
return 0;
}
#include <bits/stdc++.h>
//#include <windows.h>
using namespace std;
#define double long double
const double eps = 1e-13;
struct Point {
double x, y;
Point(double x=0,double y=0):x(x),y(y){}
} a[1010];
double d[1<<18][18];//, mn[1<<18][18];
int p[1<<18][18];
double dis(Point A, Point B)
{
return sqrtl((A.x-B.x)*(A.x-B.x)+(A.y-B.y)*(A.y-B.y));
}
void print(int S, int i)
{//cout<<S<<' '<<i<<'\n';
if(!(S&(S-1))) {cout << i+1 << ' '; return;}
//if(!((S>>p[S][i])&1)) exit(1);
print(S^(1<<i), p[S][i]);
cout << i+1 << ' ';
//Sleep(1000);
}
int main()
{
freopen("tree.in","r",stdin);
freopen("tree.out","w",stdout);
ios::sync_with_stdio(0);
int n; cin >> n;
for(int i = 0; i < n; ++i) cin >> a[i].x >> a[i].y;
if(n <= 18)
{
for(int i = 0; i < (1<<n); ++i)
for(int j = 0; j < n; ++j)
d[i][j] = 1e18;
#if 0
for(int i = 0; i < n; ++i) mn[0][i] = 1e18;
for(int i = 0; i < (1<<n); ++i)
{
if(!(i&(i-1)))
{
int x = __lg(i);
for(int j = 0; j < n; ++j)
mn[i][j] = dis(a[x], a[j]);
continue;
}
for(int j = 0; j < n; ++j)
if((i>>j)&1) mn[i][j] = 0;
else mn[i][j] = min(mn[i^(i&-i)][j],mn[i&-i][j]);
}
#endif
int mx = 0;
for(int i = 1; i < n; ++i)
if(a[i].y > a[mx].y)
mx = i;
d[1<<mx][mx] = 0;
for(int S = 1; S < (1<<n); ++S)
if((S&(1<<mx)) && (S^(1<<mx)))
{
for(int i = 0; i < n; ++i)
if(((S>>i)&1) && i != mx)
{
for(int j = 0; j < n; ++j)
if(((S>>j)&1) && j != i)
d[S][i] = min(d[S][i], d[S^(1<<i)][j]+dis(a[i],a[j]));
for(int j = 0; j < n; ++j)
if(((S>>j)&1) && j != i && fabs(d[S][i]-d[S^(1<<i)][j]-dis(a[i],a[j])) < eps)
p[S][i] = j;
//cout<<S<<' '<<i<<' '<<p[S][i]<<'\n';
}
}//exit(0);
int ed = mx==0?1:0;
for(int i = 1; i < n; ++i)
if(i != mx && d[(1<<n)-1][i] < d[(1<<n)-1][ed]) ed = i;
//cout<<ed<<' '<<mx<<'\n'; exit(0);
print((1<<n)-1, ed);
cout << '\n';
}
else
{
for(int i = 1; i <= n; ++i)
cout << i <<' ' ;
cout<<'\n';
}
cout.flush();
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int a[4][500010];
int T, n, k, vis[500010];
bool pd(int m)
{
int _mx = 0, _mn = 0x3f3f3f3f;
for(int i = 0; i < k; ++i)
for(int j = 0; j < n; ++j)
_mx = max(_mx, a[i][j]),
_mn = min(_mn, a[i][j]);
for(int i = 1; i < 3; ++i)
{
for(int j = 0; j < n; ++j)
vis[j] = 0;
for(int j = 0; j < n; ++j)
for(int x = 0; x < k; ++x)
if(a[x][j] < _mx-m || a[(i+x)%k][j] > _mn+m)
vis[j] |= 1<<x;
bool ok = true;
for(int i = 0; i < n; ++i) if(vis[i] == 7) {ok = false; break;}
if(!ok) continue;
int R = 0x3f3f3f3f, L = -(0x3f3f3f3f);
for(int j = 0; j < n; ++j)
{
int _mx = 0, _mn = 0x3f3f3f3f;
for(int x = 0; x < k; ++x)
if(!((vis[j]>>x)&1))
{
_mx = max(_mx, a[(3-i+x)%k][j]);
_mn = min(_mn, a[(3-i+x)%k][j]);
}
R = min(R, _mx);
L = max(L, _mn-m);
}
if(L <= R) return true;
}
return false;
}
void solve1()
{
int L = 0, R = 60000;
while(L < R)
{
int mid = (L+R)>>1;
if(pd(mid)) R = mid;
else L = mid+1;
}
cout << L << '\n';
}
int main()
{
freopen("lock.in", "r", stdin);
freopen("lock.out", "w", stdout);
ios::sync_with_stdio(0); cin.tie(0);
cin >> T >> k;
while(T--)
{
cin >> n;
for(int i = 0; i < k; ++i)
for(int j = 0; j < n; ++j)
cin >> a[i][j];
if(k == 1)
{
int _mx = 0, _mn = 0x3f3f3f3f;
for(int i = 0; i < n; ++i)
_mx = max(_mx, a[0][i]),
_mn = min(_mn, a[0][i]);
cout << _mx-_mn << '\n'; continue;
}
if(k == 2)
{
for(int i = 0; i < n; ++i)
if(a[0][i] < a[1][i]) swap(a[0][i], a[1][i]);
int ans = 0;
for(int i = 0; i < 2; ++i)
{
int _mx = 0, _mn = 0x3f3f3f3f;
for(int j = 0; j < n; ++j)
_mx = max(_mx, a[i][j]),
_mn = min(_mn, a[i][j]);
ans = max(ans, _mx-_mn);
}
cout << ans << '\n'; continue;
}
if(n <= 10)
{
int Ans = 0x3f3f3f3f;
for(int i = 0; i < (1<<(2*n)); ++i)
{
int ans = 0;
for(int j = 0; j < k; ++j)
{
int _mx = 0, _mn = 0x3f3f3f3f;
for(int u = 0; u < n; ++u)
_mx = max(_mx, a[(j+((i>>(u<<1))&3))%k][u]),
_mn = min(_mn, a[(j+((i>>(u<<1))&3))%k][u]);
ans = max(ans, _mx-_mn);
}
Ans = min(Ans, ans);
}
cout << Ans << '\n'; continue;
}
if(k == 3) solve1();
}
cout.flush();
return 0;
}
UPD: 多余文件没删,不知道会不会寄。
UUPD: 没寄。100+100+10+50(T3 啊啊啊啊啊啊)
恭喜 ningago 获 GS 第一!!!11 Orz