Skip to content

Commit 06091f3

Browse files
committed
Added some new definitions and includes, updated README.md (added new badges, etc.)
1 parent 3bd4e63 commit 06091f3

File tree

5 files changed

+280
-64
lines changed

5 files changed

+280
-64
lines changed
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
name: "Generate-Badge"
2+
description: "Creates dynamic and customizable README badges using shields.io/endpoint"
3+
branding:
4+
icon: "shield"
5+
color: "blue"
6+
inputs:
7+
token:
8+
description: "Used for authentication"
9+
required: true
10+
filename:
11+
description: "The filename to use in the wiki for storing the JSON badge data"
12+
required: true
13+
label:
14+
description: "The left text, or the empty string to omit the left side of the badge"
15+
required: true
16+
message:
17+
description: "The right text"
18+
required: true
19+
color:
20+
description: "The right color"
21+
required: false
22+
default: ""
23+
labelColor:
24+
description: "The left color"
25+
required: false
26+
default: ""
27+
namedLogo:
28+
description: "Logo supported by Shields"
29+
required: false
30+
default: ""
31+
logoSvg:
32+
description: "An SVG string containing a custom logo"
33+
required: false
34+
default: ""
35+
style:
36+
description: "The default template to use"
37+
required: false
38+
default: ""
39+
wikiCommitUsername:
40+
description: "Override for the wiki commit username"
41+
required: false
42+
default: ""
43+
wikiCommitEmail:
44+
description: "Override for the wiki commit email"
45+
required: false
46+
default: ""
47+
wikiCommitMessage:
48+
description: "Override for the wiki commit message"
49+
required: false
50+
default: ""
51+
repository:
52+
description: "The repository to store files"
53+
required: false
54+
default: "${{ github.repository }}"
55+
ref:
56+
description: "The branch to store files"
57+
required: false
58+
default: "badges"
59+
runs:
60+
using: "composite"
61+
steps:
62+
- name: Output number of badges
63+
id: number_of_badges
64+
run: |
65+
declare -a BAB_INPUTS_FILENAME_ARRAY=${{ inputs.filename }}
66+
echo "value=$(echo ${#BAB_INPUTS_FILENAME_ARRAY[@]})" >> $GITHUB_OUTPUT
67+
shell: bash
68+
- name: Check out repo
69+
uses: actions/checkout@v3
70+
if: inputs.wikiCommitUsername == '' || inputs.wikiCommitEmail == '' || inputs.wikiCommitMessage == ''
71+
with:
72+
token: ${{ inputs.token }}
73+
- name: Output wiki commit details
74+
id: wiki_commit
75+
run: |
76+
if [[ -n "${{ inputs.wikiCommitUsername }}" ]]; then
77+
WIKI_COMMIT_USERNAME="${{ inputs.wikiCommitUsername }}"
78+
else
79+
WIKI_COMMIT_USERNAME=$(git log -n 1 --pretty=format:%an)
80+
fi
81+
echo "username=$WIKI_COMMIT_USERNAME" >> $GITHUB_OUTPUT
82+
83+
if [[ -n "${{ inputs.wikiCommitEmail }}" ]]; then
84+
WIKI_COMMIT_EMAIL="${{ inputs.wikiCommitEmail }}"
85+
else
86+
WIKI_COMMIT_EMAIL=$(git log -n 1 --pretty=format:%ae)
87+
fi
88+
echo "email=$WIKI_COMMIT_EMAIL" >> $GITHUB_OUTPUT
89+
90+
if [[ -n "${{ inputs.wikiCommitMessage }}" ]]; then
91+
WIKI_COMMIT_MESSAGE="${{ inputs.wikiCommitMessage }}"
92+
else
93+
WIKI_COMMIT_MESSAGE=https://github.com/${{ github.repository }}/commit/$(git log -n 1 --pretty=format:"%H")
94+
fi
95+
echo "message=$WIKI_COMMIT_MESSAGE" >> $GITHUB_OUTPUT
96+
shell: bash
97+
- name: Check out wiki
98+
uses: actions/checkout@v3
99+
with:
100+
token: ${{ inputs.token }}
101+
repository: "${{ inputs.repository }}"
102+
ref: "refs/heads/${{ inputs.ref }}"
103+
path: wiki
104+
- name: Update wiki
105+
run: |
106+
cd ./wiki
107+
108+
if [[ ${{ steps.number_of_badges.outputs.value }} -eq 1 ]]; then
109+
BAB_INPUTS_FILENAME="${{ inputs.filename }}"
110+
BAB_INPUTS_LABEL="${{ inputs.label }}"
111+
BAB_INPUTS_MESSAGE="${{ inputs.message }}"
112+
BAB_INPUTS_COLOR="${{ inputs.color }}"
113+
BAB_INPUTS_LABELCOLOR="${{ inputs.labelColor }}"
114+
BAB_INPUTS_NAMEDLOGO="${{ inputs.namedLogo }}"
115+
BAB_INPUTS_LOGOSVG="${{ inputs.logoSvg }}"
116+
BAB_INPUTS_STYLE="${{ inputs.style }}"
117+
else
118+
declare -a BAB_INPUTS_FILENAME_ARRAY=${{ inputs.filename }}
119+
declare -a BAB_INPUTS_LABEL_ARRAY=${{ inputs.label }}
120+
declare -a BAB_INPUTS_MESSAGE_ARRAY=${{ inputs.message }}
121+
declare -a BAB_INPUTS_COLOR_ARRAY=${{ inputs.color }}
122+
declare -a BAB_INPUTS_LABELCOLOR_ARRAY=${{ inputs.labelColor }}
123+
declare -a BAB_INPUTS_NAMEDLOGO_ARRAY=${{ inputs.namedLogo }}
124+
declare -a BAB_INPUTS_LOGOSVG_ARRAY=${{ inputs.logoSvg }}
125+
declare -a BAB_INPUTS_STYLE_ARRAY=${{ inputs.style }}
126+
fi
127+
128+
for i in {1..${{ steps.number_of_badges.outputs.value }}}; do
129+
BADGE_JSON="{\"schemaVersion\":1"
130+
131+
if [[ ${{ steps.number_of_badges.outputs.value }} -ne 1 ]]; then
132+
BAB_INPUTS_FILENAME=${BAB_INPUTS_FILENAME_ARRAY[i-1]}
133+
BAB_INPUTS_LABEL=${BAB_INPUTS_LABEL_ARRAY[i-1]}
134+
BAB_INPUTS_MESSAGE=${BAB_INPUTS_MESSAGE_ARRAY[i-1]}
135+
BAB_INPUTS_COLOR=${BAB_INPUTS_COLOR_ARRAY[i-1]}
136+
BAB_INPUTS_LABELCOLOR=${BAB_INPUTS_LABELCOLOR_ARRAY[i-1]}
137+
BAB_INPUTS_NAMEDLOGO=${BAB_INPUTS_NAMEDLOGO_ARRAY[i-1]}
138+
BAB_INPUTS_LOGOSVG=${BAB_INPUTS_LOGOSVG_ARRAY[i-1]}
139+
BAB_INPUTS_STYLE=${BAB_INPUTS_STYLE_ARRAY[i-1]}
140+
fi
141+
142+
BADGE_JSON="$BADGE_JSON,\"label\":\"$BAB_INPUTS_LABEL\""
143+
BADGE_JSON="$BADGE_JSON,\"message\":\"$BAB_INPUTS_MESSAGE\""
144+
145+
declare -A OPTIONAL_PARAMETERS_ARRAY
146+
OPTIONAL_PARAMETERS_ARRAY["color"]=$BAB_INPUTS_COLOR
147+
OPTIONAL_PARAMETERS_ARRAY["labelColor"]=$BAB_INPUTS_LABELCOLOR
148+
OPTIONAL_PARAMETERS_ARRAY["namedLogo"]=$BAB_INPUTS_NAMEDLOGO
149+
OPTIONAL_PARAMETERS_ARRAY["logoSvg"]=$(echo $BAB_INPUTS_LOGOSVG | sed -e 's/"/\\"/g')
150+
OPTIONAL_PARAMETERS_ARRAY["style"]=$BAB_INPUTS_STYLE
151+
152+
for key in ${!OPTIONAL_PARAMETERS_ARRAY[@]}; do
153+
if [[ -n "${OPTIONAL_PARAMETERS_ARRAY[${key}]}" ]]; then
154+
BADGE_JSON="$BADGE_JSON,\"$key\":\"${OPTIONAL_PARAMETERS_ARRAY[${key}]}\""
155+
fi
156+
done
157+
BADGE_JSON="$BADGE_JSON}"
158+
159+
echo $BADGE_JSON > "$BAB_INPUTS_FILENAME.md"
160+
done
161+
162+
git pull
163+
if [[ -n $(git status --porcelain) ]]; then
164+
git config user.name "${{ steps.wiki_commit.outputs.username }}"
165+
git config user.email "${{ steps.wiki_commit.outputs.email }}"
166+
git add -A
167+
git commit -m "${{ steps.wiki_commit.outputs.message }}"
168+
git push
169+
fi
170+
171+
cd ..
172+
shell: bash

