Skip to content

Commit

Permalink
🎉 GPLT L1-081 to L1-096, L2-041 to L2-048
Browse files Browse the repository at this point in the history
  • Loading branch information
liuchuo committed Nov 21, 2023
1 parent 4ca33be commit fb6cde6
Show file tree
Hide file tree
Showing 24 changed files with 501 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CCCC-GPLT/L1-081 今天我要赢.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <iostream>
using namespace std;
int main() {
cout << "I'm gonna win! Today!\n2022-04-23";
return 0;
}
8 changes: 8 additions & 0 deletions CCCC-GPLT/L1-082 种钻石.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <iostream>
using namespace std;
int N, v;
int main() {
cin >> N >> v;
cout << N / v;
return 0;
}
14 changes: 14 additions & 0 deletions CCCC-GPLT/L1-083 谁能进图书馆.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <iostream>
using namespace std;
int prohibit, accompany, q1, q2;
int main() {
cin >> prohibit >> accompany >> q1 >> q2;
cout << q1 << '-';
if (q1 >= prohibit && q2 >= prohibit) cout << "Y " << q2 << "-Y\nhuan ying ru guan";
else if (q1 < prohibit && q2 < prohibit) cout << "N " << q2 << "-N\nzhang da zai lai ba";
else if (q1 >= accompany) cout << "Y " << q2 << "-Y\nqing 1 zhao gu hao 2";
else if (q2 >= accompany) cout << "Y " << q2 << "-Y\nqing 2 zhao gu hao 1";
else if (q1 >= prohibit) cout << "Y " << q2 << "-N\n1: huan ying ru guan";
else cout << "N " << q2 << "-Y\n2: huan ying ru guan";
return 0;
}
11 changes: 11 additions & 0 deletions CCCC-GPLT/L1-084 拯救外星人.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <iostream>
using namespace std;
int A, B, C = 1;
int main() {
cin >> A >> B;
for (int i = 1; i <= A + B; i++) {
C *= i;
}
cout << C;
return 0;
}
13 changes: 13 additions & 0 deletions CCCC-GPLT/L1-085 试试手气.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <iostream>
using namespace std;
int n, dice[6];
int main() {
for (int i = 0; i < 6; i++) cin >> dice[i];
cin >> n;
for (int i = 0; i < 6; i++) {
if (i) cout << ' ';
if (dice[i] >= 7 - n) cout << 6 - n;
else cout << 7 - n;
}
return 0;
}
15 changes: 15 additions & 0 deletions CCCC-GPLT/L1-086 斯德哥尔摩火车上的题.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <iostream>
using namespace std;
string s, a, S = "", A = "";
int main() {
cin >> s >> a;
for (int i = 1; i < s.size(); i++) {
if (s[i] % 2 == s[i - 1] % 2) S += max(s[i], s[i - 1]);
}
for (int i = 1; i < a.size(); i++) {
if (a[i] % 2 == a[i - 1] % 2) A += max(a[i], a[i - 1]);
}
cout << S;
if (S != A) cout << '\n' << A;
return 0;
}
18 changes: 18 additions & 0 deletions CCCC-GPLT/L1-087 机工士姆斯塔迪奥.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <iostream>
using namespace std;
int N, M, Q, T, C, Num_C, Num_R, Column[100001], Row[100001];
int main() {
cin >> N >> M >> Q;
for (int i = 0; i < Q; i++) {
cin >> T >> C;
if (T && !Column[C]) {
Column[C] = 1;
++Num_C;
} else if (!T && !Row[C]) {
Row[C] = 1;
++Num_R;
}
}
cout << N * M - Num_C * N - Num_R * M + Num_C * Num_R;
return 0;
}
18 changes: 18 additions & 0 deletions CCCC-GPLT/L1-088 静静的推荐.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <iostream>
using namespace std;
int N, K, S, ans, score_gplt, score_pat, mark[10001];
int main() {
cin >> N >> K >> S;
for (int i = 0; i < N; i++) {
cin >> score_gplt >> score_pat;
if (score_gplt >= 175) {
if (score_pat >= S) ++ans;
else if (mark[score_gplt] < K) {
ans++;
mark[score_gplt]++;
}
}
}
cout << ans;
return 0;
}
6 changes: 6 additions & 0 deletions CCCC-GPLT/L1-089 最好的文档.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <iostream>
using namespace std;
int main() {
cout << "Good code is its own best documentation.";
return 0;
}
8 changes: 8 additions & 0 deletions CCCC-GPLT/L1-090 什么是机器学习.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <iostream>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
cout << a + b - 16 << '\n' << a + b - 3 << '\n' << a + b - 1 << '\n' << a + b;
return 0;
}
11 changes: 11 additions & 0 deletions CCCC-GPLT/L1-091 程序员买包子.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <iostream>
using namespace std;
int main() {
int N, M, K;
string X;
cin >> N >> X >> M >> K;
if (K == N) cout << "mei you mai " << X << " de";
else if (K == M) cout << "kan dao le mai " << X << " de";
else cout << "wang le zhao mai " << X << " de";
return 0;
}
13 changes: 13 additions & 0 deletions CCCC-GPLT/L1-092 进化论.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <iostream>
using namespace std;
int main() {
int N, A, B, C;
cin >> N;
while(N--) {
cin >> A >> B >> C;
if (C == A * B) cout << "Lv Yan\n";
else if (C == A + B) cout << "Tu Dou\n";
else cout << "zhe du shi sha ya!\n";
}
return 0;
}
19 changes: 19 additions & 0 deletions CCCC-GPLT/L1-093 猜帽子游戏.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <iostream>
using namespace std;
int Hat[105], Guess, Right, Wrong, N, K;
int main() {
cin >> N;
for (int i = 1; i <= N; i++) cin >> Hat[i];
cin >> K;
while(K--) {
Right = Wrong = 0;
for (int i = 1; i <= N; i++) {
cin >> Guess;
if (Guess && Guess == Hat[i]) Right = 1;
else if (Guess && Guess != Hat[i]) Wrong = 1;
}
if (Wrong || !Right) cout << "Ai Ya\n";
else cout << "Da Jiang!!!\n";
}
return 0;
}
20 changes: 20 additions & 0 deletions CCCC-GPLT/L1-094 剪切粘贴.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <iostream>
#include <string>
using namespace std;
string s, a, b, X;
int N, l, r, pos;
int main() {
cin >> s >> N;
while (N--) {
cin >> l >> r >> a >> b;
X = s.substr(l - 1, r - l + 1);
s.erase(l - 1, r - l + 1);
pos = s.find(a + b);
if (pos == -1) s = s + X;
else {
s = s.substr(0, pos + (int)a.size()) + X + s.substr(pos + (int)a.size());
}
}
cout << s;
return 0;
}
17 changes: 17 additions & 0 deletions CCCC-GPLT/L1-095 分寝室.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <iostream>
using namespace std;
int n0, n1, n, F, M;
int main() {
cin >> n0 >> n1 >> n;
for (int i = 2; i <= n0; i++) {
if (n0 % i != 0 || n0 / i > n) continue;
int j = n - n0 / i;
if (n1 % j != 0) continue;
if (!F || abs(i - n1 / j) < abs(n0 / F - n1 / M)) {
F = n0 / i, M = j;
}
}
if (F) cout << F << ' ' << M;
else cout << "No Solution";
return 0;
}
24 changes: 24 additions & 0 deletions CCCC-GPLT/L1-096 谁管谁叫爹.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int N, a, b;
string A, B;
int main() {
cin >> N;
while(N--) {
cin >> A >> B;
a = b = 0;
for (auto it : A) {
a += it - '0';
}
for (auto it : B) {
b += it - '0';
}
if (stoi(A) % b == 0 && stoi(B) % a != 0) cout << "A\n";
else if (stoi(A) % b != 0 && stoi(B) % a == 0) cout << "B\n";
else if (stoi(A) > stoi(B)) cout << "A\n";
else cout << "B\n";
}
return 0;
}
50 changes: 50 additions & 0 deletions CCCC-GPLT/L2-041 插松枝.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#include <iostream>
#include <stack>
#include <vector>
using namespace std;
int N, M, K, tui;
stack<int> he;
vector<int> temp;
void outprint() {
for (int i = 0; i < temp.size(); i++) {
if (i) cout << ' ';
cout << temp[i];
}
cout << '\n';
temp.clear();
}
int main() {
cin >> N >> M >> K;
for (int i = 0; i < N; i++) {
cin >> tui;
tuihaimeiyong:
while (!he.empty()) {
if (temp.empty() || he.top() <= temp.back()) {
temp.push_back(he.top());
he.pop();
}
else break;
if (temp.size() == K) outprint();
}
if (temp.empty() || tui <= temp.back()) temp.push_back(tui);
else if(he.size() < M) he.push(tui);
else {
outprint();
goto tuihaimeiyong;
}
if (temp.size() == K) outprint();
}
while(!he.empty()) {
if (temp.empty() || he.top() <= temp.back()) {
temp.push_back(he.top());
he.pop();
}
else outprint();
if (temp.size() == K) outprint();
}
for (int j = 0; j < temp.size(); j++) {
if (j) cout << ' ';
cout << temp[j];
}
return 0;
}
15 changes: 15 additions & 0 deletions CCCC-GPLT/L2-042 老板的作息表.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <iostream>
#include <set>
using namespace std;
set<pair<string, string> > record;
string work_start_time, work_end_time, last_start = "00:00:00";
int main() {
cin >> work_start_time;
while (cin >> work_start_time >> work_end_time >> work_end_time) record.insert({work_start_time, work_end_time});
record.insert({"23:59:59", ""});
for (auto ite : record) {
if (last_start < ite.first) cout << last_start << " - " << ite.first << '\n';
last_start = ite.second;
}
return 0;
}
35 changes: 35 additions & 0 deletions CCCC-GPLT/L2-043 龙龙送外卖.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <iostream>
#include <queue>
using namespace std;
int N, M, Parent_num, new_address, passed_close_to_root, Round, Longest_path, Parent[100001], mark[100001], Distance[100001];
vector<int> Child[100001];
queue<pair<int, int> > Q;
int main() {
cin >> N >> M;
for (int i = 1; i <= N; i++) {
cin >> Parent_num;
if (Parent_num < 0) Parent[0] = i;
else Child[Parent_num].push_back(i);
Parent[i] = Parent_num;
}
mark[Parent[0]] = 1;
Q.push({Parent[0], 0});
while(!Q.empty()) {
int id = Q.front().first, deep = Q.front().second;
Q.pop();
Distance[id] = deep;
for (auto ite : Child[id]) Q.push({ite, deep + 1});
}
for (int i = 0; i < M; i++) {
cin >> new_address;
passed_close_to_root = new_address;
while(!mark[passed_close_to_root]) {
mark[passed_close_to_root] = 1;
passed_close_to_root = Parent[passed_close_to_root];
}
Round += Distance[new_address] - Distance[passed_close_to_root];
Longest_path = max(Longest_path, Distance[new_address]);
cout << Round * 2 - Longest_path * 1 << '\n';
}
return 0;
}
Loading

0 comments on commit fb6cde6

Please sign in to comment.