owned this note
owned this note
Published
Linked with GitHub
# 不分系早安
### 目錄
> [C++語法惡補]( ##C++語法惡補) :memo:
> [歷屆刷刷刷]( ##歷屆刷刷刷) :100:
## :memo:C++語法惡補
```cpp=
isalpha(ch); //是否為字母
isdigit(ch); //是否為數字
```
### STL複習
https://tioj.ck.tp.edu.tw/uploads/attachment/11/40/1.pdf
## :100:歷屆刷刷刷
>[CPE](##CPE歷屆)
> [2013/05/28](###2013/05/28)
>
> [ICPC](##ICPC歷屆)
> [2023](###2023)
## CPE歷屆
### 2013/05/28
#### Uva245 Uncompress
```cpp=
#include<iostream>
#include<vector>
using namespace std;
int main(){
string s;
vector<string> v;
while(1){
getline(cin,s);
if(s.size()==1&&s[0]=='0')
break;
for(int i=0;i<s.size();i++){
if(isalpha(s[i])){
string t="";
while(isalpha(s[i]))
t+=s[i++];
i--;
v.push_back(t);
cout<<t;
}
else if(isdigit(s[i])){
string t="";
int x=0;
while(isdigit(s[i]))
x=x*10+s[i++]-'0';
i--;
t=v[v.size()-x];
v.erase(v.end()-x);
v.push_back(t);
cout<<t;
}
else
cout<<s[i];
}
cout<<'\n';
}
}
```
#### 11475 Extend to Palindromes
```cpp=
#include<iostream>
#define int long long
using namespace std;
signed main(){
ios_base::sync_with_stdio(false);
//cin.tie(0),cout.tie(0);
int a, b, c, d;
string s;
while (cin >> s){
a = -1;
int i = s.size() - 1;
for (int f = i; f >= 0; f--){
b = 0;
while (s[i - b] == s[f + b]){
if (b == (i - f)){
if (b > a){
a = b;
c = f;
d = i;
}
break;
}
b++;
}
}
if ((a + 1) == s.size()){
cout << s << '\n';
}
else if ((d + 1) == s.size()){
cout << s;
for (int i = c - 1; i >= 0; i--)
cout << s[i];
cout << '\n';
}
else{
cout << s;
for (int i = s.size() - 2; i >= 0; i--)
cout << s[i];
cout << '\n';
}
}
}
```
## ICPC歷屆
### 2023
#### A - Advance to Taoyuan Regional
```cpp=
#include <iostream>
#include <algorithm>
#include <string>
#define int long long
using namespace std;
signed main(){
ios_base::sync_with_stdio(false);
/in.tie(0), cout.tie(0);
int a, b, d;
string s,ss;
char c;
while(cin>>a>>c>>b>>c>>d){
if(a>2023)
cout << "TOO LATE\n";
else if(b>=9&&d>16)
cout << "TOO LATE\n";
else if(b>9)
cout << "TOO LATE\n";
else
cout << "GOOD\n";
}
}
```
#### J - Java Warriors
```cpp=
#include <iostream>
#include <algorithm>
#include <string>
#define int long long
using namespace std;
signed main(){
ios_base::sync_with_stdio(false);
//cin.tie(0), cout.tie(0);
int a, b, d, e, t;
string s;
char c;
while(cin>>t){
cout << 4000 * t << '\n';
}
}
```
#### K - Kick
```cpp=
#include <iostream>
#include <algorithm>
#include <string>
#define int long long
using namespace std;
signed main(){
ios_base::sync_with_stdio(false);
//cin.tie(0), cout.tie(0);
int a, b, d, e, t;
string s;
char c;
while(cin>>s){
int x = 0;
for (int i = 0; i < s.size(); i++){
if(s[i]=='k'&&s[i+1]=='i'&&s[i+2]=='c'&&s[i+3]=='k')
x++;
}
cout << x << '\n';
}
}
```
#### L - Location, Location, Location
```cpp=
#include <iostream>
#include <algorithm>
#include <string>
#define int long long
using namespace std;
signed main(){
ios_base::sync_with_stdio(false);
//cin.tie(0), cout.tie(0);
int a, b, d, e, t;
string s;
char c;
while(cin>>t){
int x = 0, y = 0;
int n[t], m[t];
for (int i = 0; i < t; i++){
cin >> n[i] >> m[i];
x += n[i];
y += m[i];
}
sort(n, n + t);
sort(m, m + t);
if(t%2)
cout << n[t / 2] << ' ' << m[t / 2] << '\n';
else
cout << n[t / 2 - 1] << ' ' << m[t / 2 - 1] << '\n';
}
}
```