前期天胡开局各种1A,然后被弱智E题卡到集体降智。后面的题也太难了8
7题滚了,过于真实
A:
solver:zyh

1 #include <bits/stdc++.h> 2 #include <unordered_set> 3 using namespace std; 4 struct board { 5 int arr[6][6]; 6 board() { 7 memset(arr, 0, sizeof(arr)); 8 } 9 }; 10 //EW:1 NS:2 11 int towards[11]; 12 int len[11]; 13 struct state { 14 int x[11]; 15 int y[11]; 16 bool operator==(const state &b)const { 17 for (int i = 1; i <= 10; ++i) if (x[i] != b.x[i] || y[i] != b.y[i]) return false; 18 return true; 19 } 20 }; 21 struct myHash { 22 size_t operator()(state State) const { 23 size_t hash = 0; 24 for (int i = 1; i <= 10; ++i) { 25 hash = hash * 7 + size_t(State.x[i]); 26 hash = hash * 7 + size_t(State.y[i]); 27 } 28 return hash; 29 } 30 }; 31 board st; 32 state st_state; 33 queue< pair<int, state> > que; 34 unordered_set<state, myHash> Set; 35 board generateBoard(state State) { 36 board rnt; 37 for (int i = 1; i <= 10; ++i) 38 if (towards[i] > 0) { 39 int dx = 0, dy = 0; 40 int x = State.x[i]; 41 int y = State.y[i]; 42 if (towards[i] == 1) dy = 1; 43 else dx = 1; 44 for (int j = 0; j < len[i]; ++j) { 45 rnt.arr[x][y] = i; 46 x += dx; y += dy; 47 } 48 } 49 return rnt; 50 } 51 void output(int s, state State) { 52 //return; 53 cout << "s=" << s << endl; 54 board Board = generateBoard(State); 55 for (int i = 0; i < 6; ++i) { 56 for (int j = 0; j < 6; ++j) cout << Board.arr[i][j] << ' '; 57 cout << endl; 58 } 59 system("pause"); 60 } 61 int bfs() { 62 que.push(pair<int, state>(0, st_state)); 63 Set.insert(st_state); 64 while (!que.empty()) { 65 auto tmp = que.front(); 66 int nows = tmp.first; 67 state nowstate = tmp.second; 68 que.pop(); 69 if (nows == 10) continue; 70 board nowboard = generateBoard(nowstate); 71 for (int i = 1; i <= 10; ++i) { 72 //positive 73 if (towards[i] == 0) continue; 74 state tmpstate = nowstate; 75 int dx = 0, dy = 0; 76 if (towards[i] == 1) dy = 1; 77 else dx = 1; 78 for (int j = 1; j <= 1; ++j) { 79 //positive 80 if (nowstate.x[i] + dx * (len[i] + j - 1) < 6 && 81 nowstate.y[i] + dy * (len[i] + j - 1) < 6 && 82 nowboard.arr[nowstate.x[i] + dx * (len[i] + j - 1)][nowstate.y[i] + dy * (len[i] + j - 1)] == 0) { 83 tmpstate.x[i] = nowstate.x[i] + dx * j; 84 tmpstate.y[i] = nowstate.y[i] + dy * j; 85 if (Set.find(tmpstate) == Set.end()) { 86 if (tmpstate.y[1] + len[1] - 1 == 5) { 87 //output(nows+1,tmpstate); 88 if (nows + 1 + len[1] <= 10) return nows + 1 + len[1]; 89 return -1; 90 } 91 //output(nows+1,tmpstate); 92 que.push(pair<int, state>(nows + 1, tmpstate)); 93 Set.insert(tmpstate); 94 } 95 } else break; 96 } 97 for (int j = 1; j <= 1; ++j) { 98 if (nowstate.x[i] - dx * j >= 0 && 99 nowstate.y[i] - dy * j >= 0 && 100 nowboard.arr[nowstate.x[i] - dx * j][nowstate.y[i] - dy * j] == 0) { 101 tmpstate.x[i] = nowstate.x[i] - dx * j; 102 tmpstate.y[i] = nowstate.y[i] - dy * j; 103 if (Set.find(tmpstate) == Set.end()) { 104 if (tmpstate.y[1] + len[1] - 1 == 5) { 105 //output(nows+1,tmpstate); 106 if (nows + 1 + len[1] <= 10) return nows + 1 + len[1]; 107 return -1; 108 } 109 //output(nows+1,tmpstate); 110 111 que.push(pair<int, state>(nows + 1, tmpstate)); 112 Set.insert(tmpstate); 113 } 114 } else break; 115 } 116 } 117 } 118 return -1; 119 } 120 int main() { 121 for (int i = 0; i < 6; ++i) 122 for (int j = 0; j < 6; ++j) scanf("%d", &st.arr[i][j]); 123 for (int i = 0; i < 6; ++i) 124 for (int j = 0; j < 6; ++j) 125 if (st.arr[i][j] > 0) { 126 int t = st.arr[i][j]; 127 if (towards[t] > 0) continue; 128 st_state.x[t] = i; 129 st_state.y[t] = j; 130 int dx = 0, dy = 0; 131 if (j + 1 < 6 && st.arr[i][j + 1] == t) { 132 towards[t] = 1; 133 dy = 1; 134 } else { 135 towards[t] = 2; 136 dx = 1; 137 } 138 int x = i, y = j; 139 len[t] = 0; 140 while (st.arr[x][y] == t) { 141 len[t]++; 142 x += dx; y += dy; 143 } 144 } 145 if (st_state.x[1] != 2 || towards[1] != 1) { 146 printf("-1\n"); 147 return 0; 148 } 149 printf("%d", bfs()); 150 }
B:
完全没看的神仙题
C:
solver:lzh

1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef pair<int, int> pii; 4 typedef long long ll; 5 #define ff first 6 #define ss second 7 8 int a[100]; 9 int main() { 10 int n; scanf("%d", &n); 11 for (int i = 1; i <= n; i++)scanf("%d", &a[i]); 12 for (int i = 1; i <= n; i++) 13 for (int j = 1; j <= n; j++) 14 for (int k = 1; k <= n; k++) 15 if (i != j && i != k && j != k) { 16 if (abs(a[i] - a[j]) % a[k] != 0) { 17 printf("no\n"); return 0; 18 } 19 } 20 printf("yes\n"); 21 }
D:
solver:lzh

1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef pair<int, int> pii; 4 typedef long long ll; 5 #define ff first 6 #define ss second 7 8 char s[100]; 9 char a[] = {" bubble"}, b[] = {" tapioka"}; 10 int main() { 11 int output = 0; 12 while (~scanf("%s", s + 1)) { 13 int n = strlen(s + 1); 14 if (n == 6) { 15 for (int i = 1; i <= 6; i++)if (a[i] != s[i]) { 16 printf("%s ", s + 1); output++; break; 17 } 18 } else if (n == 7) { 19 for (int i = 1; i <= 7; i++)if (b[i] != s[i]) { 20 printf("%s ", s + 1); output++; break; 21 } 22 } else { 23 printf("%s ", s + 1); output++; 24 } 25 } 26 if (!output)printf("nothing\n"); 27 }
E:
solver:czq
想了好久才醒悟到有sb做法

1 /* basic header */ 2 #include <bits/stdc++.h> 3 /* define */ 4 #define ll long long 5 #define dou double 6 #define pb emplace_back 7 #define mp make_pair 8 #define sot(a,b) sort(a+1,a+1+b) 9 #define rep1(i,a,b) for(int i=a;i<=b;++i) 10 #define rep0(i,a,b) for(int i=a;i<b;++i) 11 #define eps 1e-8 12 #define int_inf 0x3f3f3f3f 13 #define ll_inf 0x7f7f7f7f7f7f7f7f 14 #define lson (curpos<<1) 15 #define rson (curpos<<1|1) 16 /* namespace */ 17 using namespace std; 18 /* header end */ 19 20 const int maxn = 1999, lim = 1e6; 21 ll a[maxn], k, l; 22 23 int main() { 24 int t; scanf("%d", &t); 25 while (t--) { 26 scanf("%lld%lld", &k, &l); 27 if (l > maxn) { 28 puts("-1"); 29 continue; 30 } 31 a[0] = -1; 32 ll tmp = k + maxn; 33 for (int i = 1; i < maxn - 1; i++) { 34 a[i] = min(tmp, (ll)lim); 35 tmp -= a[i]; 36 } 37 a[maxn - 1] = tmp; 38 printf("%d\n%lld", maxn, a[0]); 39 for (int i = 1; i < maxn; i++) printf(" %lld", a[i]); 40 puts(""); 41 } 42 return 0; 43 }
H:
solver:lzh、zyh

1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef pair<int, int> pii; 4 typedef long long ll; 5 #define ff first 6 #define ss second 7 8 int main() { 9 int t; scanf("%d", &t); 10 while (t--) { 11 ll n; scanf("%lld", &n); 12 ll x = (1ll * n * (n + 1)) ^ (n + 1); 13 printf("%lld\n", x); 14 } 15 }
I:
完全没看的神仙题
J:
solver:lzh、zyh

