Question number | title | It has adopted the code | Interpretations / Discussion | Passing rate | Team status |
---|---|---|---|---|---|
A | String | Click to view | Enter discussions | 561/3518 | by |
B | Irreducible Polynomial | Click to view | Enter discussions | 724/2269 | by |
C | Governing sand | Click to view | Enter discussions | 383/2052 | by |
D | Number | Click to view | Enter discussions | 955/1462 | by |
E | Find the median | Click to view | Enter discussions | 82/968 | Did not pass |
F | Energy stones | Click to view | Enter discussions | 15/131 | Did not pass |
G | Make Shan Happy | Click to view | Enter discussions | 2/28 | Did not pass |
H | Pair | Click to view | Enter discussions | 92/239 | Did not pass |
I | Chessboard | Click to view | Enter discussions | 17/82 | Did not pass |
J | A+B problem | Click to view | Enter discussions | 1023/1843 | by |
K | Function | Click to view | Enter discussions | 8/49 | Did not pass |
A
Knowledge Point: Minimum string representation
I to the beginning position of the string, looking from the back violence furthest j such that S [i ... j] represents the minimum of its own
ps: solution to a problem which did not engage in the practice of writing out, saw a lot of heavyweights on over less than 5ms
About smallest representation: OI Wiki
#include <bits/stdc++.h>
using namespace std;
int T,n;
int num;
char s[220];
char t[500];
//判断s[l...r] 是否为自己的最小表示
bool ok(int l,int r){
int n = r - l + 1;
for(int i=1;i<=n;i++)t[i] = s[l + i - 1];
for(int i=1;i<=n;i++)t[n+i] = s[l + i - 1];
int i=1,j=2,k;
while(i<=n && j <= n){
for(k = 0; k <= n && t[i+k] == t[j+k];k++);
if(k == n)break;
if(t[i+k] > t[j+k]){
i = i + k + 1;
if(i == j)i++;
}
else{
j = j + k + 1;
if(i == j)j++;
}
}
int ans = min(i,j);
for(int i=0;i<n;i++){
if(t[ans+i] == s[l+i])continue;
else return false;
}
return true;
}
void print(int l,int r){
for(int i=l;i<=r;i++)printf("%c",s[i]);
printf(" ");
}
int main(){
scanf("%d",&T);
while(T--){
scanf("%s",s+1);
n = strlen(s+1);
num = 0;
for(int i=1;i<=n;){
for(int j=n;j>=i;j--){
if(i == j || ok(i,j)){
print(i,j);
i = j+1;
}
}
}
puts("");
}
return 0;
}
B
Conclusion: real domain can not be split only two polynomials: a quadratic polynomial and ( \ (2 ^ B <4ac \) )
#include <bits/stdc++.h>
using namespace std;
int T;
int n;
long long a[1005];
int main(){
scanf("%d", &T);
while(T--){
scanf("%d", &n);
for(int i = 0; i <= n; i++){
scanf("%lld", &a[i]);
}
if(n >= 3){
puts("No");
}
else if(n <= 1){
puts("Yes");
}
else{
if(a[1] * a[1] - 4 * a[0] * a[2] < 0){
puts("Yes");
}
else{
puts("No");
}
}
}
return 0;
}
C
According to the height of small to large order, and then enumerate the current height as the maximum height, then than it is high tree to be cut down, less than it was inside the tree to pick some number of trees (from small to large by price considerations) so that the remaining quantity is less than equal to the number of the current enumeration of the maximum height of the tree.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll cost[205];
struct node {
int h, c, p;
}E[100005];
bool cmp(node A, node B) {
return A.h > B.h;
}
ll suf[100005];
int main() {
int n;
while(~scanf("%d", &n)) {
ll ans = 0;
memset(cost, 0, sizeof(cost));
for(int i = 1; i <= n; i++) {
scanf("%d%d%d", &E[i].h, &E[i].c, &E[i].p);
cost[E[i].c] += 1LL * E[i].p;
ans += 1LL * E[i].c * E[i].p;
}
sort(E + 1, E + 1 + n, cmp);
suf[n] = 1LL * E[n].p;
for(int i = n - 1; i >= 1; i--) suf[i] = suf[i + 1] + 1LL * E[i].p;
ll pre = 0;
for(int i = 1; i <= n; i++) {
int j;
ll num = 0; //同一高度的树
ll cutx = 0; //砍掉同一高度的花费
bool tail = true;
ll tmp = suf[i];
for(j = i; j <= n; j++) {
if(E[j].h == E[i].h) {
cutx += 1LL * E[j].p * E[j].c;
num += 1LL * E[j].p;
tmp -= 1LL * E[j].p;
cost[E[j].c] -= 1LL * E[j].p;
} else {
tail = false;
i = j - 1;
break;
}
}
if(tail) i = n;
if(tmp < num) tmp = 0;
else tmp = tmp - num + 1;
ll cut = 0;
for(int j = 1; j <= 200; j++) {
if(cost[j] >= tmp) {
cut += 1LL * j * tmp;
tmp = 0;
break;
} else {
cut += 1LL * j * cost[j];
tmp -= cost[j];
}
}
ll ccc = cut + pre;
ans = min(ans, ccc);
pre += cutx;
if(pre >= ans) break;
}
printf("%lld\n", ans);
}
return 0;
}
D
If n is greater than or equal length p, the first output p 0 then back up p, otherwise the answer does not exist
#include <bits/stdc++.h>
using namespace std;
int n,p;
int calc(int x){
int res = 0;
while(x)res++,x/=10;
return res;
}
int main(){
scanf("%d%d",&n,&p);
int len = calc(p);
if(n >= len){
printf("%d",p);
for(int i=len;i<n;i++)printf("0");
puts("");return 0;
}
else puts("T_T");
return 0;
}
J
#include <bits/stdc++.h>
using namespace std;
int T;
char a[100];
char b[100];
char c[105];
int main(){
scanf("%d", &T);
while(T--){
memset(c, 0, sizeof(c));
scanf("%s%s", a, b);
reverse(a, a + strlen(a));
reverse(b, b + strlen(b));
long long aa, bb;
aa = bb = 0;
for(int i = 0; a[i]; i++){
aa *= 10;
aa += a[i] - '0';
}
for(int i = 0; b[i]; i++){
bb *= 10;
bb += b[i] - '0';
}
long long ans = aa + bb;
int cnt = 0;
bool flag = false;
for(int i = 0; ans > 0; i++){
c[i] = '0' + (ans % 10);
if(!flag && c[i] != '0'){
flag = true;
cnt = i;
}
ans /= 10;
}
if(!flag){
puts("0");
}
else{
printf("%s\n", c + cnt);
}
}
return 0;
}