Задача А. Семьонова Поліна
#include <iostream>
#include <deque>
#include <string.h>
#include <ctype.h>
using namespace std;
int main()
{
char vocal[]="AEIOUYaeiouy\0";
int n;
deque<int> vocal_num;
cin>>n;
cin.get();
char text[n+1];
cin.getline(text,n+1);
for(int i=0;i<n;i++)
{
if(strchr(vocal,text[i])){vocal_num.push_back(i);
}
}
while(vocal_num.size()>1)
{
char tmp;
int st=vocal_num.front();
int fn=vocal_num.back();
tmp=text[st];
if(isupper(tmp))text[st]=toupper(text[fn]);else text[st]=tolower(text[fn]);
if(isupper(text[fn]))text[fn]=toupper(tmp);else text[fn]=tolower(tmp);
vocal_num.pop_front();
vocal_num.pop_back();
}
cout<<text<<endl;
return 0;
}
Задача В. Мельник Софія
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const int N = 2e6+10;
const int M = 10;
const string st2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string s1 = "abcdefghijklmnopqrstuvwxyz";
#define mod % MOD
#define filesio(x) freopen(x ".in", "r", stdin); freopen(x ".out", "w", stdout)
#define filesds(x) freopen(x ".dat", "r", stdin); freopen(x ".sol", "w", stdout)
#define filestt(x) freopen(x ".txt", "r", stdin); freopen(x ".txt", "w", stdout)
#define filestxt freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout)
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ms(x, y) memset(x, sizeof(x), y)
#define sqr(a) ((a) * (a))
#define ld long double
#define outld(l) cout.precision(l);cout << fixed
#define s second
#define ll long long
#define f first
#define mp make_pair
#define y1 dbfuebfwkjNBSciwbe
#define time zdfheajbrkjasghduw
#define ull unsigned long long
#define randomize srand(time(NULL))
#define next ifhiuebf
#define last dkbffjrb
int n,res,i,v[N],num[N];
ll ll1,rr1,x,y,a[N],p[N];
pair<ll,int> s[N];
char ccc;
bool _minus;
inline int sum(int r)
{
res=0;
for (int ij=r; ij>=0; ij=(ij&(ij+1))-1)
{
res+=v[ij];
}
return res;
}
inline int sum(int l, int r)
{
return sum(r)-sum(l-1);
}
inline void update(int l, int r)
{
for (int ij=l; ij<=n; ij=(ij|(ij+1)))
{
v[ij]+=r;
}
}
bool kek;
inline void readll(ll &n) {
n = 0;
_minus = false;
kek=false;
while (true) {
ccc = getchar();
if ((ccc == ' ' || ccc == '\n'))
{
if (kek==true) break;
else continue;
}
if (ccc>='0'&&ccc<='9') kek=true;
if (ccc == '-') {
_minus = true;
continue;
}
n = n * 10 + ccc - '0';
}
if (_minus)
n *= -1;
}
inline void readint(int &n) {
n = 0;
_minus = false;
kek=false;
while (true) {
ccc = getchar();
if ((ccc == ' ' || ccc == '\n'))
{
if (kek==true) break;
else continue;
}
if (ccc>='0'&&ccc<='9') kek=true;
if (ccc == '-') {
_minus = true;
continue;
}
n = n * 10 + ccc - '0';
}
if (_minus)
n *= -1;
}
int j,l,r,k,xx,yy;
int main()
{
sync;
readint(n);
readll(x);
readll(y);
for (i=1; i<=n; i++)
{
readll(a[i]);
p[i]=p[i-1]+a[i];
s[i]=mp(p[i],i);
}
for (i=1; i<=n; i++)
for (j=i; j<=n; j++)
if (p[j]-p[i-1]>=x&&p[j]-p[i-1]<=y)
{
}
n++;
s[n]=mp(0,0);
sort(s+1,s+n+1);
for (i=1; i<=n; i++)
num[s[i].second]=i;
for (i=1; i<=n; i++)
if (s[i].s==0) update(i,1);
ll ans=0;
for (i=1; i<n; i++)
{
ll1=p[i]-y;
rr1=p[i]-x;
l=1;
r=n;
while (r-l>1)
{
k=(l+r)>>1;
if (s[k].f>=ll1) r=k; else l=k;
}
xx=n+10;
if (s[l].f>=ll1) xx=l; else
if (s[r].f>=ll1) xx=r;
l=1;
r=n;
while (r-l>1)
{
k=(l+r)>>1;
if (s[k].f<=rr1) l=k; else r=k;
}
yy=-1;
if (s[r].f<=rr1) yy=r; else
if (s[l].f<=rr1) yy=l;
//cout<<ll1<<" "<<rr1<<" "<<xx<<" "<<yy<<endl;
if (xx<=yy)
{
ans+=(ll)sum(xx,yy);
}
//cout<<endl;
// cout<<xx<<" "<<yy<<endl;
update(num[i],1);
}
cout<<ans<<endl;
}
Задача С. Лаврішин Дмитро
#include <iostream>
using namespace std;
int a[2000005],b[2000005],c[2000005];
int n;
long long r;
int main(){
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i];
for (int i = 1; i <= n; i++){
b[i]=max(b[i-1],a[i]);
c[n-i+1]=max(a[n-i+1],c[n-i+2]);
}
for (int i = 1; i <= n; i++)
r+=min(b[i],c[i])-a[i];
cout << r;
}
Задача D. Миронюк Костянтин
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
int waterAmount(vector < vector<int>>& height) {
typedef pair <int, int> cell;
priority_queue <cell, vector <cell>, greater<cell>> q;
int m = height.size();
if (m == 0) return 0;
int n = height[0].size();
vector <int> was(m * n, false);
for (int i = 0; i < m; ++i) {
for (int j = 0; j < n; ++j) {
if (i == 0 || i == (m - 1) || j == 0 || j == (n - 1)) {
if (!was[i*n + j])
q.push(cell(height[i][j], i*n + j));
was[i*n + j] = true;
}
}
}
int dir[4][2] = {{0,1}, {0, -1}, {1, 0}, {-1, 0}}, res = 0;
while (!q.empty()) {
cell newCell = q.top(); q.pop();
int i = newCell.S / n,
j = newCell.S % n;
for (int nd = 0; nd < 4; nd ++) {
int i2 = i + dir[nd][0],
j2 = j + dir[nd][1];
if (i2 < 0 || i2 >= m || j2 < 0 || j2 >= n || was[i2*n + j2])
continue;
res += max(0, newCell.F - height[i2][j2]);
q.push(cell(max(newCell.F, height[i2][j2]), i2*n+j2));
was[i2*n + j2] = true;
}
}
return res;
}
int main()
{
ios_base::sync_with_stdio(false);
int n, m, x;
cin >> n >> m;
vector <vector <int>> h(n);
for (int i = 0; i < n; i ++) {
for (int j = 0; j < m; j ++) {
cin >> x;
h[i].push_back(x);
}
}
cout << waterAmount(h);
}
Задача Е. Бушовський Олександр
print(''.join(['1' if int(x)%8==0 else '0' for x in input().split()]))