답안 #330072

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
330072 2020-11-23T16:45:22 Z Karliver Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
382 ms 89708 KB

#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();
}

Compilation message

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;
      |         ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 492 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 492 KB Output is correct
8 Correct 1 ms 400 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
11 Correct 1 ms 492 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 492 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 492 KB Output is correct
8 Correct 1 ms 400 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
11 Correct 1 ms 492 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 492 KB Output is correct
14 Correct 6 ms 2284 KB Output is correct
15 Correct 1 ms 488 KB Output is correct
16 Correct 3 ms 1644 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 10 ms 2796 KB Output is correct
19 Correct 5 ms 2796 KB Output is correct
20 Correct 5 ms 2796 KB Output is correct
21 Correct 8 ms 2816 KB Output is correct
22 Correct 5 ms 2796 KB Output is correct
23 Correct 5 ms 2796 KB Output is correct
24 Correct 8 ms 2796 KB Output is correct
25 Correct 6 ms 2796 KB Output is correct
26 Correct 5 ms 2796 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 492 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 492 KB Output is correct
8 Correct 1 ms 400 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
11 Correct 1 ms 492 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 492 KB Output is correct
14 Correct 6 ms 2284 KB Output is correct
15 Correct 1 ms 488 KB Output is correct
16 Correct 3 ms 1644 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 10 ms 2796 KB Output is correct
19 Correct 5 ms 2796 KB Output is correct
20 Correct 5 ms 2796 KB Output is correct
21 Correct 8 ms 2816 KB Output is correct
22 Correct 5 ms 2796 KB Output is correct
23 Correct 5 ms 2796 KB Output is correct
24 Correct 8 ms 2796 KB Output is correct
25 Correct 6 ms 2796 KB Output is correct
26 Correct 5 ms 2796 KB Output is correct
27 Correct 349 ms 84844 KB Output is correct
28 Correct 2 ms 876 KB Output is correct
29 Correct 13 ms 6764 KB Output is correct
30 Correct 1 ms 620 KB Output is correct
31 Correct 248 ms 62316 KB Output is correct
32 Correct 311 ms 89068 KB Output is correct
33 Correct 303 ms 89452 KB Output is correct
34 Correct 299 ms 72300 KB Output is correct
35 Correct 311 ms 89196 KB Output is correct
36 Correct 309 ms 89544 KB Output is correct
37 Correct 382 ms 89708 KB Output is correct
38 Correct 212 ms 61884 KB Output is correct
39 Correct 202 ms 62060 KB Output is correct