Goo sees more than the school year
Cattle off
More than 2019 cattle off summer school camp (first)
Question number | title | Team status |
---|---|---|
A | Equivalent Prefixes | by |
B | Integration | by |
C | Euclidean Distance | Did not pass |
D | Parity of Tuples | Did not pass |
E | ABBA | by |
F | Random Point in Triangle | by |
G | Substrings 2 | Did not pass |
H | XOR | Did not pass |
I | Points Division | Did not pass |
J | Fraction Comparision | by |
A.
Thinking: binary stack monotone +
Code:
#pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize(4) #include<bits/stdc++.h> using namespace std; #define y1 y11 #define fi first #define se second #define pi acos(-1.0) #define LL long long //#define mp make_pair #define pb emplace_back #define ls rt<<1, l, m #define rs rt<<1|1, m+1, r #define ULL unsigned LL #define pll pair<LL, LL> #define pli pair<LL, int> #define pii pair<int, int> #define piii pair<pii, int> #define pdd pair<double, double> #define mem(a, b) memset(a, b, sizeof(a)) #define debug(x) cerr << #x << " = " << x << "\n"; #define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); //head const int N = 1e5 + 5; int n, a[N], b[N], la[N], ra[N],lb[N], rb[N]; stack<int> st; inline bool ck(int m) { while(!st.empty()) st.pop(); st.push(0); for (int i = 1; i <= m; ++i) { while(!st.size() > 1 && a[st.top()] > a[i]) st.pop(); la[i] = st.top(); st.push(i); } while(!st.empty()) st.pop(); st.push(m+1); for (int i = m; i >= 1; --i) { while(st.size() > 1 && a[st.top()] > a[i]) st.pop(); ra[i] = st.top(); st.push(i); } while(!st.empty()) st.pop(); st.push(0); for (int i = 1; i <= m; ++i) { while(!st.size() > 1 && b[st.top()] > b[i]) st.pop(); lb[i] = st.top(); st.push(i); } while(!st.empty()) st.pop(); st.push(m+1); for (int i = m; i >= 1; --i) { while(st.size() > 1 && b[st.top()] > b[i]) st.pop(); rb[i] = st.top(); st.push(i); } for (int i = 1; i <= m; ++i) if(la[i] != lb[i] || ra[i] != rb[i]) return false; return true; } int main() { while(~scanf("%d", &n)) { for (int i = 1; i <= n; ++i) scanf("%d", &a[i]); for (int i = 1; i <= n; ++i) scanf("%d", &b[i]); int l = 1, r = n, m = l+r+1 >>1; while( l < r) { if(ck(m)) l = m; else r = m-1; m = l+r+1>>1; } printf("%d\n", m); } return 0; }
B.
Ideas: Splitting, see D God blog
Code:
#pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize(4) #include<bits/stdc++.h> using namespace std; #define y1 y11 #define fi first #define se second #define pi acos(-1.0) #define LL long long //#define mp make_pair #define pb push_back #define ls rt<<1, l, m #define rs rt<<1|1, m+1, r #define ULL unsigned LL #define pll pair<LL, LL> #define pli pair<LL, int> #define pii pair<int, int> #define piii pair<pii, int> #define pdd pair<double, double> #define mem(a, b) memset(a, b, sizeof(a)) #define debug(x) cerr << #x << " = " << x << "\n"; #define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); //head const int N = 1e3 + 5; const int MOD = 1e9 + 7; int a[N], n; LL q_pow(LL n, LL k) { LL ans = 1; while(k){ if(k&) = years (years n *)%1 MOD; n =(n * n) % MOD; k >>= 1; } return ans; } int main() { while(~scanf("%d", &n)) { for (int i = 1; i <= n; ++i) scanf("%d",&a[i]); LL ans = 0; for (int i = 1; i <= n; ++i) { LL tmp = 2*a[i]%MOD; for (int j = 1; j <= n; ++j) { if(i == j) continue; tmp = (tmp * (a[j]*1LL*a[j]%MOD-a[i]*1LL*a[i]%MOD))%MOD; } ans = (ans + q_pow(tmp, MOD-2))%MOD; } printf("%lld\n", (ans+MOD)%MOD); } return 0; }
C.
D.
E.
Ideas: dp, to ensure that the difference between A and B -m to + n
Code:
#include <bits/stdc++.h> using namespace std; #define pb push_back #define fi first #define se second #define debug(x) cerr<<#x << " := " << x << endl; #define bug cerr<<"-----------------------"<<endl; #define FOR(a, b, c) for(int a = b; a <= c; ++ a) typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; template<class T> void _R(T &x) { cin >> x; } void _R(int &x) { scanf("%d", &x); } void _R(ll &x) { scanf("%lld", &x); } void _R(double &x) { scanf("%lf", &x); } void _R(char &x) { scanf(" %c", &x); } void _R(char *x) { scanf("%s", x); } void R() {} template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); } template<typename T> inline T read(T&x){ x=0;int f=0;char ch=getchar(); while (ch<'0'||ch>'9') f|=(ch=='-'),ch=getchar(); while (ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar(); return x=f?-x:x; } const int inf = 0x3f3f3f3f; const int mod = 1e9+7; /**********showtime************/ const int maxn = 8e3+9; ll dp[maxn][maxn]; int g(int x) { return x + 4000; } int main(){ int n,m; while(~scanf("%d%d", &n, &m)) { int s = 2 * (n + m); int t = (n + m); for(int i=0; i<=s; i++) { for(int j=-t; j<=t; j++) { dp[i][g(j)] = 0; } } dp[0][g(0)] = 1; for(int i=1; i<=s; i++) { for(int j=-t; j<=t; j++) { if(j <= n) dp[i][g(j)] = (dp[i][g(j)] + dp[i-1][g(j-1)] ) %mod; if(j >= -m) dp[i][g(j)] = (dp[i][g(j)] + dp[i-1][g(j+1)] ) %mod; } } // cout<<dp[s][g(0)]<<endl; printf("%lld\n", dp[s][g(0)]); } return 0; }
F.
Ideas:
22*S/36
Code:
#include<bits/stdc++.h> #define ll long long using namespace std; struct Point { // double pan duan ll x,y; Point(ll a=0,ll b=0) { x=a;y=b; }; }; typedef Point Vector; Vector operator + (Vector A, Vector B){ return Vector(A.x+B.x, A.y+B.y); } // 向量相加 Vector operator - (Point A, Point B){ return Vector(A.x-B.x, A.y-B.y); } // 向量生成 double operator * (Vector A, Vector B){ return A.x*B.x-A.y*B.y; } // 点积 double operator ^ (Vector A, Vector B){ return A.x*B.y-A.y*B.x; } // 叉积 ll Cross(Vector A, Vector B) { return A.x*B.y - A.y*B.x; } // 叉积 ll Area2(Point A, Point B, Point C) { return Cross(B-A, C-A); } // 四边形面积 int main(){ Point a,b,c; while(~scanf("%lld %lld %lld %lld %lld %lld",&a.x,&a.y,&b.x,&b.y,&c.x,&c.y)){ ll area=abs(Cross(b-a,c-a) ) *11; printf("%lld\n",area); } }
G.
H.
I.
J.
Ideas: large numbers too
import java.math.BigInteger; import java.util.*; public class Main { /** * @param args */ public static void main(String[] args) { BigInteger x, a, y, b; Scanner reader = new Scanner(System.in); while(reader.hasNext()) { x = reader.nextBigInteger(); a = reader.nextBigInteger(); y = reader.nextBigInteger(); b = reader.nextBigInteger(); if(x.multiply(b).compareTo(y.multiply(a)) == 0) { System.out.println("="); } else if(x.multiply(b).compareTo(y.multiply(a)) > 0) { System.out.println(">"); } else { System.out.println("<"); } } } }
Hangzhou Electric