1 #include <bits/stdc++.h> 2 using namespace std; 3 bitset<500> number[30]; 4 char str[1001]; 5 int main(){ 6 int T; 7 scanf("%d",&T); 8 while (T--){ 9 int n,m; 10 scanf("%d%d",&n,&m); 11 for (int i=0;i<m;++i){ 12 scanf("%s",str); 13 number[i]=bitset<500>(str); 14 } 15 int len=1<<m; 16 int ans=m+1; 17 18 for (int i=1;i<len;++i){ 19 int t=i; 20 int s=0; 21 bitset<500> now(0); 22 for (int j=0;j<m && t>0;++j){ 23 if (t&1){ now=now|number[j]; s++;} 24 t>>=1; 25 } 26 if (now.count()==n) ans=min(ans,s); 27 } 28 if (ans==m+1) printf("-1\n"); 29 else printf("%d\n",ans); 30 } 31 }
K:
solver:zyh、czq

1 #include <bits/stdc++.h> 2 using namespace std; 3 priority_queue< int,vector<int>,greater<int> > que; 4 int main(){ 5 int T; 6 scanf("%d",&T); 7 while (T--){ 8 int n; 9 scanf("%d",&n); 10 que=priority_queue<int,vector<int>,greater<int>>(); 11 for (int i=0;i<n;++i){ 12 int t; 13 scanf("%d",&t); 14 que.push(t); 15 } 16 int ans=0; 17 while (que.size()>1){ 18 int f1=que.top(); 19 que.pop(); 20 int f2=que.top(); 21 que.pop(); 22 ans+=f1+f2; 23 que.push(f1+f2); 24 } 25 printf("%d\n",ans); 26 } 27 }
L:
想得头皮发麻……这里给个500ms过的std

1 #include<cstdio> 2 #include<algorithm> 3 #include<bitset> 4 using namespace std; 5 6 struct Point { 7 long long x, y; 8 int num; 9 bool operator <(const Point &p)const { 10 return x != p.x ? x < p.x : y < p.y; 11 } 12 Point operator -(const Point &p)const { 13 return { x - p.x, y - p.y }; 14 } 15 Point Rotate() { 16 return { -y, x }; 17 } 18 } w[4400], P[4400], st[4400]; 19 long long Z[4400]; 20 int n; 21 22 long long Mul(Point a, Point b) { 23 return a.x * b.x + a.y * b.y; 24 } 25 26 long long getArea(Point a, Point b, Point c) { 27 return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x); 28 } 29 30 void Solve() { 31 scanf("%d", &n); 32 for (int i = 0; i < n; i++) { 33 scanf("%lld%lld", &w[i].x, &w[i].y); 34 } 35 // 按x和y排序 36 sort(w, w + n); 37 for (int i = 0; i < n; i++) w[i].num = i; // 给点编号 38 int cnt = 0, top = 0; 39 // 求凸包? 40 for (int i = 0; i < n; i++) { 41 while (top > 1 && getArea(st[top - 1], st[top], w[i]) <= 0) top--; 42 st[++top] = w[i]; 43 } 44 for (int i = 1; i < top; i++) P[cnt++] = st[i]; 45 top = 0; 46 for (int i = 0; i < n; i++) { 47 while (top > 1 && getArea(st[top - 1], st[top], w[i]) >= 0)top--; 48 st[++top] = w[i]; 49 } 50 for (int i = top; i > 1; i--) P[cnt++] = st[i]; 51 if (cnt <= 2) { 52 puts("0"); 53 return; 54 } 55 long long res = 0; 56 for (int i = 0; i < cnt; i++) { 57 Point V1 = P[(i + 1) % cnt] - P[i]; 58 Point V2 = V1.Rotate(); 59 long long Mx2 = -5e18; 60 for (int j = 0; j < cnt; j++) { 61 long long t = Mul(V2, P[j]); 62 Z[j] = t; 63 if (Mx2 < t)Mx2 = t; 64 } 65 for (int j = 0; j < cnt; j++) { 66 if (Z[j] == Mx2) { 67 Point VV = (P[j] - P[i]).Rotate(); 68 long long Mn = 5e18, Mx = -5e18; 69 for (int k = 0; k < n; k++) { 70 if (k == P[i].num || k == P[j].num)continue; 71 long long t = Mul(VV, w[k]); 72 if (Mn > t)Mn = t; 73 if (Mx < t)Mx = t; 74 } 75 res = max(res, Mx - Mn); 76 } 77 } 78 } 79 if (res % 2)printf("%lld.5\n", res / 2); 80 else printf("%lld\n", res / 2); 81 } 82 83 int main() { 84 int TC; 85 scanf("%d", &TC); 86 while (TC--) { 87 Solve(); 88 } 89 }
M:
贴个zzy大佬的代码

