Submission #1324341

#TimeUsernameProblemLanguageResultExecution timeMemory
1324341quollcucumber`Cell Automaton (JOI23_cell)C++20
4 / 100
1004 ms9480 KiB
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
    int n, q;
    cin >> n >> q;
    int t[1005];
    t[0] = n;
    map<pair<int, int>, int> arr;
    for(int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        arr[{x, y}] = 2;
    }
    int total = n;
    for(int i = 1; i < 55; i++) {
        map<pair<int, int>, int> newarr;
        for(int j = -105; j < 105; j++) {
            for(int k = -105; k < 105; k++) {
                if(j == 0 && k == 0) {
                    int a = 0;
                }
                if(arr[{j, k}] == 0) {
                   if(arr[{j+1, k}] == 2 || arr[{j-1, k}] == 2 || arr[{j, k+1}] == 2 || arr[{j, k-1}] ==2) {
                       newarr[{j, k}] = 2;
                       total++;
                   }
                }else if(arr[{j, k}] == 1) {
                    newarr[{j,k}] = 0;
                }else {
                    newarr[{j,k}] = 1;
                    total--;
                }
            }
        }
        arr = newarr;
        t[i] = total;
    }
    for(int i = 0; i < q; i++) {
        int a;
        cin >> a;
        cout<<t[a]<<'\n';
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...