Submission #1031664

# Submission time Handle Problem Language Result Execution time Memory
1031664 2024-07-23T03:26:15 Z vjudge1 Mars (APIO22_mars) C++17
14 / 100
12 ms 3104 KB
#include "mars.h"
#include<bits/stdc++.h>
using namespace std;
bitset<29> grid[29];
void flod(int i,int j){
    if(i<0||i>8||j<0||j>8)return;
    if(!grid[i][j]) return;
    grid[i][j]=0;
    flod(i-1,j);
    flod(i+1,j);
    flod(i,j+1);
    flod(i,j-1);
}
string howmanyislands(int n){
    int ans=0;
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            ans+=grid[i][j],flod(i,j);
    string str;
    for(int i=0;i<100;i++)
        str+=48+(ans&1),ans>>=1;
    return str;
}
int turn[42][42];
string encode_grid(int i,int j){
    string str;
    for(int I=0;I<10;I++)
        for(int J=0;J<10;J++)
            str+=48+grid[i+I][j+J];
    return str;
}
void putintogrid(string a,int i,int j){
    int CC=0;
    for(int I=0;I<10;I++) for(int J=0;J<10;J++)
        grid[i+I][j+J]=grid[i+I][j+J]|a[CC++]=='1';
}
std::string process(std::vector <std::vector<std::string>> a, int i, int j, int k, int n) {
    for(int i=0;i<2*n+1;i++)
        grid[i].reset();
    if(i&1||j&1) return a[0][0];
    if(max(i,j)==2*n-2*k-2) {
        grid[i][j]=a[0][0][0]=='1';
        grid[i+1][j]=a[1][0][0]=='1';
        grid[i][j+1]=a[0][1][0]=='1';
        grid[i+1][j+1]=a[1][1][0]=='1';
        grid[i+2][j+1]=a[2][1][0]=='1';
        grid[i+1][j+2]=a[1][2][0]=='1';
        putintogrid(a[2][0],i+2,j);
        putintogrid(a[2][2],i+2,j+2);
        putintogrid(a[0][2],i,j+2);
    } else return a[0][0];
    if(k==n-1)
        return howmanyislands(2*n+1);
    return encode_grid(i,j);
}

Compilation message

mars.cpp: In function 'void putintogrid(std::string, int, int)':
mars.cpp:35:46: warning: suggest parentheses around comparison in operand of '|' [-Wparentheses]
   35 |         grid[i+I][j+J]=grid[i+I][j+J]|a[CC++]=='1';
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2852 KB Output is correct
2 Correct 2 ms 2748 KB Output is correct
3 Correct 4 ms 2832 KB Output is correct
4 Correct 4 ms 2744 KB Output is correct
5 Correct 5 ms 2760 KB Output is correct
6 Correct 5 ms 2984 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2852 KB Output is correct
2 Correct 2 ms 2748 KB Output is correct
3 Correct 4 ms 2832 KB Output is correct
4 Correct 4 ms 2744 KB Output is correct
5 Correct 5 ms 2760 KB Output is correct
6 Correct 5 ms 2984 KB Output is correct
7 Correct 8 ms 3016 KB Output is correct
8 Correct 10 ms 2840 KB Output is correct
9 Correct 12 ms 2836 KB Output is correct
10 Correct 8 ms 2744 KB Output is correct
11 Correct 10 ms 2848 KB Output is correct
12 Correct 8 ms 3104 KB Output is correct
13 Correct 8 ms 2840 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2852 KB Output is correct
2 Correct 2 ms 2748 KB Output is correct
3 Correct 4 ms 2832 KB Output is correct
4 Correct 4 ms 2744 KB Output is correct
5 Correct 5 ms 2760 KB Output is correct
6 Correct 5 ms 2984 KB Output is correct
7 Correct 8 ms 3016 KB Output is correct
8 Correct 10 ms 2840 KB Output is correct
9 Correct 12 ms 2836 KB Output is correct
10 Correct 8 ms 2744 KB Output is correct
11 Correct 10 ms 2848 KB Output is correct
12 Correct 8 ms 3104 KB Output is correct
13 Correct 8 ms 2840 KB Output is correct
14 Incorrect 2 ms 332 KB Incorrect
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2852 KB Output is correct
2 Correct 2 ms 2748 KB Output is correct
3 Correct 4 ms 2832 KB Output is correct
4 Correct 4 ms 2744 KB Output is correct
5 Correct 5 ms 2760 KB Output is correct
6 Correct 5 ms 2984 KB Output is correct
7 Correct 8 ms 3016 KB Output is correct
8 Correct 10 ms 2840 KB Output is correct
9 Correct 12 ms 2836 KB Output is correct
10 Correct 8 ms 2744 KB Output is correct
11 Correct 10 ms 2848 KB Output is correct
12 Correct 8 ms 3104 KB Output is correct
13 Correct 8 ms 2840 KB Output is correct
14 Incorrect 2 ms 332 KB Incorrect
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2852 KB Output is correct
2 Correct 2 ms 2748 KB Output is correct
3 Correct 4 ms 2832 KB Output is correct
4 Correct 4 ms 2744 KB Output is correct
5 Correct 5 ms 2760 KB Output is correct
6 Correct 5 ms 2984 KB Output is correct
7 Correct 8 ms 3016 KB Output is correct
8 Correct 10 ms 2840 KB Output is correct
9 Correct 12 ms 2836 KB Output is correct
10 Correct 8 ms 2744 KB Output is correct
11 Correct 10 ms 2848 KB Output is correct
12 Correct 8 ms 3104 KB Output is correct
13 Correct 8 ms 2840 KB Output is correct
14 Incorrect 2 ms 332 KB Incorrect
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2852 KB Output is correct
2 Correct 2 ms 2748 KB Output is correct
3 Correct 4 ms 2832 KB Output is correct
4 Correct 4 ms 2744 KB Output is correct
5 Correct 5 ms 2760 KB Output is correct
6 Correct 5 ms 2984 KB Output is correct
7 Correct 8 ms 3016 KB Output is correct
8 Correct 10 ms 2840 KB Output is correct
9 Correct 12 ms 2836 KB Output is correct
10 Correct 8 ms 2744 KB Output is correct
11 Correct 10 ms 2848 KB Output is correct
12 Correct 8 ms 3104 KB Output is correct
13 Correct 8 ms 2840 KB Output is correct
14 Incorrect 2 ms 332 KB Incorrect
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2852 KB Output is correct
2 Correct 2 ms 2748 KB Output is correct
3 Correct 4 ms 2832 KB Output is correct
4 Correct 4 ms 2744 KB Output is correct
5 Correct 5 ms 2760 KB Output is correct
6 Correct 5 ms 2984 KB Output is correct
7 Correct 8 ms 3016 KB Output is correct
8 Correct 10 ms 2840 KB Output is correct
9 Correct 12 ms 2836 KB Output is correct
10 Correct 8 ms 2744 KB Output is correct
11 Correct 10 ms 2848 KB Output is correct
12 Correct 8 ms 3104 KB Output is correct
13 Correct 8 ms 2840 KB Output is correct
14 Incorrect 2 ms 332 KB Incorrect
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2852 KB Output is correct
2 Correct 2 ms 2748 KB Output is correct
3 Correct 4 ms 2832 KB Output is correct
4 Correct 4 ms 2744 KB Output is correct
5 Correct 5 ms 2760 KB Output is correct
6 Correct 5 ms 2984 KB Output is correct
7 Correct 8 ms 3016 KB Output is correct
8 Correct 10 ms 2840 KB Output is correct
9 Correct 12 ms 2836 KB Output is correct
10 Correct 8 ms 2744 KB Output is correct
11 Correct 10 ms 2848 KB Output is correct
12 Correct 8 ms 3104 KB Output is correct
13 Correct 8 ms 2840 KB Output is correct
14 Incorrect 2 ms 332 KB Incorrect
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2852 KB Output is correct
2 Correct 2 ms 2748 KB Output is correct
3 Correct 4 ms 2832 KB Output is correct
4 Correct 4 ms 2744 KB Output is correct
5 Correct 5 ms 2760 KB Output is correct
6 Correct 5 ms 2984 KB Output is correct
7 Correct 8 ms 3016 KB Output is correct
8 Correct 10 ms 2840 KB Output is correct
9 Correct 12 ms 2836 KB Output is correct
10 Correct 8 ms 2744 KB Output is correct
11 Correct 10 ms 2848 KB Output is correct
12 Correct 8 ms 3104 KB Output is correct
13 Correct 8 ms 2840 KB Output is correct
14 Incorrect 2 ms 332 KB Incorrect
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2852 KB Output is correct
2 Correct 2 ms 2748 KB Output is correct
3 Correct 4 ms 2832 KB Output is correct
4 Correct 4 ms 2744 KB Output is correct
5 Correct 5 ms 2760 KB Output is correct
6 Correct 5 ms 2984 KB Output is correct
7 Correct 8 ms 3016 KB Output is correct
8 Correct 10 ms 2840 KB Output is correct
9 Correct 12 ms 2836 KB Output is correct
10 Correct 8 ms 2744 KB Output is correct
11 Correct 10 ms 2848 KB Output is correct
12 Correct 8 ms 3104 KB Output is correct
13 Correct 8 ms 2840 KB Output is correct
14 Incorrect 2 ms 332 KB Incorrect
15 Halted 0 ms 0 KB -