コンテスト30秒前にVScodeが使えなくなった男の備忘録です
コンテスト概要
トヨタ自動車プログラミングコンテスト2025(AtCoder Beginner Contest 389)
開催日:2025年1月18日 21:00-22:40
A - 9x9
考察
xを無視してだけを抽出。あとは2数をかけるだけ。
...なんだが、前述の通りVScoderがなぜか使用できなくなる。なのでコードテストを縛りでコンテストに参加する羽目に。
提出
#include <iostream>
using namespace std;
int main(){
int x,y;
char z;
cin >> x >> z >> y;
cout << x*y << endl;
}
B - tcaF
考察
1から順番に掛けていき特定の値になったら終了。
最後に掛けた値を出力。
提出
#include <iostream>
using namespace std;
using ll = long long;
int main(){
ll x;
cin >> x;
ll ans = 1;
for(ll i=1;i<21;i++){
ans *= i;
if(ans == x){
cout << i << endl;
return 0;
}
}
}
C-Snake Queue
考察
先頭のindexを管理する変数を持って置き、どんどん蛇には並んでもらい、それぞれの蛇の頭の位置を記録した配列を作成する。蛇が抜ければindexを1増やす。
ここでk番目の蛇の位置は[index+k]番目-[index]番目で求まる。
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
int n;
cin >> n;
vector<ll>num (1,0);
int now = 0;
for(int i=0;i<n;i++){
int x;
cin >> x;
if(x == 1){
ll y;
cin >> y;
ll s = num.back();
num.push_back(s+y);
}
if(x == 2){
now++;
}
if(x == 3){
int k;
cin >> k;
k--;
cout << num[k+now] - num[now] << endl;
}
}
}
D-Squares in Circle
考察
正方形の右角を基準に考えたとき、$(i+0.5)^2+(j+0.5)^2 \leq R^2$ となる$(i,j)$の数を考える。
ここで$i$を固定すると$j \leq {\sqrt{R^2 - (i+0.5)^2}} - 0.5$という式でかけるのである$i$に対する$j$の個数が簡単に求まる。
あとは$i$を全探査。
なお、この時動揺がMAXに達していたためまともなコードが書けなくなる。
提出
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll che(ll n){
ll h = 0,t = 2000001;
while(h != t){
ll c = (h+t) / 2LL;
if(c*c > n)t = c;
else h = c+ 1LL;
}
return h / 2LL;
}
int main(){
ll r;
cin >> r;
r *= 2LL;
r *= r;
vector<ll>ans (0);
ll now = 0;
while(true){
ll i = 2LL*now + 1LL;
ll s = r - i*i;
if(s < 0) break;
s = che(s);
if(s == 0) break;
ans.push_back(s);
now++;
}
if(ans.size() == 0)cout << "0" << endl;
ll cnt = 0;
for(auto x:ans) cnt += x;
cnt = cnt*2LL - ans[0];
cnt = cnt*2LL - (ans[0]*2LL - 1LL);
cout << cnt << endl;
}
E - Square Price
考察
どうやったら安い順に買えるかが思いつかずTIME UP
F - Rated Range
考察
遅延セグ木で範囲の両端を探しその間に1を足せばいいと残り10分で気づく。
10分でまともな写経なんてできるわけもなく遁走。
結果
結果 ABCD(1) 4完 68:23
順位 3207位
パフォーマンス 972
感想
突発的にコードテスト縛りなんて聞いてない。
せっかくの前回のアドバンテージが消し飛ぶ結果に。
みんなコンテストの15分前には動作確認をしよう!