.github/workflows/c-cpp.yml

Lines changed: 0 additions & 49 deletions
This file was deleted.

.github/workflows/main-branch.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Main Branch Workflow
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
build-windows-vs:
11+
name: build-windows-vs
12+
runs-on: windows-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Compile with VS 2022
16+
shell: cmd
17+
run: ${{ '"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat" && msbuild' }}
18+
working-directory: 'likespro.eth - UNIVERSAL'
19+
- name: Run
20+
run: |
21+
"likespro.eth - UNIVERSAL\Debug\likespro.eth - UNIVERSAL.exe"
22+
shell: cmd
23+
- name: Upload executable
24+
uses: actions/upload-artifact@v4
25+
with:
26+
name: windows
27+
path: |
28+
"likespro.eth - UNIVERSAL\Debug\likespro.eth - UNIVERSAL.exe"
29+
build-mac-and-ubuntu:
30+
runs-on: ${{matrix.os}}
31+
strategy:
32+
matrix:
33+
os: [macos-latest, ubuntu-latest]
34+
name: 'build-${{matrix.os}}'
35+
steps:
36+
- uses: actions/checkout@v4
37+
- name: Compile with GCC
38+
run: |
39+
g++ -std=c++17 'likespro.eth - UNIVERSAL/likespro.eth - UNIVERSAL.cpp' -o 'likespro.eth - UNIVERSAL.o'
40+
- name: Run
41+
run: |
42+
'./likespro.eth - UNIVERSAL.o'
43+
shell: bash
44+
- name: Upload executable
45+
uses: actions/upload-artifact@v4
46+
with:
47+
name: ${{matrix.os}}
48+
path: |
49+
'likespro.eth - UNIVERSAL.o'
50+
51+
build-git-badges:
52+
name: Build Git Badges
53+
runs-on: ubuntu-latest
54+
permissions:
55+
contents: write
56+
57+
steps:
58+
- name: Checkout repository
59+
uses: actions/checkout@v4
60+
61+
- name: Output git info
62+
id: git_info
63+
run: |
64+
function format_size { echo $(numfmt --to iec --suffix B $1); }
65+
function format_number { LC_ALL=en_US.UTF-8 printf "%'d\n" $1; }
66+
echo "file_count=$(format_number $(git ls-files | wc -l))" >> $GITHUB_OUTPUT
67+
echo "lines_of_code=$(git ls-files | grep '\.cpp' | xargs wc -l)" >> $GITHUB_OUTPUT
68+
git gc
69+
echo "size=$(format_size $(($(git count-objects -v | grep 'size-pack: ' | sed 's/size-pack: //g' | tr -d '\n') * 1024)))" >> $GITHUB_OUTPUT
70+
shell: bash
71+
72+
- name: Generate-Badge
73+
uses: ./.github/actions/generate-badge
74+
with:
75+
token: ${{ secrets.GITHUB_TOKEN }}
76+
filename: |
77+
(
78+
"git-size"
79+
"git-file-count"
80+
"git-lines-of-code"
81+
)
82+
label: ("size" "files" "lines-of-code")
83+
message: |
84+
(
85+
"${{ steps.git_info.outputs.size }}"
86+
"${{ steps.git_info.outputs.file_count }}"
87+
"${{ steps.git_info.outputs.lines_of_code }}"
88+
)
89+
namedLogo: ("git" "git" "git")
90+
color: ("f1502f" "f1502f" "f1502f")

