• 2023CSP-J游寄


    没话说了,S组没进复赛,只能打J组,J组打的也是一团糟。。

    过程

    上午8:10

    进考场了,打开vscode写模板

    上午8:25

    密码发下来了,开始解压,喝口水压压惊.

    开始浏览题目,看到T3我又惊了(又是一元二次方程,CCF这么喜欢一元二次吗?)。

    上午8:30

    开始比赛了。

    T1一眼思维题,便开始推导思路。

    上午9:20

    T1找规律找不下去了,就本着正解和暴力只差10pts的原则,打了暴力,骗了90pts。

    赛时T1代码

    赛时的代码就是暴力,暴力,暴力,当时没有想到正解。。。

    #include
    using namespace std;
    long long n, l, f[10000005], cnt, a[10000005], k;
    int main() {
    	freopen("apple.in", "r", stdin);
    	freopen("apple.out", "w", stdout);
    	cin >> n;
    	for (k = 1;; k++) {
    		l++, cnt = 0;
    		bool flag = false;
    		for (int i = 1; i <= n; i++) {
    			if (f[i] == 0) {
    				flag = true;
    				break;
    			}
    		}
    		if (flag == false) {
    			break;
    		}
    		for (int i = 1; i <= n; i++) {
    			if (f[i] != 1) {
    				++cnt;
    				if (cnt % 3 == 1) {
    					a[i] = l;
    					f[i] = 1;
    				}
    			}
    		}
    	}
    	cout << k - 1 << " " << a[n] << "\n";
    	return 0;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32

    发现时间不多了,立马开始看T2,一眼贪心

    上午9:30

    T2知道了怎么做,就是找下降子序列。

    上午9:50

    T2打完了,当时脑子抽了,打了前缀和+离散化+贪心,大样例过了,便心安了。

    T2赛时代码
    wssb,打了一大堆东西,后来缩减一下就A了!

    #include
    using namespace std;
    long long n, d, v[100005], t[100005];
    long long pre, q[100005], ans, dis;
    double oil;
    struct node {
    	long long id, val;
    	friend bool operator<(node x, node y) {
    		return x.val < y.val;
    	}
    } a[100005];
    int main() {
    	freopen("road.in", "r", stdin);
    	freopen("road.out", "w", stdout);
    	cin >> n >> d;
    	for (int i = 1; i < n; i++) {
    		cin >> v[i];
    	}
    	for (int i = 1; i <= n; i++) {
    		cin >> a[i].val;
    		q[i + 1] = q[i] + v[i];
    		t[i] = a[i].val;
    	}
    	sort(t + 1, t + n + 1);
    	for (int i = 1; i <= n; i++) {
    		long long j = lower_bound(t + 1, t + n + 1, a[i].val) - t;
    		a[i].id = j;
    	}
    	for (int i = 1; i <= n;) {
    		oil -= dis * 1.0 / d;
    		for (int j = i + 1; j <= n; j++) {
    			if (j == n) {
    				dis = q[j] - q[i];
    				ans += ((long long)ceil(dis * 1.0 / d - oil)) * a[i].val;
    				cout << ans;
    				return 0;
    			}
    			if (a[j].id < a[i].id) {
    				dis = q[j] - q[i];
    				ans += ((long long)ceil(dis * 1.0 / d - oil)) * a[i].val;
    				oil += ceil(dis * 1.0 / d);
    				i = j, pre = i;
    				break;
    			}
    		}
    	}
    	return 0;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48

    开始看T3,一眼大模拟。

    上午10:30

    大模拟打完了,大样例没过,开始调试。但不知道为什么考场的那个vscode调试不了,于是就只能手动输出过程。

    上午11:50

    调试了半天,大样例终于过了,Ctrl+S保存了代码。

    T3赛时代码
    有点多,大模拟

    #include
    using namespace std;
    int n, up, a, b, c;
    int main() {
    	freopen("uqe.in", "r", stdin);
    	freopen("uqe.out", "w", stdout);
    	cin >> n >> up;
    	for (int t = 1; t <= n; t++) {
    		cin >> a >> b >> c;
    		int derta = b * b - 4 * a * c;
    		if (derta < 0) {
    			cout << "NO\n";
    		} else {
    			int tmpb = -b, tmpm = 2 * a;
    			if (b == 0) {
    				if (tmpm > 0) {
    					int d = tmpm * tmpm;
    					if (derta == d) {
    						cout << 1 << "\n";
    					} else {
    						int s = derta / __gcd(derta, d);
    						int m = d / __gcd(derta, d);
    						int mod = 1;
    						for (int j = sqrt(s * m); j >= 2; j--) {
    							if ((s * m) % (j * j) == 0) {
    								mod = j;
    								break;
    							}
    						}
    						cout << mod << "\n";
    						if (mod == 1) {
    							cout << "sqrt(" << s*m << ")";
    							if (m != 1) {
    								cout << "/" << m;
    							}
    							cout << "\n";
    						} else {
    							cout << mod << "*sqrt(" << s*m / mod / mod << ")";
    							if (m != 1) {
    								cout << "/" << m;
    							}
    							cout << "\n";
    						}
    
    					}
    				} else {
    					int d = tmpm * tmpm;
    					if (derta == d) {
    						cout << 1 << "\n";
    					} else {
    						int s = derta / __gcd(derta, d);
    						int m = c / __gcd(derta, d);
    						cout << "-sqrt(" << s*m << ")/" << m << "\n";
    					}
    				}
    				continue;
    			} else {
    				if (sqrt(derta)*sqrt(derta) == derta) {
    					int son = tmpb + sqrt(derta);
    					if (son == 0) {
    						cout << 0;
    					} else if (son > 0 && tmpm > 0 || son < 0 && tmpm < 0) {
    						int son2 = abs(tmpb - sqrt(derta));
    						if (son < 0) {
    							son2 = abs(son2);
    							tmpm = abs(tmpm);
    							int mod = 1;
    							for (int j = sqrt(derta); j >= 2; j--) {
    								if (derta % (j * j) == 0) {
    									mod = j;
    									break;
    								}
    							}
    							if (son2 % tmpm == 0) {
    								cout << son2 / tmpm << "\n";
    							} else {
    								cout << son2 / __gcd(son2, tmpm) << "/" << tmpm / __gcd(son2, tmpm) << "\n";
    							}
    						} else {
    							son = abs(son);
    							tmpm = abs(tmpm);
    							int mod = 1;
    							for (int j = sqrt(derta); j >= 2; j--) {
    								if (derta % (j * j) == 0) {
    									mod = j;
    									break;
    								}
    							}
    							if (son % tmpm == 0) {
    								cout << son / tmpm << "\n";
    							} else {
    								cout << son / __gcd(son, tmpm) << "/" << tmpm / __gcd(son, tmpm) << "\n";
    							}
    						}
    					} else {
    						int son2 = tmpb - sqrt(derta);
    						if (son2 > 0 && tmpm > 0 || son2 < 0 && tmpm < 0) {
    							son2 = abs(son2);
    							tmpm = abs(tmpm);
    							int mod = 1;
    							for (int j = sqrt(derta); j >= 2; j--) {
    								if (derta % (j * j) == 0) {
    									mod = j;
    									break;
    								}
    							}
    							if (son2 % tmpm == 0) {
    								cout << son2 / tmpm << "\n";
    							} else {
    								cout << son2 / __gcd(son2, tmpm) << "/" << tmpm / __gcd(son2, tmpm) << "\n";
    							}
    						} else {
    							son = abs(son);
    							son2 = abs(son2);
    							tmpm = abs(tmpm);
    							int mod = 1;
    							for (int j = sqrt(derta); j >= 2; j--) {
    								if (derta % (j * j) == 0) {
    									mod = j;
    									break;
    								}
    							}
    							if (son2 * 1.0 / tmpm > son * 1.0 / tmpm) {
    								if (son2 % tmpm == 0) {
    									cout << "-" << son2 / tmpm << "\n";
    								} else {
    									cout << "-" << son2 / __gcd(son2, tmpm) << "/" << tmpm / __gcd(son2, tmpm) << "\n";
    								}
    							} else {
    								if (son % tmpm == 0) {
    									cout << "-" << son / tmpm << "\n";
    								} else {
    									cout << "-" << son / __gcd(son, tmpm) << "/" << tmpm / __gcd(son, tmpm) << "\n";
    								}
    							}
    						}
    
    					}
    					continue;
    				} else {
    					if (tmpm < 0) {
    						if (tmpb < 0) {
    							if (abs(tmpb) % abs(tmpm) != 0) {
    								int g = __gcd(abs(tmpb), abs(tmpm));
    								int mod = 1;
    								for (int j = sqrt(derta); j >= 2; j--) {
    									if (derta % (j * j) == 0) {
    										mod = j;
    										break;
    									}
    								}
    								cout << abs(tmpb) / g << "/" << abs(tmpm) / g << "+sqrt(" << derta << ")/" << abs(tmpm) << "\n";
    							} else {
    								int mod = 1;
    								for (int j = sqrt(derta); j >= 2; j--) {
    									if (derta % (j * j) == 0) {
    										mod = j;
    										break;
    									}
    								}
    								cout << abs(tmpb) / abs(tmpm) << "+sqrt(" << derta << ")/" << abs(tmpm) << "\n";
    							}
    							continue;
    						} else {
    							if (abs(tmpb) % abs(tmpm) != 0) {
    								int g = __gcd(abs(tmpb), abs(tmpm)), mod = 1;
    								for (int j = sqrt(derta); j >= 2; j--) {
    									if (derta % (j * j) == 0) {
    										mod = j;
    										break;
    									}
    								}
    								if (mod % abs(tmpm) == 0) {
    									cout << "-" << abs(tmpb) / g << "/" << abs(tmpm) / g << "+sqrt(" << derta / mod / mod << ")/" << mod / abs(tmpm) << "\n";
    								} else {
    									if (mod != 1) {
    										cout << "-" << abs(tmpb) / g << "/" << abs(tmpm) / g << "+" << mod << "*sqrt(" << derta / mod / mod << ")/" << abs(tmpm) << "\n";
    									}
    									cout << "-" << abs(tmpb) / g << "/" << abs(tmpm) / g << "sqrt(" << derta / mod / mod << ")/" << abs(tmpm) << "\n";
    								}
    							} else {
    								int mod = 1;
    								for (int j = sqrt(derta); j >= 2; j--) {
    									if (derta % (j * j) == 0) {
    										mod = j;
    										break;
    									}
    								}
    								cout << "-" << abs(tmpb) / abs(tmpm) << "+sqrt(" << derta << ")/" << abs(tmpm) << "\n";
    							}
    							continue;
    						}
    					} else {
    						if (tmpb < 0) {
    							if (abs(tmpb) % abs(tmpm) != 0) {
    								int g = __gcd(abs(tmpb), abs(tmpm));
    								int mod = 1;
    								for (int j = sqrt(derta); j >= 2; j--) {
    									if (derta % (j * j) == 0) {
    										mod = j;
    										break;
    									}
    								}
    								cout << "-" << abs(tmpb) / g << "/" << abs(tmpm) / g << "+sqrt(" << derta << ")/" << abs(tmpm) << "\n";
    							} else {
    								int mod = 1;
    								for (int j = sqrt(derta); j >= 2; j--) {
    									if (derta % (j * j) == 0) {
    										mod = j;
    										break;
    									}
    								}
    								cout << "-" << abs(tmpb) / abs(tmpm) << "+sqrt(" << derta << ")/" << abs(tmpm) << "\n";
    							}
    							continue;
    						} else {
    							if (abs(tmpb) % abs(tmpm) != 0) {
    								int g = __gcd(abs(tmpb), abs(tmpm));
    								int mod = 1;
    								for (int j = sqrt(derta); j >= 2; j--) {
    									if (derta % (j * j) == 0) {
    										mod = j;
    										break;
    									}
    								}
    								cout << abs(tmpb) / g << "/" << abs(tmpm) / g << "+sqrt(" << derta << ")/" << abs(tmpm) << "\n";
    							} else {
    								int mod = 1;
    								for (int j = sqrt(derta); j >= 2; j--) {
    									if (derta % (j * j) == 0) {
    										mod = j;
    										break;
    									}
    								}
    								cout << abs(tmpb) / abs(tmpm) << "+sqrt(" << derta << ")/" << abs(tmpm) << "\n";
    							}
    							continue;
    						}
    					}
    				}
    			}
    		}
    	}
    	return 0;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144
    • 145
    • 146
    • 147
    • 148
    • 149
    • 150
    • 151
    • 152
    • 153
    • 154
    • 155
    • 156
    • 157
    • 158
    • 159
    • 160
    • 161
    • 162
    • 163
    • 164
    • 165
    • 166
    • 167
    • 168
    • 169
    • 170
    • 171
    • 172
    • 173
    • 174
    • 175
    • 176
    • 177
    • 178
    • 179
    • 180
    • 181
    • 182
    • 183
    • 184
    • 185
    • 186
    • 187
    • 188
    • 189
    • 190
    • 191
    • 192
    • 193
    • 194
    • 195
    • 196
    • 197
    • 198
    • 199
    • 200
    • 201
    • 202
    • 203
    • 204
    • 205
    • 206
    • 207
    • 208
    • 209
    • 210
    • 211
    • 212
    • 213
    • 214
    • 215
    • 216
    • 217
    • 218
    • 219
    • 220
    • 221
    • 222
    • 223
    • 224
    • 225
    • 226
    • 227
    • 228
    • 229
    • 230
    • 231
    • 232
    • 233
    • 234
    • 235
    • 236
    • 237
    • 238
    • 239
    • 240
    • 241
    • 242
    • 243
    • 244
    • 245

    开始看T4,虽然只有10min了,但是发现T4输出-1有分,于是就花1min打了一个-1。

    中午12:00

    考试结束了,如释重负,走出考场闻闻新鲜空气。

    晚上8:30

    满怀激动的来洛谷测,以为这次300+pts胜券在握。

    晚上8:35

    T1->90pts理所应当
    T2->45pts 大样例都过了,不知道这次是不是有个地方考虑漏了,希望CCF的数据和大样例一样水。。。
    T3->0pts 震惊到我了,好说歹说也应该至少50pts啊,我仔细检查了一下自己的代码,调试过程没删!!!我当场晕了过去。。
    T4->0pts 理所应当

    结果

    洛谷上测出来145pts,跟估分差了十万八千里。

    估分:90+100+100+[10,20]=[300,310]pts

    实际:90+45+0+10=145pts

    T3报灵了,全部都因为没有删去调试的中间过程,艹。

    后寄

    没什么好说,这次寄了,如果到明年都不会away from OI,希望明年不要犯如此低级的错误。。。

  • 相关阅读:
    如何改善交通管制带来的交通拥堵?
    市场渗透率不到1%,低代码产品未来发展趋势如何?
    谐振波导光栅的严格分析
    [机缘参悟-76]:深度思考-职场中注意事项与大忌-员工版
    camunda_03_techstack
    二分法-算法总结
    使用Spring Boot和MyBatis访问数据库
    Meetup 回顾|Data Infra 研究社第十五期(含资料发布)
    【数据结构初级(2)】单链表的基本操作和实现
    Perl基本数组排序方法介绍
  • 原文地址:https://blog.csdn.net/cyyyyds857/article/details/134087043