Submission #857425

# Submission time Handle Problem Language Result Execution time Memory
857425 2023-10-06T07:43:48 Z lbadea1000 Squirrel (RMI18_squirrel) C++17
25 / 100
4700 ms 600 KB
#include <bits/stdc++.h>

using namespace std;

int ldir[8] = {-1, -1, 0, 1, 1,  1,  0, -1};
int cdir[8] = { 0,  1, 1, 1, 0, -1, -1, -1};

int ans;


bool gcd(int a, int b) {
//    cout << a + 1 << ' ' << b + 1 << endl;
    return (__gcd(a, b) == 1);
}

void generateFractal(int l, int c, int dir, int size) {
    if(size == 0)
        return;
    //cout << "tree : " << endl;
    for(int i = 0; i < size; i++) {
        l += ldir[dir];
        c += cdir[dir];
        ans += gcd(l, c);
    }
    //cout << endl;
    int dir1 = (dir - 1 + 8) % 8, dir2 = (dir + 1) % 8;
    int l1 = l, c1 = c;
    //cout << dir1 << " Branch 1 : " << endl;
    for(int i = 0; i < size / 2; i++) {
        l1 += ldir[dir1];
        c1 += cdir[dir1];
        ans += gcd(l1, c1);
    }
//    cout << dir2 << " Branch 2 : " << endl;
    int l2 = l, c2 = c;
    for(int i = 0; i < size / 2; i++) {
        l2 += ldir[dir2];
        c2 += cdir[dir2];
        ans += gcd(l2, c2);
    }
//    cout << endl << endl;
    generateFractal(l1, c1, (dir1 - 1 + 8) % 8, size / 2);
    generateFractal(l1, c1, (dir1 + 1 + 8) % 8, size / 2);
    generateFractal(l2, c2, (dir2 - 1 + 8) % 8, size / 2);
    generateFractal(l2, c2, (dir2 + 1 + 8) % 8, size / 2);
}

int main() {
    int m, n, f;
    cin >> m >> n >> f;
    ans = 0;
    for(int i = 0; i < f; i++) {
        int l, c, size;
        cin >> l >> c >> size;
        l--;
        c--;
        ans += gcd(l, c);
        generateFractal(l, c, 0, size);
    }
    cout << ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 44 ms 348 KB Output is correct
2 Correct 93 ms 408 KB Output is correct
3 Correct 2110 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3582 ms 408 KB Output is correct
2 Correct 3471 ms 404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 4725 ms 344 KB Time limit exceeded
2 Execution timed out 4753 ms 348 KB Time limit exceeded
3 Execution timed out 4792 ms 344 KB Time limit exceeded
4 Execution timed out 4764 ms 344 KB Time limit exceeded
5 Execution timed out 4706 ms 344 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 4783 ms 600 KB Time limit exceeded
2 Execution timed out 4730 ms 344 KB Time limit exceeded
3 Execution timed out 4735 ms 344 KB Time limit exceeded
4 Execution timed out 4731 ms 344 KB Time limit exceeded
5 Execution timed out 4753 ms 348 KB Time limit exceeded
6 Execution timed out 4725 ms 348 KB Time limit exceeded
7 Execution timed out 4744 ms 348 KB Time limit exceeded
8 Execution timed out 4726 ms 344 KB Time limit exceeded
9 Execution timed out 4702 ms 344 KB Time limit exceeded
10 Execution timed out 4744 ms 348 KB Time limit exceeded