README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<p align="center">
22
<img width="100px" src="https://github.com/likespro.png" align="center" alt="Competitive Template" />
33
<h2 align="center">Competitive Programming Template by likespro</h2>
4-
<p align="center">Template for CP competitions used by likespro. Written in C++.</p>
4+
<p align="center">Template for CP competitions such as ICPC, CodeForces, etc. Written in C++.</p>
55
</p>
66
<p align="center">
7-
<a href="https://github.com/likespro/cp-programming-template/workflows/C/C++ CI">
8-
<img alt="Build Passing" src="https://github.com/likespro/cp-programming-template/workflows/C/C++ CI/badge.svg" />
7+
<a href="https://github.com/likespro/cp-programming-template">
8+
<img alt="LICENSE" src="https://img.shields.io/badge/licence-MIT-yellow" />
99
</a>
1010
<a href="https://github.com/likespro/cp-programming-template/graphs/contributors">
1111
<img alt="GitHub Contributors" src="https://img.shields.io/github/contributors/likespro/cp-programming-template" />
@@ -18,20 +18,20 @@
1818
</a>
1919
</p>
2020
<p align="center">
21-
<a href="https://sonarcloud.io/summary/new_code?id=likespro_cp-programming-template">
22-
<img alt="Code Lines" src="https://sonarcloud.io/api/project_badges/measure?project=likespro_cp-programming-template&metric=ncloc" />
21+
<a href="https://github.com/likespro/cp-programming-template/workflows/Main Branch Workflow">
22+
<img alt="Build Passing" src="https://github.com/likespro/cp-programming-template/workflows/Main Branch Workflow/badge.svg" />
2323
</a>
24-
<a href="https://sonarcloud.io/summary/new_code?id=likespro_cp-programming-template">
25-
<img alt="Quality Rate" src="https://sonarcloud.io/api/project_badges/measure?project=likespro_cp-programming-template&metric=alert_status" />
24+
<a href="https://app.codacy.com/gh/likespro/cp-programming-template/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade">
25+
<img src="https://app.codacy.com/project/badge/Grade/59828f3512224a018a6930c0c68c5a71"/>
2626
</a>
27-
<a href="https://sonarcloud.io/summary/new_code?id=likespro_cp-programming-template">
28-
<img alt="Bugs" src="https://sonarcloud.io/api/project_badges/measure?project=likespro_cp-programming-template&metric=bugs" />
27+
<a href="https://github.com/axusinc/cp-programming-template">
28+
<img alt="Git Size" src="https://img.shields.io/endpoint?url=https://github.com/axusinc/cp-programming-template/blob/badges/git-size.md?raw=true" />
2929
</a>
30-
<a href="https://sonarcloud.io/summary/new_code?id=likespro_cp-programming-template">
31-
<img alt="Technical Debt" src="https://sonarcloud.io/api/project_badges/measure?project=likespro_cp-programming-template&metric=sqale_index" />
30+
<a href="https://github.com/axusinc/cp-programming-template">
31+
<img alt="Git File Count" src="https://img.shields.io/endpoint?url=https://github.com/axusinc/cp-programming-template/blob/badges/git-file-count.md?raw=true" />
3232
</a>
33-
<a href="https://sonarcloud.io/summary/new_code?id=likespro_cp-programming-template">
34-
<img alt="Maintability" src="https://sonarcloud.io/api/project_badges/measure?project=likespro_cp-programming-template&metric=sqale_rating" />
33+
<a href="https://github.com/axusinc/cp-programming-template">
34+
<img alt="Git Lines Of Code" src="https://img.shields.io/endpoint?url=https://github.com/axusinc/cp-programming-template/blob/badges/git-lines-of-code.md?raw=true" />
3535
</a>
3636
</p>
3737

