이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <fstream>
#define FIXED_FLOAT(x) std::fixed <<std::setprecision(10)<<(x)
#define all(v) (v).begin(), ( v).end()
using namespace std;
#define forn(i, b) for (int i=0; i<b; ++i)
using ll = long long;
const int mod = (ll)998244353;
#define PI acos(-1)
typedef pair<int , int> pairs;
typedef complex<ll> G;
const int INF = 1e9 + 1 ;
//const int N = 10;
const double eps = 1e-7;
int power(int a, int b){
if(!b)
return 1;
int c=power(a,b/2);
c=(1LL*c*c)%mod;
if(b%2)
c=(1LL*c*a)%mod;
return c;
}
int mul(int a, int b) {
return (ll)a * b % mod;
}
struct Seg {
int n;
vector<int>s;
Seg(const vector<int>& a) {
this->n = a.size();
s.resize(4 * n);
function<void(int, int, int)> build = [&](int p, int l, int r) {
if(r - l == 1) {
s[p] = a[l];
return;
}
int m = (l + r) / 2;
build(2 * p, l, m);
build(2 * p + 1, m, r);
pull(p);
};
build(1, 0, n);
}
void pull(int p) {
s[p] = __gcd(s[2 * p], s[2 * p + 1]);
}
void range_g(int p, int l, int r, int il, int ir, int &ans) {
if(l >= ir || r <= il)return;
if(l >= il && r <= ir) {
ans = __gcd(ans, s[p]);
return;
}
int m = (l + r) / 2;
range_g(2 * p, l, m, il, ir, ans);
range_g(2 * p + 1, m, r, il, ir, ans);
}
int get_ans(int l, int r) {
int ans = 0;
range_g(1, 0, n, l, r, ans);
return ans;
}
};
void done() {
int n, sub;
cin >> n >> sub;
vector<int>a(n);
for(int i = 0;i < n;++i) {
cin >> a[i];
}
Seg S(a);
ll ans = 0;
for(int i = 0;i <= n - sub;++i) {
ans += S.get_ans(i, i + sub);
}
cout << ans << '\n';
}
void solve()
{
int d, k;
cin >> d >> k;
auto ch = [&](int x, int y) {
return ((ll)x * x + (ll)y * y <= (ll)d * d);
};
int x = 0;
int y = 0;
int st = 0;
}
void another() {
ll ans = 0;
int n, w;
cin >> n >> w;
vector<string>s(n);
forn(i, n)cin >> s[i];
vector<vector<int>> down(n, vector<int>(w, 0));
vector<vector<int>> le(n, vector<int>(w, 0));
for(int j = 0;j < w;++j) {
for(int i = n - 1;i >= 0;--i) {
if(s[i][j] == 'I')down[i][j]++;
if(i != n - 1)down[i][j] += down[i + 1][j];
}
}
for(int i = 0;i < n;++i) {
for(int j = w - 1;j >= 0;--j) {
if(s[i][j] == 'O')le[i][j]++;
if(j != w - 1)le[i][j] += le[i][j + 1];
}
}
forn(i, n) forn(j, w) {
if(s[i][j] == 'J') {
ans += down[i][j] * le[i][j];
}
}
cout << ans << '\n';
}
void test_case() {
int t;
cin >> t;
while(t--)done();
}
int main() {
ios::sync_with_stdio(NULL); cin.tie(0); cout.tie(0);
another();
}
컴파일 시 표준 에러 (stderr) 메시지
joi2019_ho_t1.cpp: In function 'void solve()':
joi2019_ho_t1.cpp:106:10: warning: variable 'ch' set but not used [-Wunused-but-set-variable]
106 | auto ch = [&](int x, int y) {
| ^~
joi2019_ho_t1.cpp:109:9: warning: unused variable 'x' [-Wunused-variable]
109 | int x = 0;
| ^
joi2019_ho_t1.cpp:110:9: warning: unused variable 'y' [-Wunused-variable]
110 | int y = 0;
| ^
joi2019_ho_t1.cpp:111:9: warning: unused variable 'st' [-Wunused-variable]
111 | int st = 0;
| ^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |