版本比较
cuiyunqi1229
个人介绍
增加 49 行删除 298 行
47 行未改动484950515253545556575859606162636465666768697071727374757677787980818283848586878889909152535455565758596061949596979899100101102103104105106107108109110111112113114115116117118119120121122626364656667686970717212512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527673747527928028128228328428528628728828929029129229329476777879808182838485868788899091929394952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263279697989910010110210310410510610710832933033133233333433533633733833934034134234334434534634734834935035135235335435535635710911011147 行未改动远灯明,希望生, 终夜魂灵破迷津, 漂泊者,得安身。**
瞎写的模拟赛代码:```cpp/*#include<bits/stdc++.h>using namespace std;int t;int main(){ freopen("xorpath.in","r",stdin); freopen("xorpath.out","w",stdout); ios::sync_with_stdio(0); cin.tie(0); cin>>t; while(t--){ long long x,y,max_i=0; cin>>x>>y; long long ans=x^y; cout<<x+y<<" "; if(x==0){ cout<<0<<"\n"; continue; } queue<long long>q; q.push(x^y); while(x>0){ x--; y++; q.push(x^y); } int cs=0; while(!q.empty()){ if(ans<q.front()){ ans=q.front(); max_i=cs; } cs++; q.pop(); } cout<<max_i<<"\n"; } return 0;}*/*Raindrops keep fallin' on my head And just like the guy whose feet are too big for his bed Nothin' seems to fit Those raindrops are fallin' on my head, they keep fallin'*
*So I just did me some talkin' to the sun And I said I didn't like the way he got things done Sleepin' on the job Those raindrops are fallin' on my head, they keep fallin'*
#include <bits/stdc++.h>using namespace std;typedef long long ll;ll maxSubmaskLE(ll S, ll x) { ll a = 0; for (int i = 28; i >= 0; --i) { if (!(S & (1LL << i))) continue; ll cand = a | (1LL << i); if (cand <= x) { a = cand; } } return a;}int main() { freopen("xorpath.in", "r", stdin); freopen("xorpath.out", "w", stdout); ios::sync_with_stdio(false); cin.tie(nullptr); int t; cin >> t; while (t--) { ll x, y; cin >> x >> y; ll S = x + y,a = maxSubmaskLE(S, x),xor_val = S,ops=x-a; cout<<xor_val<<" "<<ops<<"\n"; } return 0;}*But there's one thing I know The blues they send to meet me won't defeat me It won't be long till happiness steps up to greet me*
*Raindrops keep fallin' on my head But that doesn't mean my eyes will soon be turnin' red Cryin's not for me 'Cause I'm never gonna stop the rain by complainin' Because I'm free Nothin's worryin' me*
/*#include<bits/stdc++.h>using namespace std;const int MOD=1e9+7;int n,a[100005][2];long long ans;int main(){ freopen("segmentcraft.in","r",stdin); freopen("segmentcraft.out","w",stdout); ios::sync_with_stdio(0); cin.tie(0); cin>>n; for(int i=1;i<=n;i++){ cin>>a[i][1]>>a[i][2]; } for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ if(a[i][2]>a[j][1]||a[j][2]>a[i][1])ans+=1; else ans+=2; ans%=MOD; } } cout<<ans; return 0;}*/
#include<bits/stdc++.h>using namespace std;typedef long long ll;const int P=1e9+7,N=200005;int n,m,t[N];ll p[N],ans;struct S{int l,r;}a[N];bool operator<(const S&x,const S&y){return x.l<y.l;}void add(int x){for(;x<=m;x+=x&-x)t[x]++;}int qry(int x){int s=0;for(;x;x-=x&-x)s+=t[x];return s;}int main(){ freopen("segmentcraft.in","r",stdin); freopen("segmentcraft.out","w",stdout); scanf("%d",&n); m=n<<1; p[0]=1; for(int i=1;i<=n;i++)p[i]=p[i-1]*2%P; for(int i=0;i<n;i++)scanf("%d%d",&a[i].l,&a[i].r); sort(a,a+n); for(int i=0;i<n;i++){ int k=i-qry(a[i].l-1); ans=(ans+p[n-1-k])%P; add(a[i].r); } printf("%lld\n",ans); return 0;}
/*#include<bits/stdc++.h>using namespace std;int n,a[1005][3],l;int main(){// freopen("ribbonmix.in","r",stdin);// freopen("ribbonmix.out","w",stdout); ios::sync_with_stdio(0); cin.tie(0); cin>>n>>l; bool b=true; for(int i=1;i<=n;i++){ cin>>a[i][1]>>a[i][2]>>a[i][3]; } if(n==1&&a[1][1]==l){ cout<<a[1][2]; return 0; } for(int i=2;i<=n;i++){ for(int j=2;j<=n;j++){ if(a[i][3]!=a[j][3]){ b=false; } } } if(b==true){ cout<<-1; } return 0;}*/
#include<bits/stdc++.h>using namespace std;typedef long long ll;const ll INF=-1e18;int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); freopen("ribbonmix.in","r",stdin); freopen("ribbonmix.out","w",stdout); int n,L; cin>>n>>L; vector<int>l(n),v(n),raw_c(n); for(int i=0;i<n;i++)cin>>l[i]>>v[i]>>raw_c[i]; vector<int>sc=raw_c; sort(sc.begin(),sc.end()); sc.erase(unique(sc.begin(),sc.end()),sc.end()); vector<int>c(n); for(int i=0;i<n;i++)c[i]=lower_bound(sc.begin(),sc.end(),raw_c[i])-sc.begin(); vector<ll>mx(L+1,INF),sec(L+1,INF); vector<int>mc(L+1,-1); mx[0]=0;mc[0]=-1; for(int i=0;i<n;i++){ if(l[i]>L)continue; for(int k=L-l[i];k>=0;k--){ ll prev=INF; if(k==0&&mx[0]==0){prev=0;} else if(mx[k]!=INF){ if(mc[k]!=c[i])prev=mx[k]; else if(sec[k]!=INF)prev=sec[k]; } if(prev==INF)continue; int t=k+l[i]; ll nv=prev+v[i]; if(mx[t]==INF||nv>mx[t]){ if(mx[t]!=INF&&mc[t]!=c[i]&&mx[t]>sec[t])sec[t]=mx[t]; mx[t]=nv;mc[t]=c[i]; }else if(c[i]!=mc[t]&&nv>sec[t]){ sec[t]=nv; } } } cout<<(mx[L]==INF?-1:mx[L])<<"\n"; return 0;}
#include<bits/stdc++.h>using namespace std;
int main(){// freopen("graphquest.in","r",stdin);// freopen("graphquest.out","w",stdout); ios::sync_with_stdio(0); cin.tie(0); return 0;}
```cpp#include <bits/stdc++.h>using namespace std;const int MAXN = 405,INF = 0x3f3f3f3f;struct Edge { int to, w;};int n, m, q;uint16_t ans_table[MAXN][MAXN][MAXN];int dist[MAXN];void solve() { cin >> n >> m >> q; vector<tuple<int, int, int>> edges(m); set<int> wset; for (int i = 0; i < m; ++i) { int u, v, w; cin >> u >> v >> w; edges[i] = {u, v, w}; wset.insert(w);int n,m; int main() { cin>>n; unordered_map<string,vector<int>> mp[6]; for(int i=0;i<n;++i){ int id; string s; cin>>id; getline(cin,s); mp[1][s].push_back(id); getline(cin,s); mp[2][s].push_back(id); getline(cin,s); stringstream ss(s); while(ss>>s) mp[3][s].push_back(id); getline(cin,s); mp[4][s].push_back(id); getline(cin,s); mp[5][s].push_back(id); } vector<int> weights(wset.begin(), wset.end()); sort(weights.begin(), weights.end()); int V = weights.size(); for (int idx = 0; idx < V; ++idx) { int thresh = weights[idx]; vector<vector<Edge>> adj(n + 1); for (const auto& [u, v, w] : edges) { int cost = (w > thresh) ? 1 : 0; adj[u].push_back({v, cost}); adj[v].push_back({u, cost}); } for (int s = 1; s <= n; ++s) { fill(dist, dist + n + 1, INF); deque<int> dq; dist[s] = 0; dq.push_back(s); while (!dq.empty()) { int u = dq.front(); dq.pop_front(); for (const auto& e : adj[u]) { int nd = dist[u] + e.w; if (nd < dist[e.to]) { dist[e.to] = nd; if (e.w == 0) dq.push_front(e.to); else dq.push_back(e.to); } } } for (int t = 1; t <= n; ++t) { ans_table[s][t][idx] = (dist[t] < INF) ? (uint16_t)dist[t] : 400; } } for(int t=1;t<=5;++t) for(auto& p:mp[t]) sort(p.second.begin(),p.second.end()); cin>>m; while(m--){ string line; getline(cin,line); cout<<line<<"\n"; int t=line[0]-'0'; string key= ine.substr(3); auto it=mp[t].find(key); if(it==mp[t].end()||it->second.empty())cout<<"Not Found\n"; else for(int id:it->second) printf("%07d\n",id); } bool first = true; for (int i = 0; i < q; ++i) { int a, b, k; cin >> a >> b >> k; int need = k - 1; int lo = 0, hi = V - 1, res_idx = V - 1; while (lo <= hi) { int mid = (lo + hi) >> 1; if (ans_table[a][b][mid] <= need) { res_idx = mid; hi = mid - 1; } else { lo = mid + 1; } } if (!first) cout << ' '; cout << weights[res_idx]; first = false; } cout << '\n';}int main() { ios::sync_with_stdio(false); cin.tie(nullptr); freopen("graphquest.in", "r", stdin); freopen("graphquest.out", "w", stdout); int t; cin >> t; while (t--) solve(); return 0;}```