@@ -40,7 +40,7 @@
4040

4141

4242
## Overview
43-
A C++ template that likespro uses for competitions such as ICPC, CodeForces, AtCoder, etc.
43+
A C++ template for competitions such as ICPC, CodeForces, AtCoder, etc.
4444

4545
The main goal of this template is to be very powerful and convenient.
4646

@@ -87,7 +87,7 @@ Just copy & paste content of "likespro.eth - UNIVERSAL/likespro.eth - UNIVERSAL.
8787
* `rofin` = `for(int i = n; i >= 0; i--)`
8888
* `fori(n)` = `for(int i = 0; i < (n); i++)`
8989
* `rofi(n)` = `for(int i = (n); i >= 0; i--)`
90-
### Definitions for Wrong Spelling
90+
### Definitions against Wrong Spelling
9191
* `iont` = `int`
9292
* `itn` = `int`
9393
* `for9int` = `for(int`

likespro.eth - UNIVERSAL/likespro.eth - UNIVERSAL.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#include <numeric>
5050
#include <iomanip>
5151
#include <unordered_map>
52+
#include <stack>
5253
#include <random>
5354

5455
// <========== NAMESPACES ==========>
@@ -132,6 +133,8 @@ using mapsi = map<string, int>;
132133
using mib = map<int, bool>;
133134
using mipii = map<int, pii>;
134135
using mitiii = map<int, tiii>;
136+
using mpiib = map<pii, bool>;
137+
using mpiii = map<pii, int>;
135138
using mpiivpii = map<pii, vpii>;
136139
using misi = map<int, si>;
137140
using mivi = map<int, vi>;

0 commit comments

Comments
 (0)