// AC one more times // nndbk #include<bits/stdc++.h> usingnamespace std; typedeflonglong ll; constint mod = 1e9 + 7; constint N = 2e5 + 10; ll n,m; ll pre_a[N],pre_b[N]; ll qmi(ll a, ll b, ll mod) { ll ans = 1 % mod; while(b) { if(b & 1) ans = ans * a % mod; a = a * a % mod; b >>= 1; } return ans; }
// AC one more times // nndbk #include<bits/stdc++.h> usingnamespace std; typedeflonglong ll; constint mod = 1e9 + 7; constint N = 2e5 + 10; ll exgcd(ll a, ll b, ll &x, ll &y) { if(b == 0) { x = 1; y = 0; return a; } ll xx,yy; ll d = exgcd(b, a % b, xx, yy); x = yy; y = xx - (a / b) * yy; return d; }
intmain() { ios::sync_with_stdio(false); cin.tie(nullptr), cout.tie(nullptr); int t; cin>>t; while(t--) { ll x1,y1,x2,y2,x,y; cin>>x1>>y1>>x2>>y2; ll a = x2-x1, b = y2-y1; if(a==0) cout<<x1-1<<" "<<y1<<"\n"; elseif(b==0) cout<<x1<<" "<<y1-1<<"\n"; else { //((x2-x2)(y3-y1)-(y2-y1)(x3-x1))/2 //(-bx+ay)/2 ll d = exgcd(-b,a,x,y); cout<<x+x1<<" "<<y+y1<<"\n"; } }
// AC one more times // nndbk #include<bits/stdc++.h> usingnamespace std; typedeflonglong ll; constint mod = 10; constint N = 6e5 + 10; ll a[N];
template<classT> structBIT { T c[N]; int size; voidresize(int s){ size = s;} T query(int x){ // 1 ... x assert(x <= size); T s = 0; for (; x; x -= x & (-x)) { s += c[x]; } return s; }
voidmodify(int x, T s){ // a[x] += s assert(x != 0); for (; x <= size; x += x & (-x)) { c[x] += s; } } };
BIT<ll> c; intmain() { ios::sync_with_stdio(false); cin.tie(nullptr), cout.tie(nullptr); //翻转p' = n(n-1)/2-p //转移p' = p-比x小的(x-1)个数+(n-x)比x大的数 ll n,m,ans = 0; cin>>n>>m; c.resize(n+10); for(int i = 0; i < n; i++) cin>>a[i]; for(int i = 0;i < n; i++) { ans += c.query(n)-c.query(a[i]); c.modify(a[i],1); } cout<<ans<<"\n"; ans %= 10; int head = 0,nxt = 1; ll all = n*(n-1)/2; all %= mod; string s; cin>>s; int sz = s.size(); for(int i = 0;i < sz; i++) { if(s[i]=='S') { ans = ((ans-(a[head]-1)+(n-a[head])%mod+mod)%mod+mod)%mod; head = ((head+nxt)%n+n)%n; } elseif(s[i]=='R') { ans = ((all-ans)%mod+mod)%mod; head = ((head+(n-1)*nxt)%n+n)%n; nxt *= -1; } cout<<ans; } cout<<"\n";
return0; }
Title: 2022 CCPC桂林 CEM
Author: Nannan
Created at
: 2023-09-12 11:33:00
Updated at
: 2024-09-30 17:20:47
Link: https://redefine.ohevan.com/2023/09/12/2022 China Collegiate Programming Contest (CCPC) Guilin Site/