This commit is contained in:
Zengtudor 2024-10-05 13:24:08 +08:00
parent 3580a299d2
commit 100e97ef6e
32 changed files with 117 additions and 46 deletions

View File

@ -16,27 +16,10 @@ message("Build type is [${CMAKE_BUILD_TYPE}]")
project(algorithm_2024)
add_executable(P1031 ${CMAKE_CURRENT_LIST_DIR}/P1031/main.cpp)
add_executable(P1031_pro ${CMAKE_CURRENT_LIST_DIR}/P1031/pro.cpp)
file(GLOB_RECURSE SRC_LIST CONFIGURE_DEPENDS ${CMAKE_CURRENT_LIST_DIR}/src/*.cpp)
add_executable(P2661 ${CMAKE_CURRENT_LIST_DIR}/P2661/main.cpp)
add_executable(P2661_video ${CMAKE_CURRENT_LIST_DIR}/P2661/video.cpp)
add_executable(P2615 ${CMAKE_CURRENT_LIST_DIR}/P2615/P2615.cpp)
add_executable(P7076 ${CMAKE_CURRENT_LIST_DIR}/P7076/P7076.cpp)
add_executable(P7075 ${CMAKE_CURRENT_LIST_DIR}/P7075/P7075.cpp)
add_executable(P1003 ${CMAKE_CURRENT_LIST_DIR}/P1003/P1003.cpp)
add_executable(P1311 ${CMAKE_CURRENT_LIST_DIR}/P1311/P1311.cpp)
add_executable(P4017 ${CMAKE_CURRENT_LIST_DIR}/P4017/P4017.cpp)
add_executable(P2782 ${CMAKE_CURRENT_LIST_DIR}/P2782/P2782.cpp)
add_executable(P1091 ${CMAKE_CURRENT_LIST_DIR}/P1091/P1091.cpp)
add_executable(P1020 ${CMAKE_CURRENT_LIST_DIR}/P1020/P1020.cpp)
add_executable(U206625 ${CMAKE_CURRENT_LIST_DIR}/U206625/U206625.cpp)
foreach(SRC IN LISTS SRC_LIST)
get_filename_component(SRC_NAME_WE ${SRC} NAME_WE)
message("[${SRC}] will be build to [${SRC_NAME_WE}]")
add_executable(${SRC_NAME_WE} ${SRC})
endforeach()

View File

@ -1,20 +0,0 @@
#include <iostream>
#include <string>
#include <stack>
using std::cin, std::cout, std::string, std::stack;
constexpr size_t MOD {998244353}, MAX_N {(size_t)3e5+5};
string s;
stack<size_t> st;
unsigned int dp[MAX_N], ans, n;
int main(){
cin>>s;
for(size_t i {0};i<s.size();i++){
for(size_t j {0};j<s.size();j++){
}
}
}

View File

@ -1,3 +0,0 @@
//
// Created by Zengt on 2024/10/5.
//

52
src/U206625/U206625.cpp Normal file
View File

@ -0,0 +1,52 @@
#include <iostream>
#include <string>
#include <stack>
#include <cmath>
#include <array>
using std::cin, std::cout, std::string, std::stack, std::array;
constexpr size_t MOD {998244353}, MAX_N {(size_t)3e5+5};
string s;
stack<size_t> st;
unsigned int prefix[MAX_N], ans, sum, left_num;
constexpr size_t char_size {1<<(sizeof(char)*8)};
constexpr array<int,char_size> install_array(){
array<int,char_size> ret{};
ret[40]=1;
// ret[40]=1,ret[41]=-1;
return ret;
}
constexpr array<int,char_size> map = install_array();
int main(){
// cout<<(int)'('<<' '<<(int)')'<<'\n'<<map[40]<<'\n';
cin>>s;
for(size_t i {0};i<s.size();i++){
for(size_t j {i+1};j<=s.size();j++){
// sum=0;
for(size_t k{i};k<j;k++){
for(size_t l{k+1};l<=j;l++){
left_num = 0;
for(size_t m{k};m<l;m++){
left_num+=map[s[m]];
if(left_num<0){
goto failed;
}
if(s[m]==')'){
if(left_num<=0){
goto failed;
}
left_num--;
}
}
if(left_num==0){
ans=(ans+1)%MOD;
}
failed:;
}
}
}
}
cout<<ans<<'\n';
}

59
src/U482031/U482031.cpp Normal file
View File

@ -0,0 +1,59 @@
#include <iostream>
#include <string>
#include <ranges>
#include <vector>
using std::cin, std::cout, std::string, std::vector, std::iostream;
constexpr auto range = std::ranges::views::iota;
int n;
string s;
int a_num, b_num;
char max_char, min_char;
struct Ope{
const size_t start,end;
const char c;
};
vector<Ope> v;
void print()noexcept{
cout<<v.size()<<'\n';
for(auto &i:v){
cout<<i.start+1<<' '<<i.end+1<<' '<<i.c<<'\n';
}
}
int main(){
iostream::sync_with_stdio(false), cin.tie(0), cout.tie(0);
cin>>n;
cin>>s;
for(const int i:range(0,n)){
if(s[i]=='A') {
a_num++;
}else if(s[i]=='B'){
b_num++;
}
}
if(a_num>=b_num){
max_char = 'A';
min_char = 'B';
}else{
max_char = 'B';
min_char = 'A';
}
v.push_back({0,(size_t)n-1,max_char});
for(size_t i=0;i<n;i++){
if(s[i]==min_char){
size_t end {i};
for(size_t j=i+1;j<n;j++){
if(s[j]!=min_char)break;
end=j;
}
v.push_back({i,end,min_char});
i=end+1;
}
}
print();
}