Fri, 22 Feb 2019 20:28:38 GMT
parent
ea4d077431
commit
2c02e984a7
@ -0,0 +1,11 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
if(MSVC)
|
||||
add_compile_options("/Zc:__cplusplus" "/wd6031")
|
||||
endif()
|
||||
include_directories("C:\\Programs\\MSYS2\\mingw64\\include\\c++\\8.2.1\\x86_64-w64-mingw32")
|
||||
add_executable(PA PA.cpp)
|
||||
add_executable(PB PB.cpp)
|
||||
add_executable(PC PC.cpp)
|
||||
add_executable(PD PD.cpp)
|
||||
add_executable(PE PE.cpp)
|
||||
@ -0,0 +1,57 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
struct node
|
||||
{
|
||||
map<string, node> subdir;
|
||||
set<string> file;
|
||||
string name;
|
||||
};
|
||||
void insert_node(node &n, string s)
|
||||
{
|
||||
auto pos = s.find('/');
|
||||
if (pos == string::npos)
|
||||
n.file.insert(s);
|
||||
else
|
||||
insert_node(n.subdir[s.substr(0, pos)], s.substr(pos + 1));
|
||||
}
|
||||
void indent(int x)
|
||||
{
|
||||
while (x--) cout << " ";
|
||||
}
|
||||
void display(node &n, int depth)
|
||||
{
|
||||
for (auto &x : n.subdir)
|
||||
{
|
||||
indent(depth);
|
||||
cout << x.first << endl;
|
||||
display(x.second, depth + 1);
|
||||
}
|
||||
for (auto &x : n.file)
|
||||
indent(depth), cout << x << endl;
|
||||
}
|
||||
int main()
|
||||
{
|
||||
ios::sync_with_stdio(false);
|
||||
int t = 0;
|
||||
string s;
|
||||
node *root = nullptr;
|
||||
while (getline(cin, s))
|
||||
if (s == "0")
|
||||
{
|
||||
cout << "Case " << ++t << ":" << endl;
|
||||
if (root)
|
||||
{
|
||||
display(*root, 0);
|
||||
delete root;
|
||||
}
|
||||
root = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (root == nullptr) root = new node();
|
||||
insert_node(*root, s);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
const int N = 1e5 + 50;
|
||||
char s[N] = ".";
|
||||
int main()
|
||||
{
|
||||
int T;
|
||||
scanf("%d", &T);
|
||||
while (T--)
|
||||
{
|
||||
scanf("%s", s + 1);
|
||||
long long n = strlen(s);
|
||||
long long ans = 0;
|
||||
for (long long i = 1; i < n; i++)
|
||||
{
|
||||
ans += i * (n - i) * ((s[i] == s[i - 1]) + 1);
|
||||
if (s[i] == '0') ans += n - i;
|
||||
if (s[i] == s[i - 1]) ans -= n - i;
|
||||
}
|
||||
printf("%lld\n", ans);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
const int N = 100;
|
||||
int P[N], W[N];
|
||||
char S[N];
|
||||
int main()
|
||||
{
|
||||
int T, n;
|
||||
scanf("%d", &T);
|
||||
while (T--)
|
||||
{
|
||||
scanf("%d", &n);
|
||||
for (int i = 1; i <= n; i++)
|
||||
scanf("%d", P + i);
|
||||
for (int i = 1, j = 1; i <= n; i++)
|
||||
{
|
||||
for (int k = P[i] - P[i - 1]; k; k--)
|
||||
S[j++] = '(';
|
||||
S[j++] = ')';
|
||||
}
|
||||
for (int i = 1, j = 1; i <= (n << 1); i++)
|
||||
if (S[i] == ')')
|
||||
{
|
||||
int w = 0;
|
||||
for (int k = i - 1, c = 1; c; k--)
|
||||
if (S[k] == '(')
|
||||
c--, w++;
|
||||
else
|
||||
c++;
|
||||
W[j++] = w;
|
||||
}
|
||||
for (int i = 1; i <= n; i++)
|
||||
printf("%d%c", W[i], " \n"[i == n]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
const int N = 1e5 + 50;
|
||||
char s1[N << 1], s2[N];
|
||||
int main()
|
||||
{
|
||||
while (~scanf("%s%s", s1, s2))
|
||||
{
|
||||
auto l1 = strlen(s1), l2 = strlen(s2);
|
||||
if (l2 > l1)
|
||||
puts("no");
|
||||
else
|
||||
{
|
||||
memcpy(s1 + l1, s1, l1), s1[l1 << 1] = 0;
|
||||
puts(strstr(s1, s2) ? "yes" : "no");
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Loading…
Reference in new issue