AC 250, tried atcoder virtual contest, wasn't even half bad
This commit is contained in:
36
atcoder/beginner_contests/250/a.cpp
Normal file
36
atcoder/beginner_contests/250/a.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
int main(){
|
||||
ios::sync_with_stdio(0);
|
||||
cin.tie(0);
|
||||
|
||||
int h, w, r, c;
|
||||
|
||||
cin >> h >> w >> r >> c;
|
||||
|
||||
int result = 0;
|
||||
if(h > 1){
|
||||
result++;
|
||||
}
|
||||
|
||||
if(w > 1){
|
||||
result++;
|
||||
}
|
||||
|
||||
if(r != 1 && r != h){
|
||||
result++;
|
||||
}
|
||||
|
||||
if(c != 1 && c != w){
|
||||
result++;
|
||||
}
|
||||
|
||||
cout << result;
|
||||
|
||||
cout << flush;
|
||||
|
||||
return 0;
|
||||
}
|
||||
34
atcoder/beginner_contests/250/b.cpp
Normal file
34
atcoder/beginner_contests/250/b.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
int main(){
|
||||
ios::sync_with_stdio(0);
|
||||
cin.tie(0);
|
||||
|
||||
int n, a, b;
|
||||
cin >> n >> a >> b;
|
||||
|
||||
bool color = true;
|
||||
|
||||
for(int vertical_tiles = 0; vertical_tiles < n; ++vertical_tiles){
|
||||
for(int vertical_length = 0; vertical_length < a; ++vertical_length){
|
||||
for(int horizontal_tiles = 0; horizontal_tiles < n; ++horizontal_tiles){
|
||||
for(int horizontal_length = 0; horizontal_length < b; ++horizontal_length){
|
||||
cout << (color ? "." : "#");
|
||||
}
|
||||
color = !color;
|
||||
}
|
||||
cout << '\n';
|
||||
if(n % 2 != 0){
|
||||
color = !color;
|
||||
}
|
||||
}
|
||||
color = !color;
|
||||
}
|
||||
|
||||
cout << flush;
|
||||
|
||||
return 0;
|
||||
}
|
||||
51
atcoder/beginner_contests/250/c.cpp
Normal file
51
atcoder/beginner_contests/250/c.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(){
|
||||
ios::sync_with_stdio(0);
|
||||
cin.tie(0);
|
||||
|
||||
int n, q;
|
||||
cin >> n >> q;
|
||||
|
||||
// Denoting what ball is on the ith position
|
||||
vector<int> numberBall(n);
|
||||
// Denoting where the ith ball is
|
||||
vector<int> ballPosition(n);
|
||||
|
||||
for(int i = 0; i < n; ++i){
|
||||
numberBall[i] = i;
|
||||
ballPosition[i] = i;
|
||||
}
|
||||
|
||||
for(int j = 0; j < q; ++j){
|
||||
int xq;
|
||||
cin >> xq;
|
||||
xq--;
|
||||
|
||||
int x_pos = ballPosition[xq], y_pos, yq;
|
||||
|
||||
if(x_pos != n - 1){
|
||||
y_pos = x_pos + 1;
|
||||
yq = numberBall[y_pos];
|
||||
|
||||
swap(numberBall[x_pos], numberBall[y_pos]);
|
||||
swap(ballPosition[xq], ballPosition[yq]);
|
||||
} else{
|
||||
y_pos = x_pos - 1;
|
||||
yq = numberBall[y_pos];
|
||||
|
||||
swap(numberBall[x_pos], numberBall[y_pos]);
|
||||
swap(ballPosition[xq], ballPosition[yq]);
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < n; ++i){
|
||||
cout << numberBall[i] + 1 << " ";
|
||||
} cout << endl;
|
||||
|
||||
cout << flush;
|
||||
|
||||
return 0;
|
||||
}
|
||||
66
atcoder/beginner_contests/250/d.cpp
Normal file
66
atcoder/beginner_contests/250/d.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
typedef unsigned long long ull;
|
||||
|
||||
vector<ull> primes(ull maxPrime){
|
||||
vector<bool> p(maxPrime + 1, true);
|
||||
|
||||
for(ull i = 2; i <= sqrt(maxPrime + 1); ++i){
|
||||
if(p[i]){
|
||||
for(ull j = i * 2; j < maxPrime + 1; j += i){
|
||||
p[j] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vector<ull> result;
|
||||
for(ull i = 2; i < maxPrime + 1; ++i){
|
||||
if(p[i]){
|
||||
result.push_back(i);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
int main(){
|
||||
ios::sync_with_stdio(0);
|
||||
cin.tie(0);
|
||||
|
||||
ull n;
|
||||
cin >> n;
|
||||
|
||||
ull topPrime = ceil(cbrt(ceil(n / 2)));
|
||||
auto ps = primes(topPrime);
|
||||
|
||||
ull result = 0;
|
||||
|
||||
if(ps.size() < 2){
|
||||
cout << result << endl;
|
||||
cout << flush;
|
||||
return 0;
|
||||
}
|
||||
|
||||
for(size_t i = 1; i < ps.size(); ++i){
|
||||
ull q = ps[i];
|
||||
|
||||
for(size_t j = 0; j < i; ++j){
|
||||
ull p = ps[j];
|
||||
ull k = p * q * q * q;
|
||||
|
||||
if(k > n){
|
||||
break;
|
||||
}
|
||||
result++;
|
||||
}
|
||||
}
|
||||
|
||||
cout << result << endl;
|
||||
|
||||
cout << flush;
|
||||
|
||||
return 0;
|
||||
}
|
||||
36
atcoder/beginner_contests/250/e.cpp
Normal file
36
atcoder/beginner_contests/250/e.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
int main(){
|
||||
ios::sync_with_stdio(0);
|
||||
cin.tie(0);
|
||||
|
||||
int n, q;
|
||||
cin >> n;
|
||||
|
||||
vector<int> a(n), b(n);
|
||||
|
||||
for(int i = 0; i < n; ++i){
|
||||
cin >> a[i];
|
||||
}
|
||||
for(int i = 0; i < n; ++i){
|
||||
cin >> b[i];
|
||||
}
|
||||
|
||||
cin >> q;
|
||||
for(int j = 0; j < q; ++j){
|
||||
int x, y;
|
||||
cin >> x >> y;
|
||||
|
||||
set<int> a_set(a.begin(), a.begin() + x);
|
||||
set<int> b_set(b.begin(), b.begin() + y);
|
||||
|
||||
cout << (a_set == b_set ? "Yes" : "No") << '\n';
|
||||
}
|
||||
|
||||
cout << flush;
|
||||
|
||||
return 0;
|
||||
}
|
||||
25
atcoder/beginner_contests/250/ex.cpp
Normal file
25
atcoder/beginner_contests/250/ex.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
void test_case(int tc){
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
ios::sync_with_stdio(0);
|
||||
cin.tie(0);
|
||||
|
||||
int t;
|
||||
cin >> t;
|
||||
|
||||
for(int tc = 1; tc <= t; ++tc){
|
||||
test_case(tc);
|
||||
}
|
||||
|
||||
cout << flush;
|
||||
|
||||
return 0;
|
||||
}
|
||||
25
atcoder/beginner_contests/250/f.cpp
Normal file
25
atcoder/beginner_contests/250/f.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
void test_case(int tc){
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
ios::sync_with_stdio(0);
|
||||
cin.tie(0);
|
||||
|
||||
int t;
|
||||
cin >> t;
|
||||
|
||||
for(int tc = 1; tc <= t; ++tc){
|
||||
test_case(tc);
|
||||
}
|
||||
|
||||
cout << flush;
|
||||
|
||||
return 0;
|
||||
}
|
||||
25
atcoder/beginner_contests/250/g.cpp
Normal file
25
atcoder/beginner_contests/250/g.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
void test_case(int tc){
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
ios::sync_with_stdio(0);
|
||||
cin.tie(0);
|
||||
|
||||
int t;
|
||||
cin >> t;
|
||||
|
||||
for(int tc = 1; tc <= t; ++tc){
|
||||
test_case(tc);
|
||||
}
|
||||
|
||||
cout << flush;
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user