1 #include<iostream> 2 #include<vector> 3 #include<cmath> 4 #include<unordered_map> 5 using namespace std; 6 #define ll long long 7 8 ll M, N, mod, p[100], tot, num[100], cnt[100], ap[100], P[16000010], mu[16000010], cntt; 9 bool vis[16000010]; 10 vector<int> factor; 11 unordered_map<ll, ll> mp2; 12 ll fuck_dp[16000010]; 13 14 ll mypow(ll a, ll b) { 15 ll ret = 1; 16 while (b) { 17 if (b & 1)ret = ret * a % mod; 18 a = a * a % mod; b >>= 1; 19 } 20 return ret; 21 } 22 23 void init() { 24 mu[1] = 1; 25 for (int i = 2; i < 16000010; i++) { 26 if (!vis[i])P[cntt++] = i, mu[i] = -1; 27 for (int j = 0; j < cntt && P[j]*i < 16000010; j++) { 28 29 int now = P[j] * i; 30 vis[now] = 1; 31 if (i % P[j] == 0) { 32 mu[now] = 0; 33 break; 34 } else mu[now] = -mu[i]; 35 } 36 } 37 } 38 39 void exgcd(ll a, ll b, ll &x, ll &y) { 40 if (b == 0)x = 1, y = 0; 41 else { 42 exgcd(b, a % b, y, x); 43 y -= a / b * x; 44 } 45 } 46 47 ll inv(ll a) { 48 ll x, y; 49 exgcd(a, mod, x, y); 50 return x < 0 ? x + mod : x; 51 } 52 53 void fuck_init() { 54 fuck_dp[0] = 1; 55 for (int i = 1; i <= mod; i++) { 56 int tmp = i; 57 for (int i = 1; i <= tot; i++) { 58 if (tmp % p[i] == 0) { 59 tmp = 1; 60 break; 61 } 62 } 63 fuck_dp[i] = fuck_dp[i - 1] * tmp % mod; 64 } 65 } 66 67 inline ll calcu(int n) { 68 return fuck_dp[n]; 69 } 70 71 ll calcu2(ll n) { 72 if (n == 0)return 1; 73 if (mp2[n])return mp2[n]; 74 ll ret = mypow(calcu(mod - 1), n / mod) * calcu(n % mod) % mod; 75 for (auto &it : factor) { 76 77 ll tmp = calcu2(n / it); 78 ret = ret * (mu[it] == 0 ? 1 : (mu[it] == -1 ? tmp : inv(tmp))) % mod; 79 } 80 return mp2[n] = ret; 81 } 82 83 ll calcu3(ll n, ll x) { 84 ll ret = 0, base = x; 85 while (x <= n) { 86 ret += n / x; 87 if (x > n / base)break; 88 x *= base; 89 } 90 return ret; 91 } 92 93 int main() { 94 init(); 95 cin >> M >> N >> mod; 96 int D = mod; 97 for (int i = 2; i * i <= D; i++) { 98 if (D % i == 0) { 99 int tmp = 0; 100 while (D % i == 0) { 101 tmp++; 102 D /= i; 103 } 104 p[++tot] = i; 105 num[tot] = tmp; 106 } 107 } 108 if (D >= 2) { 109 p[++tot] = D; 110 num[tot] = 1; 111 } 112 for (int i = 2; i <= mod; i++) if (mod % i == 0) factor.push_back(i); 113 fuck_init(); 114 ll ans = calcu2(M); 115 ll ans2 = calcu2(N); 116 ll ans3 = calcu2(M - N); 117 for (int i = 1; i < mod; i++) { 118 if (ans2 * i % mod == 1) ans = ans * i % mod; 119 if (ans3 * i % mod == 1) ans = ans * i % mod; 120 } 121 ll minn = 9e18; 122 for (int i = 1; i <= tot; i++) { 123 cnt[i] += calcu3(M, p[i]); 124 cnt[i] -= calcu3(N, p[i]) + calcu3(M - N, p[i]); 125 ap[i] = cnt[i] / num[i]; 126 minn = min(minn, ap[i]); 127 } 128 for (int i = 1; i <= tot; i++) cnt[i] -= minn * num[i]; 129 ll anss = 1; 130 for (int i = 1; i <= tot; i++) anss = anss * mypow(p[i], cnt[i]) % mod; 131 cout << ans *anss % mod << endl; 132 }