0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-27 13:56:26 +00:00

fix: format all cpp codes

This commit is contained in:
Baoshuo Ren 2021-11-19 17:01:13 +08:00 committed by Baoshuo Ren
parent 9f0d4bedd0
commit f0aae01668
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68
170 changed files with 586 additions and 728 deletions

View File

@ -27,8 +27,8 @@ void dfs(int u) {
int main() {
cin >> n;
for(int i = 0 ; i < n ; i++) {
for(int j = 0 ; j < n ; j++) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
g[i][j] = '.';
}
}

View File

@ -8,7 +8,8 @@ string s;
int main() {
cin >> s;
sort(s.begin(), s.end());
do ans++;
do
ans++;
while (next_permutation(s.begin(), s.end()));
cout << ans << endl;
return 0;

View File

@ -45,8 +45,10 @@ void modify(int u, int x, int v) {
return;
}
int mid = tr[u].l + tr[u].r >> 1;
if (x <= mid) modify(u << 1, x, v);
else modify(u << 1 | 1, x, v);
if (x <= mid)
modify(u << 1, x, v);
else
modify(u << 1 | 1, x, v);
pushup(u);
}

View File

@ -1,3 +1,5 @@
#include<stdio.h>
char s[]="#include<stdio.h>%cchar%cs[]=%c%s%c%c%cint main(){printf(s,10,32,34,s,34,59,10);}";
int main(){printf(s,10,32,34,s,34,59,10);}
#include <stdio.h>
char s[] = "#include<stdio.h>%cchar%cs[]=%c%s%c%c%cint main(){printf(s,10,32,34,s,34,59,10);}";
int main() {
printf(s, 10, 32, 34, s, 34, 59, 10);
}

View File

@ -1,6 +1,7 @@
#include "interaction.h"
#include <bits/stdc++.h>
#include "interaction.h"
using namespace std;
int n;

View File

@ -1,4 +1,4 @@
#include<bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
@ -10,8 +10,8 @@ int main() {
s += t;
cin >> t;
s += t;
for(int i = 0 ; i < 9 ; i++) {
if(s[i] != s[8-i]) {
for (int i = 0; i < 9; i++) {
if (s[i] != s[8 - i]) {
cout << "NO" << endl;
return 0;
}

View File

@ -1,11 +1,11 @@
#include<bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
int main() {
int t, a, b;
cin >> t;
while(t--) {
while (t--) {
cin >> a >> b;
cout << a + b - (a & b) * 2 << endl;
}

View File

@ -25,11 +25,9 @@ int main() {
}
if (flag) {
cout << "No" << endl;
}
else {
} else {
cout << "Yes" << endl;
}
}
return 0;
}

View File

@ -9,12 +9,11 @@ int main() {
for (int i = 0; i < n; i++) {
if (i >= 3) {
cin >> t;
}
else {
} else {
t = a[i];
}
if (t % 2 != o) {
cout << i+1 << endl;
cout << i + 1 << endl;
return 0;
}
}

View File

@ -10,11 +10,9 @@ int main() {
// abc abd acd bcd
if (a + b > c && a + c > b && b + c > a || a + b > d && a + d > b && b + d > a || a + c > d && a + d > c && c + d > a || b + c > d && b + d > c && c + d > b) {
cout << "TRIANGLE" << endl;
}
else if (a + b >= c && a + c >= b && b + c >= a || a + b >= d && a + d >= b && b + d >= a || a + c >= d && a + d >= c && c + d >= a || b + c >= d && b + d >= c && c + d >= b) {
} else if (a + b >= c && a + c >= b && b + c >= a || a + b >= d && a + d >= b && b + d >= a || a + c >= d && a + d >= c && c + d >= a || b + c >= d && b + d >= c && c + d >= b) {
cout << "SEGMENT" << endl;
}
else {
} else {
cout << "IMPOSSIBLE" << endl;
}
return 0;

View File

@ -1,4 +1,4 @@
#include<bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
@ -10,20 +10,18 @@ int main() {
int n;
pair<int, int> p[200005];
cin >> n;
for(int i = 0 ; i < n ; i++) {
for (int i = 0; i < n; i++) {
cin >> p[i].first >> p[i].second;
}
sort(p, p+n, cmp);
sort(p, p + n, cmp);
int tv1 = -1, tv2 = -1;
for(int i = 0 ; i < n ; i++) {
if(p[i].first > tv1) {
for (int i = 0; i < n; i++) {
if (p[i].first > tv1) {
tv1 = p[i].second;
}
else {
if(p[i].first > tv2) {
} else {
if (p[i].first > tv2) {
tv2 = p[i].second;
}
else {
} else {
cout << "NO" << endl;
return 0;
}

View File

@ -23,8 +23,7 @@ int main() {
for (int j = 2; j <= by; j++) {
if (b[i][j]) {
continue;
}
else {
} else {
f[i][j] = max(f[i][j], f[i - 1][j] + f[i][j - 1]);
}
}

View File

@ -18,14 +18,12 @@ string add(string b, int k) {
for (int i = 0; i < len; i++) {
if (isdigit(a[i])) {
numa[len - i] = a[i] - '0';
}
else {
} else {
numa[len - i] = a[i] - 'A' + 10;
}
if (isdigit(b[i])) {
numb[len - i] = b[i] - '0';
}
else {
} else {
numb[len - i] = b[i] - 'A' + 10;
}
}

View File

@ -5,25 +5,25 @@ using namespace std;
int n, l1, l2, a[100005], d1[100005], d2[100005];
int main() {
while (cin >> a[++n]);
while (cin >> a[++n])
;
n--;
d1[++l1] = d2[++l2] = a[1];
for (int i = 2; i <= n; i++) {
if (d1[l1] >= a[i]) {
d1[++l1] = a[i];
}
else {
} else {
int* it = upper_bound(d1 + 1, d1 + 1 + l1, a[i], greater<int>());
*it = a[i];
}
if (d2[l2] < a[i]) {
d2[++l2] = a[i];
}
else {
} else {
int* it = lower_bound(d2 + 1, d2 + 1 + l2, a[i], less<int>());
*it = a[i];
}
}
cout << l1 << endl << l2 << endl;
cout << l1 << endl
<< l2 << endl;
return 0;
}

View File

@ -14,8 +14,7 @@ int main() {
for (int j = 0; j <= n; j++) {
if (j >= v[i]) {
f[i][j] = max(f[i - 1][j], f[i - 1][j - v[i]] + w[i]);
}
else {
} else {
f[i][j] = f[i - 1][j];
}
}

View File

@ -21,8 +21,7 @@ int main() {
if (n == 5 && m == 3) {
printf("78 4\n2783 95\n9323 89\n7972 88\n2538 78");
return 0;
}
else if (n == 87 && m == 35) {
} else if (n == 87 && m == 35) {
printf("77 52\n5081 100\n8736 100\n2855 99\n6347 99\n3191 96\n6090 95\n9917 95\n1832 94\n3169 92\n3404 92\n6982 92\n9494 92\n3535 91\n8569 91\n9319 90\n1896 89\n9701 89\n3321 88\n6017 88\n6158 88\n6361 88\n7353 88\n4011 87\n4967 87\n8017 87\n8944 87\n4746 86\n7313 86\n7486 86\n9250 86\n4808 85\n4982 85\n6979 85\n7327 85\n7887 85\n7651 84\n8456 84\n8850 84\n1423 83\n7889 82\n6891 81\n8779 81\n1174 80\n4116 80\n4141 80\n5473 80\n7172 79\n8562 79\n5392 78\n4301 77\n4551 77\n5498 77\n");
return 0;
}

View File

@ -8,10 +8,9 @@ int main() {
cin >> k >> c;
for (int i = 0; i < c.size(); i++) {
t = (k[i % k.size()] & 31) - 1;
if((c[i] & 31) - t > 0) {
if ((c[i] & 31) - t > 0) {
c[i] = c[i] - t;
}
else {
} else {
c[i] = c[i] - t + 26;
}
}

View File

@ -1,4 +1,4 @@
#include<bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
@ -18,8 +18,8 @@ struct node {
};
bool cmp(node a, node b) {
if(a.all == b.all) {
if(a.chinese == b.chinese) {
if (a.all == b.all) {
if (a.chinese == b.chinese) {
return a.id < b.id;
}
return a.chinese > b.chinese;
@ -31,13 +31,13 @@ int main() {
int n;
node a[305];
cin >> n;
for(int i = 0 ; i < n ; i++) {
for (int i = 0; i < n; i++) {
cin >> a[i].chinese >> a[i].math >> a[i].english;
a[i].all = a[i].chinese + a[i].math + a[i].english;
a[i].id = i+1;
a[i].id = i + 1;
}
sort(a, a+n, cmp);
for(int i = 0 ; i < 5 ; i++) {
sort(a, a + n, cmp);
for (int i = 0; i < 5; i++) {
cout << a[i].id << ' ' << a[i].all << endl;
}
return 0;

View File

@ -15,8 +15,7 @@ int main() {
l++;
r--;
ans++;
}
else {
} else {
r--;
ans++;
}

View File

@ -14,15 +14,13 @@ int main() {
for (int i = 0; i < n; i++) {
if (a[i] > r) {
p += a[i] - r;
}
else if (a[i] < l) {
} else if (a[i] < l) {
q += l - a[i];
}
}
if (n * r < sum) {
cout << -1 << endl;
}
else {
} else {
cout << max(p, q) << endl;
}
return 0;

View File

@ -1,23 +1,23 @@
#include<bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n, m, a[2005][2005], f[2005][2005];
cin >> n >> m;
for(int i = 1 ; i <= m ; i++) {
for(int j = 1 ; j <= n ; j++) {
for (int i = 1; i <= m; i++) {
for (int j = 1; j <= n; j++) {
cin >> a[j][i];
}
}
for(int i = 1 ; i <= n ; i++) {
f[i-1][0] = f[i-1][m];
for(int j = 1 ; j <= m ; j++) {
f[i][j] = a[i][j] + min(f[i-1][j], f[i-1][j-1]);
for (int i = 1; i <= n; i++) {
f[i - 1][0] = f[i - 1][m];
for (int j = 1; j <= m; j++) {
f[i][j] = a[i][j] + min(f[i - 1][j], f[i - 1][j - 1]);
}
}
long long ans = f[n][1];
for(int i = 2 ; i <= m ; i++) {
for (int i = 2; i <= m; i++) {
ans = min(ans, f[n][i]);
}
cout << ans << endl;

View File

@ -14,8 +14,7 @@ int main() {
n = unique(a, a + n) - a;
if (k >= n) {
cout << "NO RESULT" << endl;
}
else {
} else {
cout << a[--k];
}
return 0;

View File

@ -1,6 +1,6 @@
// R38820772
#include<bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
@ -9,12 +9,12 @@ int n, a[1005];
int main() {
cin >> n;
for(int i = 0 ; i < n ; i++) {
cin >>a[i];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for(int i = 1 ; i < n ; i++) {
if(!cnt[abs(a[i]-a[i-1])]) {
cnt[abs(a[i]-a[i-1])] = true;
for (int i = 1; i < n; i++) {
if (!cnt[abs(a[i] - a[i - 1])]) {
cnt[abs(a[i] - a[i - 1])] = true;
} else {
cout << "Not jolly" << endl;
return 0;

View File

@ -1,6 +1,6 @@
// R36448353
#include<bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
@ -10,10 +10,10 @@ int main() {
double a;
n = t = ans = 0;
cin >> n;
for(int i = 1 ; i <= n ; i++) {
for (int i = 1; i <= n; i++) {
cin >> a >> t;
for(int j = 1 ; j <= t ; j++) {
ans ^= int(j*a);
for (int j = 1; j <= t; j++) {
ans ^= int(j * a);
}
}
cout << ans << endl;

View File

@ -23,8 +23,7 @@ int main() {
cin >> a[i][j];
if (a[i][j] == 0) {
b[i][j] = 0;
}
else {
} else {
b[i][j] = 1;
}
}
@ -34,11 +33,9 @@ int main() {
for (int j = 1; j <= n; j++) {
if (b[i][j] == 2) {
cout << "0 ";
}
else if (b[i][j] == 0) {
} else if (b[i][j] == 0) {
cout << "2 ";
}
else {
} else {
cout << "1 ";
}
}

View File

@ -11,8 +11,7 @@ int main() {
mid = (l + r) / 2;
if (pow(1.0 / (1.0 + mid), k) >= 1 - n / m * mid) {
r = mid;
}
else {
} else {
l = mid;
}
}

View File

@ -1,4 +1,4 @@
#include<bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
@ -7,24 +7,23 @@ int main() {
priority_queue<int, vector<int>, less<int> > s;
priority_queue<int, vector<int>, greater<int> > l;
cin >> n;
for(int i = 1 ; i <= n ; i++) {
for (int i = 1; i <= n; i++) {
cin >> a[i];
k = i/2+1;
if(!l.empty() && a[i] >= l.top()) {
k = i / 2 + 1;
if (!l.empty() && a[i] >= l.top()) {
s.push(a[i]);
}
else {
} else {
l.push(a[i]);
}
while(l.size() < k) {
while (l.size() < k) {
l.push(s.top());
s.pop();
}
while(s.size() < k) {
while (s.size() < k) {
s.push(l.top());
l.pop();
}
if(i%2) {
if (i % 2) {
cout << s.top() << endl;
}
}

View File

@ -1,21 +1,21 @@
#include<bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
if(b == 0) {
if (b == 0) {
return a;
}
return gcd(b, a%b);
return gcd(b, a % b);
}
int main() {
int t;
cin >> t;
while(t--) {
while (t--) {
int ax, ay, bx, by;
cin >> ax >> ay >> bx >> by;
cout << (gcd(abs(ax-bx), abs(ay-by)) == 1 ? "no" : "yes") << endl;
cout << (gcd(abs(ax - bx), abs(ay - by)) == 1 ? "no" : "yes") << endl;
}
return 0;
}

View File

@ -10,8 +10,7 @@ int main() {
if (sum + t > m) {
ans++;
sum = t;
}
else {
} else {
sum += t;
}
}

View File

@ -9,8 +9,7 @@ bool check(int x) {
for (int i = 1; i <= n; i++) {
if (tot + a[i] <= x) {
tot += a[i];
}
else {
} else {
tot = a[i];
num++;
}
@ -28,8 +27,7 @@ int main() {
mid = l + r >> 1;
if (check(mid)) {
l = mid + 1;
}
else {
} else {
r = mid - 1;
}
}

View File

@ -26,12 +26,10 @@ int main() {
if (op == 'A') {
a[++n] = (x + t) % d;
change(n);
}
else if (op == 'Q') {
} else if (op == 'Q') {
if (x == 1) {
cout << (t = a[n]) << endl;
}
else {
} else {
cout << (t = find(n - x + 1, n)) << endl;
}
}

View File

@ -8,16 +8,22 @@ int main() {
getline(cin, a);
getline(cin, b);
for (int i = 0; i < 7; i++) {
if (a[i] <= 0) break;
else us *= a[i] - 64;
if (a[i] <= 0)
break;
else
us *= a[i] - 64;
}
for (int i = 0; i < 7; i++) {
if (b[i] <= 0) break;
else zs *= b[i] - '@';
if (b[i] <= 0)
break;
else
zs *= b[i] - '@';
}
us %= 47;
zs %= 47;
if (us == zs) cout << "GO" << endl;
else cout << "STAY" << endl;
if (us == zs)
cout << "GO" << endl;
else
cout << "STAY" << endl;
return 0;
}

View File

@ -26,8 +26,7 @@ int main() {
for (int i = 1; i < n; i++) {
if (a[i].start <= end) {
end = max(end, a[i].end);
}
else {
} else {
ans1 = max(ans1, end - start);
ans2 = max(ans2, a[i].start - end);
start = a[i].start;

View File

@ -1,6 +1,6 @@
// R36572888
#include<bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;

View File

@ -1,23 +1,23 @@
#include<bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, a[1005][1005], f[1005][1005];
cin >> n;
for(int i = 1 ; i <= n ; i++) {
for(int j = 1 ; j <= i ; j++) {
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= i; j++) {
cin >> a[i][j];
}
}
f[1][1] = a[1][1];
for(int i = 1 ; i <= n ; i++) {
for(int j = 1 ; j <= i+1 ; j++) {
f[i][j] = a[i][j] + max(f[i-1][j], f[i-1][j-1]);
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= i + 1; j++) {
f[i][j] = a[i][j] + max(f[i - 1][j], f[i - 1][j - 1]);
}
}
int ans = -0x3f3f3f;
for(int i = 1 ; i <= n ; i++) {
for (int i = 1; i <= n; i++) {
ans = max(ans, f[n][i]);
}
cout << ans << endl;

View File

@ -22,12 +22,10 @@ int main() {
if (st.empty() || b[st.top()] != s[i]) {
if (s[i] == ')') {
b[i] = '(';
}
else {
} else {
b[i] = '[';
}
}
else {
} else {
b[st.top()] = ' ';
st.pop();
}

View File

@ -1,17 +1,17 @@
// R38787626
#include<bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, a[2000005];
cin >> n >> m;
for(int i = 0 ; i < m ; i++) {
for (int i = 0; i < m; i++) {
cin >> a[i];
}
sort(a, a+m);
for(int i = 0 ; i < m ; i++) {
sort(a, a + m);
for (int i = 0; i < m; i++) {
cout << a[i] << ' ';
}
cout << endl;

View File

@ -14,15 +14,15 @@ int main() {
cin >> s[0];
n = s[0].size();
for(int i = 1 ; i < n ; i++) {
for (int i = 1; i < n; i++) {
cin >> s[i];
}
cout << n << " ";
for(int i = 0 ; i < n ; i++) {
for(int j = 0 ; j < n ; j++) {
if(s[i][j] == l) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (s[i][j] == l) {
c++;
} else {
cout << c << " "; // 输出以前统计完的

View File

@ -17,6 +17,7 @@ int main() {
girl += (s[i] == 'g' || s[i + 1] == 'i' || s[i + 2] == 'r' || s[i + 3] == 'l');
}
cout << boy << endl << girl << endl;
cout << boy << endl
<< girl << endl;
return 0;
}

View File

@ -12,7 +12,7 @@ int main() {
f[i] = 0x3f3f3f;
}
f[n] = 0;
for (int i = n-1; i >= 0; i--) {
for (int i = n - 1; i >= 0; i--) {
for (int j = i + 1; j <= n; j++) {
f[i] = min(f[i], f[j] + a[i][j]);
}

View File

@ -6,17 +6,17 @@ int n, m, op, l, r, k, d, p, a[100005];
int main() {
cin >> n >> m;
for(int i = 1 ; i <= n ; i++) {
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for(int i = 0 ; i < m ; i++) {
for (int i = 0; i < m; i++) {
cin >> op;
if(op == 1) {
if (op == 1) {
cin >> l >> r >> k >> d;
for(int j = l ; j <= r ; j++) {
for (int j = l; j <= r; j++) {
a[j] += k + (j - l) * d;
}
} else if(op == 2) {
} else if (op == 2) {
cin >> p;
cout << a[p] << endl;
}

View File

@ -10,24 +10,21 @@ int main() {
if (ch == '.') {
st.push(t);
t = 0;
}
else if('0' <= ch && ch <= '9') {
} else if ('0' <= ch && ch <= '9') {
t *= 10;
t += ch - '0';
}
else {
b = st.top(); st.pop();
a = st.top(); st.pop();
} else {
b = st.top();
st.pop();
a = st.top();
st.pop();
if (ch == '+') {
st.push(a + b);
}
else if (ch == '-') {
} else if (ch == '-') {
st.push(a - b);
}
else if (ch == '*') {
} else if (ch == '*') {
st.push(a * b);
}
else if (ch == '/') {
} else if (ch == '/') {
st.push(a / b);
}
}

View File

@ -43,8 +43,7 @@ void modify(int u, int x, int d) {
int mid = tr[u].l + tr[u].r >> 1;
if (x <= mid) {
modify(u << 1, x, d);
}
else {
} else {
modify(u << 1 | 1, x, d);
}
pushup(u);
@ -75,8 +74,7 @@ int main() {
cin >> op >> x >> y;
if (op == 'U') {
modify(1, x, y);
}
else if (op == 'Q') {
} else if (op == 'Q') {
cout << query(1, x, y) << endl;
}
}

View File

@ -22,8 +22,7 @@ int main() {
cin >> x >> y;
if (find(x) == find(y)) {
cout << "Yes" << endl;
}
else {
} else {
cout << "No" << endl;
}
}

View File

@ -8,12 +8,12 @@ int n, m, js[10];
int main() {
cin >> n >> m;
for(int i = n ; i <= m ; i++) {
for(int j = i ; j ; j /= 10) {
js[j%10]++;
for (int i = n; i <= m; i++) {
for (int j = i; j; j /= 10) {
js[j % 10]++;
}
}
for(int i = 0 ; i < 10 ; i++) {
for (int i = 0; i < 10; i++) {
cout << js[i] << " ";
}
return 0;

View File

@ -22,16 +22,13 @@ int main() {
if (a[now].towards == 0) {
if (x == 0) {
now = (now + n - y) % n;
}
else if (x == 1) {
} else if (x == 1) {
now = (now + y) % n;
}
}
else if (a[now].towards == 1) {
} else if (a[now].towards == 1) {
if (x == 0) {
now = (now + y) % n;
}
else if (x == 1) {
} else if (x == 1) {
now = (now + n - y) % n;
}
}

View File

@ -12,8 +12,7 @@ int main() {
for (int i = 1; i < n; i++) {
if (a[i] > a[i - 1]) {
f[i] = f[i - 1] + 1;
}
else {
} else {
f[i] = 0;
}
}

View File

@ -1,6 +1,6 @@
// https://www.luogu.com.cn/record/38654562
#include<bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
@ -11,14 +11,14 @@ int main() {
a = b = c = 0;
cin >> s;
for(int i = 0 ; i < s.size() ; i += 5) {
cout << s[i] << ' ' << s[i+3] << ' ';
switch(s[i]) {
for (int i = 0; i < s.size(); i += 5) {
cout << s[i] << ' ' << s[i + 3] << ' ';
switch (s[i]) {
case 'a':
if('0' <= s[i+3] && s[i+3] <= '9') {
a = s[i+3] - '0';
if ('0' <= s[i + 3] && s[i + 3] <= '9') {
a = s[i + 3] - '0';
} else {
switch(s[i+3]) {
switch (s[i + 3]) {
case 'a':
a = a;
break;
@ -32,10 +32,10 @@ int main() {
}
break;
case 'b':
if('0' <= s[i+3] && s[i+3] <= '9') {
b = s[i+3] - '0';
if ('0' <= s[i + 3] && s[i + 3] <= '9') {
b = s[i + 3] - '0';
} else {
switch(s[i+3]) {
switch (s[i + 3]) {
case 'a':
b = a;
break;
@ -49,10 +49,10 @@ int main() {
}
break;
case 'c':
if('0' <= s[i+3] && s[i+3] <= '9') {
c = s[i+3] - '0';
if ('0' <= s[i + 3] && s[i + 3] <= '9') {
c = s[i + 3] - '0';
} else {
switch(s[i+3]) {
switch (s[i + 3]) {
case 'a':
c = a;
break;

View File

@ -30,8 +30,7 @@ int main() {
if (cnt[j] == max) {
printf("%s%c", j == 0 ? "" : " ", '*');
cnt[j]--;
}
else {
} else {
printf("%s%s", j == 0 ? "" : " ", " ");
}
}

View File

@ -1,98 +1,98 @@
// https://www.luogu.com.cn/record/20137358
#include<bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
long long c = 0, word[6] = {0,0,0,0,0,0}, out = 0;
long long c = 0, word[6] = {0, 0, 0, 0, 0, 0}, out = 0;
int getst(string s, long long &c) {
if(s=="one" || s=="a" || s=="first" || s=="another") {
word[c] = 1 ;
if (s == "one" || s == "a" || s == "first" || s == "another") {
word[c] = 1;
c++;
return 0;
}
if(s == "two" || s == "both" || s == "second") {
if (s == "two" || s == "both" || s == "second") {
word[c] = 4;
c++;
return 0;
}
if(s == "three" || s == "third") {
word[c]=9;
if (s == "three" || s == "third") {
word[c] = 9;
c++;
return 0;
}
if(s == "four") {
if (s == "four") {
word[c] = 16;
c++;
return 0;
}
if(s == "five") {
if (s == "five") {
word[c] = 25;
c++;
return 0;
}
if(s == "six") {
if (s == "six") {
word[c] = 36;
c++;
return 0;
}
if(s == "seven") {
if (s == "seven") {
word[c] = 49;
c++;
return 0;
}
if(s == "eight") {
if (s == "eight") {
word[c] = 64;
c++;
return 0;
}
if(s == "nine") {
if (s == "nine") {
word[c] = 81;
c++;
return 0;
}
if(s == "eleven") {
if (s == "eleven") {
word[c] = 21;
c++;
return 0;
}
if(s == "twelve") {
if (s == "twelve") {
word[c] = 44;
c++;
return 0;
}
if(s == "thirteen") {
if (s == "thirteen") {
word[c] = 69;
c++;
return 0;
}
if(s == "fourteen") {
if (s == "fourteen") {
word[c] = 96;
c++;
return 0;
}
if(s == "fifteen") {
if (s == "fifteen") {
word[c] = 25;
c++;
return 0;
}
if(s == "sixteen") {
if (s == "sixteen") {
word[c] = 56;
c++;
return 0;
}
if(s == "seventeen") {
if (s == "seventeen") {
word[c] = 89;
c++;
return 0;
}
if(s == "eightteen") {
if (s == "eightteen") {
word[c] = 24;
c++;
return 0;
}
if(s == "nineteen") {
if (s == "nineteen") {
word[c] = 61;
c++;
return 0;
@ -101,15 +101,15 @@ int getst(string s, long long &c) {
int main(void) {
string getit[6];
for (int i = 0 ; i < 6 ; i++) {
for (int i = 0; i < 6; i++) {
cin >> getit[i];
if (getit[i][getit[i].size()-1] == '.') {
getit[i].erase(getit[i].size()-1,1);
if (getit[i][getit[i].size() - 1] == '.') {
getit[i].erase(getit[i].size() - 1, 1);
}
getst(getit[i] , c);
getst(getit[i], c);
}
sort(word , word + c);
for(int i = 0 ; i < c ; i++) {
sort(word, word + c);
for (int i = 0; i < c; i++) {
out += word[i];
out *= 100;
}

View File

@ -23,7 +23,7 @@ void dfs(int x, int y) {
int main() {
cin >> n >> m >> t >> sx >> sy >> fx >> fy;
for(int i = 0 ; i < t ; i++) {
for (int i = 0; i < t; i++) {
int x, y;
cin >> x >> y;
vis[x][y] = -1;

View File

@ -5,14 +5,14 @@
using namespace std;
int main() {
int n, m, a[100005], minn=100000, t=0;
int n, m, a[100005], minn = 100000, t = 0;
cin >> n >> m;
for(int i = 1 ; i <= n ; i++) {
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for(int i = 1 ; i <= n-m+1 ; i++) {
for(int j = 1 ; j <= m ; j++) {
t += a[i+j-1];
for (int i = 1; i <= n - m + 1; i++) {
for (int j = 1; j <= m; j++) {
t += a[i + j - 1];
}
minn = min(t, minn);
t = 0;

View File

@ -1,12 +1,12 @@
#include<bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
int main() {
unsigned long long x, n, ans=1;
unsigned long long x, n, ans = 1;
cin >> x >> n;
for(unsigned long long i = 0 ; i < n ; i++) {
ans += ans*x;
for (unsigned long long i = 0; i < n; i++) {
ans += ans * x;
}
cout << ans << endl;
return 0;

View File

@ -32,8 +32,7 @@ int main() {
if (d >= 365) {
ans++;
}
}
else {
} else {
m++;
}
}

View File

@ -15,11 +15,9 @@ int main() {
int p = lower_bound(a, a + m, q) - a;
if (p == m) {
ans += q - a[m - 1];
}
else if (p == 0) {
} else if (p == 0) {
ans += a[0] - q;
}
else {
} else {
ans += min(abs(a[p] - q), abs(q - a[p - 1]));
}
}

View File

@ -16,7 +16,7 @@ void dfs(int cnt, int k, int last) {
return;
}
int i = last;
while (i*i*i*i <= n - cnt) {
while (i * i * i * i <= n - cnt) {
i++;
}
while (i >= last) {

View File

@ -8,10 +8,10 @@ int main() {
int n, a[11] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
scanf("%d", &n);
do {
for (int i = 0; i < n-1; i++) {
for (int i = 0; i < n - 1; i++) {
printf("%5d", a[i]);
}
printf("%5d\n", a[n-1]);
printf("%5d\n", a[n - 1]);
} while (next_permutation(a, a + n));
return 0;
}

View File

@ -1,4 +1,4 @@
#include<bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
@ -7,22 +7,22 @@ const int fib[] = {0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610,
int main() {
int t, n;
cin >> t;
while(t--) {
while (t--) {
stack<int> st;
cin >> n;
cout << n << "=";
for(int i = 45 ; i > 0 ; i--) {
while(n >= fib[i]) {
for (int i = 45; i > 0; i--) {
while (n >= fib[i]) {
n -= fib[i];
st.push(fib[i]);
}
if(n == 0) {
if (n == 0) {
break;
}
}
cout << st.top();
st.pop();
while(!st.empty()) {
while (!st.empty()) {
cout << "+" << st.top();
st.pop();
}

View File

@ -12,8 +12,7 @@ int main() {
while (scanf("%c", &c) != EOF) {
if (c == ' ') {
cnt++;
}
else if('a' <= c && c <= 'z') {
} else if ('a' <= c && c <= 'z') {
cnt += num[c - 'a'];
}
// cout << c << ' ' << cnt << endl;

View File

@ -30,8 +30,7 @@ int main() {
cin >> l >> r;
if (l > m || r > m || l < 1 || r < 1) {
cout << "Crossing the line" << endl;
}
else {
} else {
cout << ans[r] - ans[l - 1] << endl;
}
}

View File

@ -2,7 +2,6 @@
using namespace std;
long long n, m, l, r, ans, a[1000005];
bool check(long long x) {
@ -25,8 +24,7 @@ int main() {
long long mid = l + r >> 1;
if (check(mid)) {
l = (ans = mid) + 1;
}
else {
} else {
r = mid - 1;
}
}

View File

@ -29,8 +29,7 @@ int main() {
mid2 = r - (r - l) / 3.0;
if (check(mid1) > check(mid2)) {
l = mid1;
}
else {
} else {
r = mid2;
}
}

View File

@ -23,11 +23,9 @@ int main() {
}
if (ans[3] == 1 && ans[2] == 0 && ans[1] == 0) {
cout << 100 << endl;
}
else if ((ans[2] + ans[3]) % 10) {
} else if ((ans[2] + ans[3]) % 10) {
cout << (ans[2] + ans[3]) % 10 << (ans[1] + ans[2]) % 10 << endl;
}
else {
} else {
cout << (ans[1] + ans[2]) % 10 << endl;
}
return 0;

View File

@ -13,8 +13,7 @@ void merge_sort(long long a[], long long l, long long r) {
while (i <= mid && j <= r) {
if (a[i] <= a[j]) {
t[k++] = a[i++];
}
else {
} else {
t[k++] = a[j++];
ans += (mid - i + 1);
}

View File

@ -17,11 +17,9 @@ string cnm() {
while (n--) {
s += str;
}
}
else if (ch == ']') {
} else if (ch == ']') {
return s;
}
else {
} else {
s += ch;
}
}

View File

@ -7,8 +7,7 @@ extern "C" int Chtholly(int n, int OvO) {
if (Seniorious(mid) >= 0) {
ans = mid;
r = mid - 1;
}
else {
} else {
l = mid + 1;
}
mid = l + r >> 1;

View File

@ -26,8 +26,7 @@ int main() {
for (int j = a[1]; j < a[a[0]]; j++) {
if (a[l] == j) {
l++;
}
else {
} else {
for (int k = 1; k <= a[0]; k++) {
if (!v[a[k]][j]) {
int t = a[k];

View File

@ -84,12 +84,10 @@ signed main() {
if (op == 1) {
cin >> k;
modify(1, x, y, k, 0);
}
else if (op == 2) {
} else if (op == 2) {
cin >> k;
modify(1, x, y, 1, k);
}
else if (op == 3) {
} else if (op == 3) {
cout << query(1, x, y) % p << endl;
}
}

View File

@ -37,8 +37,10 @@ void modify(int u, int x, int d) {
return;
}
int mid = tr[u].l + tr[u].r >> 1;
if (x <= mid) modify(u << 1, x, d);
else modify(u << 1 | 1, x, d);
if (x <= mid)
modify(u << 1, x, d);
else
modify(u << 1 | 1, x, d);
pushup(u);
}
@ -60,8 +62,7 @@ int main() {
cin >> op >> a >> b;
if (op == 'x') {
modify(1, a, b);
}
else if (op == 'y') {
} else if (op == 'y') {
cout << query(1, a, b) << endl;
}
}

View File

@ -28,11 +28,9 @@ int main() {
long long w, c;
cin >> w >> c;
a.insert(node(w, c));
}
else if (op == 2 && !a.empty()) {
} else if (op == 2 && !a.empty()) {
a.erase(--a.end());
}
else if (op == 3 && !a.empty()) {
} else if (op == 3 && !a.empty()) {
a.erase(a.begin());
}
}

View File

@ -8,7 +8,7 @@ string s;
int main() {
cin >> m >> s;
for (int i = 0; i < s.size(); i++) {
if(s[i] == '0') {
if (s[i] == '0') {
continue;
}
if (i != 0) {

View File

@ -15,8 +15,7 @@ int main() {
vector<int>::iterator it = lower_bound(nums.begin(), nums.end(), t);
if (*it == t) {
cout << it - nums.begin() + 1 << ' ';
}
else {
} else {
cout << "-1 ";
}
}

View File

@ -80,20 +80,16 @@ int main() {
if (op == 1) {
cin >> x >> y >> k;
modify(1, x, y, k);
}
else if(op == 2) {
} else if (op == 2) {
cin >> k;
modify(1, 1, 1, k);
}
else if(op == 3) {
} else if (op == 3) {
cin >> k;
modify(1, 1, 1, -k);
}
else if(op == 4) {
} else if (op == 4) {
cin >> x >> y;
cout << query(1, x, y) << endl;
}
else if(op == 5) {
} else if (op == 5) {
cout << query(1, 1, 1) << endl;
}
}

View File

@ -1,19 +1,17 @@
#include<bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
if(n <= 8) {
if (n <= 8) {
cout << 0 << endl;
}
else if(n == 9) {
} else if (n == 9) {
cout << 8 << endl;
}
else {
} else {
cout << 72;
for(int i = 10 ; i < n ; i++) {
for (int i = 10; i < n; i++) {
cout << 0;
}
cout << endl;

View File

@ -7,10 +7,10 @@ int n, a[10];
void dfs(int x, int depth, int last) {
if (x > n) return;
if (x == n) {
for(int i = 1 ; i < depth - 1 ; i++) {
for (int i = 1; i < depth - 1; i++) {
cout << a[i] << '+';
}
cout << a[depth-1] << endl;
cout << a[depth - 1] << endl;
return;
}
for (int i = last; i < n; i++) {

View File

@ -1,4 +1,4 @@
#include<bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
@ -7,51 +7,38 @@ int main() {
cin >> T;
if (T == 1) {
cout << "I love Luogu!";
}
else if (T == 2) {
} else if (T == 2) {
cout << 2 + 4 << " " << 10 - 2 - 4;
}
else if (T == 3) {
} else if (T == 3) {
cout << 3 << endl
<< 12 << endl
<< 2 << endl;
}
else if (T == 4) {
} else if (T == 4) {
printf("%.3lf\n", 500.0 / 3.0);
}
else if (T == 5) {
} else if (T == 5) {
cout << 15 << endl;
}
else if (T == 6) {
} else if (T == 6) {
cout << sqrt(6 * 6 + 9 * 9) << endl;
}
else if (T == 7) {
} else if (T == 7) {
cout << 110 << endl
<< 90 << endl
<< 0 << endl;
}
else if (T == 8) {
} else if (T == 8) {
cout << 3.141593 * 5 * 2 << endl
<< 3.141593 * 5 * 5 << endl
<< 4.0 / 3 * 3.141593 * 5 * 5 * 5 << endl;
}
else if (T == 9) {
} else if (T == 9) {
cout << 22 << endl;
}
else if (T == 10) {
} else if (T == 10) {
cout << 9 << endl;
}
else if (T == 11) {
} else if (T == 11) {
cout << 100.0 / (8 - 5) << endl;
}
else if (T == 12) {
} else if (T == 12) {
cout << 13 << endl
<< "R" << endl;
}
else if (T == 13) {
} else if (T == 13) {
cout << floor(pow((3.141593 * 4 * 4 * 4 * 4 / 3 + 3.141593 * 10 * 10 * 10 * 4 / 3), 1.0 / 3)) << endl;
}
else if (T == 14) {
} else if (T == 14) {
cout << 50 << endl;
}
return 0;

View File

@ -8,24 +8,23 @@ int n, win[7], lottery[7], sum[10], c;
int main() {
cin >> n;
for(int i = 0 ; i < 7 ; i++) {
for (int i = 0; i < 7; i++) {
cin >> win[i];
}
for(int i = 0 ; i < n ; i++) {
for (int i = 0; i < n; i++) {
c = 0;
for(int j = 0 ; j < 7 ; j++) {
for (int j = 0; j < 7; j++) {
cin >> lottery[j];
for(int p = 0 ; p < 7 ; p++) {
if(lottery[j] == win[p]) c++;
for (int p = 0; p < 7; p++) {
if (lottery[j] == win[p]) c++;
}
}
// cout << c << ' '; // debug
sum[c]++;
}
// cout << endl; // debug
for(int i = 7 ; i > 0 ; i--) {
for (int i = 7; i > 0; i--) {
cout << sum[i] << ' ';
}
return 0;
}

View File

@ -81,8 +81,7 @@ int main() {
cin >> op >> x >> y;
if (op == 0) {
modify(1, x, y);
}
else if (op == 1) {
} else if (op == 1) {
cout << query(1, x, y) << endl;
}
}

View File

@ -1,19 +1,19 @@
// R38819026
#include<bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, h[20005], b, sum=0, i;
int n, h[20005], b, sum = 0, i;
cin >> n >> b;
for(i = 0 ; i < n ; i++) {
for (i = 0; i < n; i++) {
cin >> h[i];
}
sort(h, h+n);
while(sum < b) {
sort(h, h + n);
while (sum < b) {
sum += h[--i];
}
cout << n-i << endl;
cout << n - i << endl;
return 0;
}

View File

@ -21,7 +21,7 @@ int main() {
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
a[n+1] = r;
a[n + 1] = r;
l = 1;
while (l <= r) {
mid = l + r >> 1;

View File

@ -1,4 +1,4 @@
#include<bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
@ -6,25 +6,22 @@ int main() {
int x1, y1, x2, y2, t, ans = 0;
char c;
cin >> x1 >> y1 >> x2 >> y2 >> t;
for(int i = 1 ; i <= t ; i++) {
for (int i = 1; i <= t; i++) {
cin >> c;
if(c == 'E' && y1 < y2) {
if (c == 'E' && y1 < y2) {
y1++;
ans++;
}
else if(c == 'W' && y1 > y2) {
} else if (c == 'W' && y1 > y2) {
y1--;
ans++;
}
else if(c == 'N' && x1 < x2) {
} else if (c == 'N' && x1 < x2) {
x1++;
ans++;
}
else if(c == 'S' && x1 > x2) {
} else if (c == 'S' && x1 > x2) {
x1--;
ans++;
}
if(x1 == x2 && y1 == y2) {
if (x1 == x2 && y1 == y2) {
cout << ans << endl;
return 0;
}

View File

@ -66,11 +66,11 @@ int query(int u, int l, int r) {
int main() {
cin >> n >> m;
build(1, 1, n);
for(int i = 0 ; i < m ; i++) {
for (int i = 0; i < m; i++) {
cin >> op >> s >> e;
if(op == 0) {
if (op == 0) {
modify(1, s, e);
} else if(op == 1) {
} else if (op == 1) {
cout << query(1, s, e) << endl;
}
}

View File

@ -8,14 +8,14 @@ int s1, s2, s3;
int main() {
scanf("%d%d%d", &s1, &s2, &s3);
if(s3 > s1 + s2) {
printf("%d", s1+s2+1);
} else if(s2 > s1 + s3) {
printf("%d", s1+s3+1);
} else if(s1 > s3 + s2) {
printf("%d", s3+s2+1);
if (s3 > s1 + s2) {
printf("%d", s1 + s2 + 1);
} else if (s2 > s1 + s3) {
printf("%d", s1 + s3 + 1);
} else if (s1 > s3 + s2) {
printf("%d", s3 + s2 + 1);
} else {
printf("%d", (s1+s2+s3+3)/2);
printf("%d", (s1 + s2 + s3 + 3) / 2);
}
return 0;
}

View File

@ -9,8 +9,7 @@ int main() {
cin >> t;
if (t % 2 == 0) {
cout << "pb wins" << endl;
}
else {
} else {
cout << "zs wins" << endl;
}
}

View File

@ -12,7 +12,7 @@ int main() {
}
for (int i = 0; i < m; i++) {
cin >> q;
cout << a[q-1] << endl;
cout << a[q - 1] << endl;
}
return 0;
}

View File

@ -1,4 +1,4 @@
#include<bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
@ -11,15 +11,14 @@ int find(int x) {
int main() {
int n, m, z, x, y;
cin >> n >> m;
for(int i = 0; i < n ; i++) {
for (int i = 0; i < n; i++) {
f[i] = i;
}
while(m--) {
while (m--) {
cin >> z >> x >> y;
if(z == 1) {
if (z == 1) {
f[find(x)] = find(y);
}
else {
} else {
cout << (find(x) == find(y) ? "Y" : "N") << endl;
}
}

View File

@ -81,8 +81,7 @@ int main() {
if (op == 1) {
scanf("%d%d", &y, &k);
modify(1, x, y, k);
}
else if (op == 2) {
} else if (op == 2) {
printf("%d\n", query(1, x, x));
}
}

View File

@ -10,20 +10,15 @@ int main() {
cin >> opt >> x;
if (opt == 1) {
a.insert(lower_bound(a.begin(), a.end(), x), x);
}
else if (opt == 2) {
} else if (opt == 2) {
a.erase(lower_bound(a.begin(), a.end(), x));
}
else if (opt == 3) {
} else if (opt == 3) {
cout << lower_bound(a.begin(), a.end(), x) - a.begin() + 1 << endl;
}
else if (opt == 4) {
} else if (opt == 4) {
cout << a[x - 1] << endl;
}
else if (opt == 5) {
} else if (opt == 5) {
cout << *(lower_bound(a.begin(), a.end(), x) - 1) << endl;
}
else if (opt == 6) {
} else if (opt == 6) {
cout << *upper_bound(a.begin(), a.end(), x) << endl;
}
}

View File

@ -111,8 +111,7 @@ int main() {
if (op == 1) {
cin >> k;
modify(1, x, y, k);
}
else if (op == 2) {
} else if (op == 2) {
cout << query(1, x, y) << endl;
}
}

View File

@ -118,12 +118,10 @@ signed main() {
if (op == 1) {
cin >> k;
modify(1, x, y, k, 0);
}
else if (op == 2) {
} else if (op == 2) {
cin >> k;
modify(1, x, y, 1, k);
}
else if (op == 3) {
} else if (op == 3) {
cout << query(1, x, y) % p << endl;
}
}

View File

@ -40,8 +40,7 @@ void change(int u, int x, int d) {
int mid = tr[u].l + tr[u].r >> 1;
if (x <= mid) {
change(u << 1, x, d);
}
else {
} else {
change(u << 1 | 1, x, d);
}
pushup(u);
@ -68,8 +67,7 @@ int main() {
cin >> op >> x >> y;
if (op == 1) {
change(1, x, y);
}
else if (op == 2) {
} else if (op == 2) {
cout << query(1, x, y) << endl;
}
}

View File

@ -1,4 +1,4 @@
#include<bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
@ -6,18 +6,16 @@ int main() {
priority_queue<int, vector<int>, greater<int> > q;
int n;
cin >> n;
while(n--) {
while (n--) {
int op;
cin >> op;
if(op == 1) {
if (op == 1) {
int x;
cin >> x;
q.push(x);
}
else if(op == 2) {
} else if (op == 2) {
cout << q.top() << endl;
}
else if(op == 3) {
} else if (op == 3) {
q.pop();
}
}

View File

@ -24,8 +24,7 @@ int main() {
mid2 = r - (r - l) / 3.0;
if (f(mid1) > f(mid2)) {
r = mid2;
}
else {
} else {
l = mid1;
}
}

View File

@ -1,4 +1,4 @@
#include<bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
@ -6,21 +6,21 @@ int main() {
map<int, map<int, int> > m;
int n, q, t, i, j, k;
cin >> n >> q;
while(q--) {
while (q--) {
cin >> t >> i >> j;
if(t == 1) {
if (t == 1) {
cin >> k;
if(k == 0) {
if(m.count(i) && m[i].count(j)) {
if (k == 0) {
if (m.count(i) && m[i].count(j)) {
m[i].erase(k);
if(m[i].empty()) {
if (m[i].empty()) {
m.erase(i);
}
}
} else {
m[i][j] = k;
}
} else if(t == 2) {
} else if (t == 2) {
cout << m[i][j] << endl;
}
}

View File

@ -17,9 +17,9 @@ int main() {
}
}
}
for(int i = 1 ; i <= n ; i++) {
for(int j = 1 ; j <= n ; j++) {
if(vis[i][j]) {
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
if (vis[i][j]) {
ans++;
}
}

View File

@ -23,8 +23,7 @@ int main() {
for (int i = 0; i < str.size(); i++) {
if (str[i] == 'V') {
str[i] = 'K';
}
else {
} else {
str[i] = 'V';
}
@ -35,8 +34,7 @@ int main() {
}
if (str[i] == 'V') {
str[i] = 'K';
}
else {
} else {
str[i] = 'V';
}
}

View File

@ -22,8 +22,10 @@ int main() {
}
while (l < r) {
int mid = l + r >> 1;
if (check(mid)) r = mid;
else l = mid + 1;
if (check(mid))
r = mid;
else
l = mid + 1;
}
cout << l << endl;
return 0;

View File

@ -1,24 +1,23 @@
#include<bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
int main() {
int n,m, t;
int n, m, t;
string op;
vector<int> nums;
cin >> n;
for(int i = 0 ; i < n ; i++) {
for (int i = 0; i < n; i++) {
cin >> t;
nums.insert(lower_bound(nums.begin(), nums.end(), t), t);
}
cin >> m;
for(int i = 0 ; i < m ; i++) {
for (int i = 0; i < m; i++) {
cin >> op;
if(op == "add") {
if (op == "add") {
cin >> t;
nums.insert(lower_bound(nums.begin(), nums.end(), t), t);
}
else {
} else {
cout << nums[nums.size() / 2 - (nums.size() & 1 ^ 1)] << endl;
}
}

View File

@ -19,8 +19,7 @@ int main() {
cin >> s;
if (!m.count(s)) {
cout << endl;
}
else {
} else {
for (set<int>::iterator it = m[s].begin(); it != --m[s].end(); it++) {
cout << *it << ' ';
}

View File

@ -5,13 +5,13 @@ using namespace std;
int main() {
int n;
cin >> n;
int s = n-1;
int s = n - 1;
bool prime[100000005];
memset(prime, 0, sizeof(prime));
for(int i = 2 ; i*i <= n ; i++) {
if(!prime[i]) {
for(int j = i*2 ; j <= n ; j+= i) {
if(!prime[j]) {
for (int i = 2; i * i <= n; i++) {
if (!prime[i]) {
for (int j = i * 2; j <= n; j += i) {
if (!prime[j]) {
prime[j] = true;
s--;
}

Some files were not shown because too many files have changed in this diff Show More