# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
731591 | 2023-04-27T15:19:47 Z | ogibogi2004 | 화성 (APIO22_mars) | C++17 | 255 ms | 3172 KB |
#include "mars.h" #include<bits/stdc++.h> using namespace std; vector<vector<bool> > read_string(string s,int k) { //it should have k+2 * k+2 //i,j in (k+2)*i+j vector<vector<bool> >ret; for(int i=0;i<k+1;i++) { ret.push_back({}); for(int j=0;j<k+1;j++) { ret[i].push_back(s[(k+1)*i+j]); } } //cout<<"?\n"; for(int i=0;i<(k+1)*(k+1);i++) { int x=i/(k+1); int y=i%(k+1); //cout<<x<<" "<<y<<endl; ret[x][y]=s[i]-'0'; } return ret; } string encode(vector<vector<bool> >v) { string ret=""; int t=v.size()/2+1; for(int i=0;i<t*t;i++)ret+="0"; for(int i=0;i<v.size();i+=2) { for(int j=0;j<v.size();j+=2) { ret[(i/2)*t+j/2]=v[i][j]+'0'; } } while(ret.size()<100)ret+="0"; return ret; } bool vis[64][64]; vector<vector<bool> >matrix; void dfs(int x,int y) { vis[x][y]=1; if(x>0&&vis[x-1][y]==0&&matrix[x-1][y]==1)dfs(x-1,y); if(y>0&&vis[x][y-1]==0&&matrix[x][y-1]==1)dfs(x,y-1); if(x+1<matrix.size()&&vis[x+1][y]==0&&matrix[x+1][y]==1)dfs(x+1,y); if(y+1<matrix.size()&&vis[x][y+1]==0&&matrix[x][y+1]==1)dfs(x,y+1); } string get_num_islands(vector<vector<bool> >v) { /*cout<<"--------------\n"; for(auto xd:v) { for(auto dx:xd)cout<<dx<<" "; cout<<endl; } cout<<"--------------\n";*/ int cnt=0; memset(vis,0,sizeof(vis)); matrix=v; for(int i=0;i<v.size();i++) { for(int j=0;j<v[i].size();j++) { if(vis[i][j]==0&&v[i][j]==1) { dfs(i,j); cnt++; } } } string bin=""; //cout<<cnt<<endl; while(cnt) { bin+=char(cnt%2+'0'); cnt/=2; } //reverse(bin.begin(),bin.end()); while(bin.size()<100)bin+="0"; return bin; } void print(vector<vector<bool> >v) { cout<<"--------------\n"; for(auto xd:v) { for(auto dx:xd)cout<<dx<<" "; cout<<endl; } cout<<"--------------\n"; } string process(vector <vector<string>> a, int i, int j, int k, int n) { //cout<<i<<" "<<j<<" "<<k<<endl; if(k<n-1) { vector<vector<bool> >actual_table; for(int it1=0;it1<2*k+3;it1++) { actual_table.push_back({}); for(int it2=0;it2<2*k+3;it2++) { actual_table[it1].push_back(0); } } for(int i1=0;i1<3;i1++) { for(int i2=0;i2<3;i2++) { vector<vector<bool> >subtable = read_string(a[i1][i2],k); for(int dx=0;dx<subtable.size()&&i1+dx*2<actual_table.size();dx++) { for(int dy=0;dy<subtable[dx].size()&&i2+dy*2<actual_table.size();dy++) { actual_table[i1+dx*2][i2+dy*2]=max(actual_table[i1+dx*2][i2+dy*2],subtable[dx][dy]); } } } } //cout<<"returned "<<i<<" "<<j<<" "<<k<<" "<<encode(actual_table)<<endl; //print(actual_table); return encode(actual_table); } else { vector<vector<bool> >actual_table; for(int it1=0;it1<2*k+3;it1++) { actual_table.push_back({}); for(int it2=0;it2<2*k+3;it2++) { actual_table[it1].push_back(0); } } //cout<<"*1\n"; for(int i1=0;i1<3;i1++) { for(int i2=0;i2<3;i2++) { //cout<<i1<<" "<<i2<<endl; vector<vector<bool> >subtable = read_string(a[i1][i2],k); //print(subtable); //cout<<"alo\n"; for(int dx=0;dx<subtable.size()&&i1+dx*2<actual_table.size();dx++) { for(int dy=0;dy<subtable[dx].size()&&i2+dy*2<actual_table.size();dy++) { //cout<<i1+dx*2<<" "<<i2+dy*2<<endl; actual_table[i1+dx*2][i2+dy*2]=max(actual_table[i1+dx*2][i2+dy*2],subtable[dx][dy]); } } } } //cout<<"*2\n"; return get_num_islands(actual_table); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 1952 KB | Output is correct |
2 | Correct | 8 ms | 2156 KB | Output is correct |
3 | Correct | 8 ms | 1716 KB | Output is correct |
4 | Correct | 8 ms | 1988 KB | Output is correct |
5 | Correct | 8 ms | 2092 KB | Output is correct |
6 | Correct | 8 ms | 2096 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 1952 KB | Output is correct |
2 | Correct | 8 ms | 2156 KB | Output is correct |
3 | Correct | 8 ms | 1716 KB | Output is correct |
4 | Correct | 8 ms | 1988 KB | Output is correct |
5 | Correct | 8 ms | 2092 KB | Output is correct |
6 | Correct | 8 ms | 2096 KB | Output is correct |
7 | Correct | 13 ms | 2076 KB | Output is correct |
8 | Correct | 19 ms | 2148 KB | Output is correct |
9 | Correct | 18 ms | 2148 KB | Output is correct |
10 | Correct | 17 ms | 2128 KB | Output is correct |
11 | Correct | 19 ms | 1968 KB | Output is correct |
12 | Correct | 16 ms | 2124 KB | Output is correct |
13 | Correct | 18 ms | 2164 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 1952 KB | Output is correct |
2 | Correct | 8 ms | 2156 KB | Output is correct |
3 | Correct | 8 ms | 1716 KB | Output is correct |
4 | Correct | 8 ms | 1988 KB | Output is correct |
5 | Correct | 8 ms | 2092 KB | Output is correct |
6 | Correct | 8 ms | 2096 KB | Output is correct |
7 | Correct | 13 ms | 2076 KB | Output is correct |
8 | Correct | 19 ms | 2148 KB | Output is correct |
9 | Correct | 18 ms | 2148 KB | Output is correct |
10 | Correct | 17 ms | 2128 KB | Output is correct |
11 | Correct | 19 ms | 1968 KB | Output is correct |
12 | Correct | 16 ms | 2124 KB | Output is correct |
13 | Correct | 18 ms | 2164 KB | Output is correct |
14 | Correct | 34 ms | 2460 KB | Output is correct |
15 | Correct | 54 ms | 2568 KB | Output is correct |
16 | Correct | 53 ms | 2576 KB | Output is correct |
17 | Correct | 56 ms | 2572 KB | Output is correct |
18 | Correct | 47 ms | 2472 KB | Output is correct |
19 | Correct | 48 ms | 2568 KB | Output is correct |
20 | Correct | 52 ms | 2572 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 1952 KB | Output is correct |
2 | Correct | 8 ms | 2156 KB | Output is correct |
3 | Correct | 8 ms | 1716 KB | Output is correct |
4 | Correct | 8 ms | 1988 KB | Output is correct |
5 | Correct | 8 ms | 2092 KB | Output is correct |
6 | Correct | 8 ms | 2096 KB | Output is correct |
7 | Correct | 13 ms | 2076 KB | Output is correct |
8 | Correct | 19 ms | 2148 KB | Output is correct |
9 | Correct | 18 ms | 2148 KB | Output is correct |
10 | Correct | 17 ms | 2128 KB | Output is correct |
11 | Correct | 19 ms | 1968 KB | Output is correct |
12 | Correct | 16 ms | 2124 KB | Output is correct |
13 | Correct | 18 ms | 2164 KB | Output is correct |
14 | Correct | 34 ms | 2460 KB | Output is correct |
15 | Correct | 54 ms | 2568 KB | Output is correct |
16 | Correct | 53 ms | 2576 KB | Output is correct |
17 | Correct | 56 ms | 2572 KB | Output is correct |
18 | Correct | 47 ms | 2472 KB | Output is correct |
19 | Correct | 48 ms | 2568 KB | Output is correct |
20 | Correct | 52 ms | 2572 KB | Output is correct |
21 | Correct | 82 ms | 2640 KB | Output is correct |
22 | Correct | 125 ms | 2736 KB | Output is correct |
23 | Correct | 128 ms | 2728 KB | Output is correct |
24 | Correct | 136 ms | 2748 KB | Output is correct |
25 | Correct | 126 ms | 2864 KB | Output is correct |
26 | Correct | 131 ms | 2896 KB | Output is correct |
27 | Correct | 121 ms | 2760 KB | Output is correct |
28 | Correct | 131 ms | 2620 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 1952 KB | Output is correct |
2 | Correct | 8 ms | 2156 KB | Output is correct |
3 | Correct | 8 ms | 1716 KB | Output is correct |
4 | Correct | 8 ms | 1988 KB | Output is correct |
5 | Correct | 8 ms | 2092 KB | Output is correct |
6 | Correct | 8 ms | 2096 KB | Output is correct |
7 | Correct | 13 ms | 2076 KB | Output is correct |
8 | Correct | 19 ms | 2148 KB | Output is correct |
9 | Correct | 18 ms | 2148 KB | Output is correct |
10 | Correct | 17 ms | 2128 KB | Output is correct |
11 | Correct | 19 ms | 1968 KB | Output is correct |
12 | Correct | 16 ms | 2124 KB | Output is correct |
13 | Correct | 18 ms | 2164 KB | Output is correct |
14 | Correct | 34 ms | 2460 KB | Output is correct |
15 | Correct | 54 ms | 2568 KB | Output is correct |
16 | Correct | 53 ms | 2576 KB | Output is correct |
17 | Correct | 56 ms | 2572 KB | Output is correct |
18 | Correct | 47 ms | 2472 KB | Output is correct |
19 | Correct | 48 ms | 2568 KB | Output is correct |
20 | Correct | 52 ms | 2572 KB | Output is correct |
21 | Correct | 82 ms | 2640 KB | Output is correct |
22 | Correct | 125 ms | 2736 KB | Output is correct |
23 | Correct | 128 ms | 2728 KB | Output is correct |
24 | Correct | 136 ms | 2748 KB | Output is correct |
25 | Correct | 126 ms | 2864 KB | Output is correct |
26 | Correct | 131 ms | 2896 KB | Output is correct |
27 | Correct | 121 ms | 2760 KB | Output is correct |
28 | Correct | 131 ms | 2620 KB | Output is correct |
29 | Correct | 175 ms | 2952 KB | Output is correct |
30 | Correct | 255 ms | 3060 KB | Output is correct |
31 | Correct | 255 ms | 3140 KB | Output is correct |
32 | Correct | 251 ms | 3000 KB | Output is correct |
33 | Correct | 249 ms | 3172 KB | Output is correct |
34 | Correct | 248 ms | 3096 KB | Output is correct |
35 | Correct | 253 ms | 3020 KB | Output is correct |
36 | Correct | 231 ms | 2992 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 1952 KB | Output is correct |
2 | Correct | 8 ms | 2156 KB | Output is correct |
3 | Correct | 8 ms | 1716 KB | Output is correct |
4 | Correct | 8 ms | 1988 KB | Output is correct |
5 | Correct | 8 ms | 2092 KB | Output is correct |
6 | Correct | 8 ms | 2096 KB | Output is correct |
7 | Correct | 13 ms | 2076 KB | Output is correct |
8 | Correct | 19 ms | 2148 KB | Output is correct |
9 | Correct | 18 ms | 2148 KB | Output is correct |
10 | Correct | 17 ms | 2128 KB | Output is correct |
11 | Correct | 19 ms | 1968 KB | Output is correct |
12 | Correct | 16 ms | 2124 KB | Output is correct |
13 | Correct | 18 ms | 2164 KB | Output is correct |
14 | Correct | 34 ms | 2460 KB | Output is correct |
15 | Correct | 54 ms | 2568 KB | Output is correct |
16 | Correct | 53 ms | 2576 KB | Output is correct |
17 | Correct | 56 ms | 2572 KB | Output is correct |
18 | Correct | 47 ms | 2472 KB | Output is correct |
19 | Correct | 48 ms | 2568 KB | Output is correct |
20 | Correct | 52 ms | 2572 KB | Output is correct |
21 | Correct | 82 ms | 2640 KB | Output is correct |
22 | Correct | 125 ms | 2736 KB | Output is correct |
23 | Correct | 128 ms | 2728 KB | Output is correct |
24 | Correct | 136 ms | 2748 KB | Output is correct |
25 | Correct | 126 ms | 2864 KB | Output is correct |
26 | Correct | 131 ms | 2896 KB | Output is correct |
27 | Correct | 121 ms | 2760 KB | Output is correct |
28 | Correct | 131 ms | 2620 KB | Output is correct |
29 | Correct | 175 ms | 2952 KB | Output is correct |
30 | Correct | 255 ms | 3060 KB | Output is correct |
31 | Correct | 255 ms | 3140 KB | Output is correct |
32 | Correct | 251 ms | 3000 KB | Output is correct |
33 | Correct | 249 ms | 3172 KB | Output is correct |
34 | Correct | 248 ms | 3096 KB | Output is correct |
35 | Correct | 253 ms | 3020 KB | Output is correct |
36 | Correct | 231 ms | 2992 KB | Output is correct |
37 | Incorrect | 45 ms | 392 KB | invalid len |
38 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 1952 KB | Output is correct |
2 | Correct | 8 ms | 2156 KB | Output is correct |
3 | Correct | 8 ms | 1716 KB | Output is correct |
4 | Correct | 8 ms | 1988 KB | Output is correct |
5 | Correct | 8 ms | 2092 KB | Output is correct |
6 | Correct | 8 ms | 2096 KB | Output is correct |
7 | Correct | 13 ms | 2076 KB | Output is correct |
8 | Correct | 19 ms | 2148 KB | Output is correct |
9 | Correct | 18 ms | 2148 KB | Output is correct |
10 | Correct | 17 ms | 2128 KB | Output is correct |
11 | Correct | 19 ms | 1968 KB | Output is correct |
12 | Correct | 16 ms | 2124 KB | Output is correct |
13 | Correct | 18 ms | 2164 KB | Output is correct |
14 | Correct | 34 ms | 2460 KB | Output is correct |
15 | Correct | 54 ms | 2568 KB | Output is correct |
16 | Correct | 53 ms | 2576 KB | Output is correct |
17 | Correct | 56 ms | 2572 KB | Output is correct |
18 | Correct | 47 ms | 2472 KB | Output is correct |
19 | Correct | 48 ms | 2568 KB | Output is correct |
20 | Correct | 52 ms | 2572 KB | Output is correct |
21 | Correct | 82 ms | 2640 KB | Output is correct |
22 | Correct | 125 ms | 2736 KB | Output is correct |
23 | Correct | 128 ms | 2728 KB | Output is correct |
24 | Correct | 136 ms | 2748 KB | Output is correct |
25 | Correct | 126 ms | 2864 KB | Output is correct |
26 | Correct | 131 ms | 2896 KB | Output is correct |
27 | Correct | 121 ms | 2760 KB | Output is correct |
28 | Correct | 131 ms | 2620 KB | Output is correct |
29 | Correct | 175 ms | 2952 KB | Output is correct |
30 | Correct | 255 ms | 3060 KB | Output is correct |
31 | Correct | 255 ms | 3140 KB | Output is correct |
32 | Correct | 251 ms | 3000 KB | Output is correct |
33 | Correct | 249 ms | 3172 KB | Output is correct |
34 | Correct | 248 ms | 3096 KB | Output is correct |
35 | Correct | 253 ms | 3020 KB | Output is correct |
36 | Correct | 231 ms | 2992 KB | Output is correct |
37 | Incorrect | 45 ms | 392 KB | invalid len |
38 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 1952 KB | Output is correct |
2 | Correct | 8 ms | 2156 KB | Output is correct |
3 | Correct | 8 ms | 1716 KB | Output is correct |
4 | Correct | 8 ms | 1988 KB | Output is correct |
5 | Correct | 8 ms | 2092 KB | Output is correct |
6 | Correct | 8 ms | 2096 KB | Output is correct |
7 | Correct | 13 ms | 2076 KB | Output is correct |
8 | Correct | 19 ms | 2148 KB | Output is correct |
9 | Correct | 18 ms | 2148 KB | Output is correct |
10 | Correct | 17 ms | 2128 KB | Output is correct |
11 | Correct | 19 ms | 1968 KB | Output is correct |
12 | Correct | 16 ms | 2124 KB | Output is correct |
13 | Correct | 18 ms | 2164 KB | Output is correct |
14 | Correct | 34 ms | 2460 KB | Output is correct |
15 | Correct | 54 ms | 2568 KB | Output is correct |
16 | Correct | 53 ms | 2576 KB | Output is correct |
17 | Correct | 56 ms | 2572 KB | Output is correct |
18 | Correct | 47 ms | 2472 KB | Output is correct |
19 | Correct | 48 ms | 2568 KB | Output is correct |
20 | Correct | 52 ms | 2572 KB | Output is correct |
21 | Correct | 82 ms | 2640 KB | Output is correct |
22 | Correct | 125 ms | 2736 KB | Output is correct |
23 | Correct | 128 ms | 2728 KB | Output is correct |
24 | Correct | 136 ms | 2748 KB | Output is correct |
25 | Correct | 126 ms | 2864 KB | Output is correct |
26 | Correct | 131 ms | 2896 KB | Output is correct |
27 | Correct | 121 ms | 2760 KB | Output is correct |
28 | Correct | 131 ms | 2620 KB | Output is correct |
29 | Correct | 175 ms | 2952 KB | Output is correct |
30 | Correct | 255 ms | 3060 KB | Output is correct |
31 | Correct | 255 ms | 3140 KB | Output is correct |
32 | Correct | 251 ms | 3000 KB | Output is correct |
33 | Correct | 249 ms | 3172 KB | Output is correct |
34 | Correct | 248 ms | 3096 KB | Output is correct |
35 | Correct | 253 ms | 3020 KB | Output is correct |
36 | Correct | 231 ms | 2992 KB | Output is correct |
37 | Incorrect | 45 ms | 392 KB | invalid len |
38 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 1952 KB | Output is correct |
2 | Correct | 8 ms | 2156 KB | Output is correct |
3 | Correct | 8 ms | 1716 KB | Output is correct |
4 | Correct | 8 ms | 1988 KB | Output is correct |
5 | Correct | 8 ms | 2092 KB | Output is correct |
6 | Correct | 8 ms | 2096 KB | Output is correct |
7 | Correct | 13 ms | 2076 KB | Output is correct |
8 | Correct | 19 ms | 2148 KB | Output is correct |
9 | Correct | 18 ms | 2148 KB | Output is correct |
10 | Correct | 17 ms | 2128 KB | Output is correct |
11 | Correct | 19 ms | 1968 KB | Output is correct |
12 | Correct | 16 ms | 2124 KB | Output is correct |
13 | Correct | 18 ms | 2164 KB | Output is correct |
14 | Correct | 34 ms | 2460 KB | Output is correct |
15 | Correct | 54 ms | 2568 KB | Output is correct |
16 | Correct | 53 ms | 2576 KB | Output is correct |
17 | Correct | 56 ms | 2572 KB | Output is correct |
18 | Correct | 47 ms | 2472 KB | Output is correct |
19 | Correct | 48 ms | 2568 KB | Output is correct |
20 | Correct | 52 ms | 2572 KB | Output is correct |
21 | Correct | 82 ms | 2640 KB | Output is correct |
22 | Correct | 125 ms | 2736 KB | Output is correct |
23 | Correct | 128 ms | 2728 KB | Output is correct |
24 | Correct | 136 ms | 2748 KB | Output is correct |
25 | Correct | 126 ms | 2864 KB | Output is correct |
26 | Correct | 131 ms | 2896 KB | Output is correct |
27 | Correct | 121 ms | 2760 KB | Output is correct |
28 | Correct | 131 ms | 2620 KB | Output is correct |
29 | Correct | 175 ms | 2952 KB | Output is correct |
30 | Correct | 255 ms | 3060 KB | Output is correct |
31 | Correct | 255 ms | 3140 KB | Output is correct |
32 | Correct | 251 ms | 3000 KB | Output is correct |
33 | Correct | 249 ms | 3172 KB | Output is correct |
34 | Correct | 248 ms | 3096 KB | Output is correct |
35 | Correct | 253 ms | 3020 KB | Output is correct |
36 | Correct | 231 ms | 2992 KB | Output is correct |
37 | Incorrect | 45 ms | 392 KB | invalid len |
38 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 1952 KB | Output is correct |
2 | Correct | 8 ms | 2156 KB | Output is correct |
3 | Correct | 8 ms | 1716 KB | Output is correct |
4 | Correct | 8 ms | 1988 KB | Output is correct |
5 | Correct | 8 ms | 2092 KB | Output is correct |
6 | Correct | 8 ms | 2096 KB | Output is correct |
7 | Correct | 13 ms | 2076 KB | Output is correct |
8 | Correct | 19 ms | 2148 KB | Output is correct |
9 | Correct | 18 ms | 2148 KB | Output is correct |
10 | Correct | 17 ms | 2128 KB | Output is correct |
11 | Correct | 19 ms | 1968 KB | Output is correct |
12 | Correct | 16 ms | 2124 KB | Output is correct |
13 | Correct | 18 ms | 2164 KB | Output is correct |
14 | Correct | 34 ms | 2460 KB | Output is correct |
15 | Correct | 54 ms | 2568 KB | Output is correct |
16 | Correct | 53 ms | 2576 KB | Output is correct |
17 | Correct | 56 ms | 2572 KB | Output is correct |
18 | Correct | 47 ms | 2472 KB | Output is correct |
19 | Correct | 48 ms | 2568 KB | Output is correct |
20 | Correct | 52 ms | 2572 KB | Output is correct |
21 | Correct | 82 ms | 2640 KB | Output is correct |
22 | Correct | 125 ms | 2736 KB | Output is correct |
23 | Correct | 128 ms | 2728 KB | Output is correct |
24 | Correct | 136 ms | 2748 KB | Output is correct |
25 | Correct | 126 ms | 2864 KB | Output is correct |
26 | Correct | 131 ms | 2896 KB | Output is correct |
27 | Correct | 121 ms | 2760 KB | Output is correct |
28 | Correct | 131 ms | 2620 KB | Output is correct |
29 | Correct | 175 ms | 2952 KB | Output is correct |
30 | Correct | 255 ms | 3060 KB | Output is correct |
31 | Correct | 255 ms | 3140 KB | Output is correct |
32 | Correct | 251 ms | 3000 KB | Output is correct |
33 | Correct | 249 ms | 3172 KB | Output is correct |
34 | Correct | 248 ms | 3096 KB | Output is correct |
35 | Correct | 253 ms | 3020 KB | Output is correct |
36 | Correct | 231 ms | 2992 KB | Output is correct |
37 | Incorrect | 45 ms | 392 KB | invalid len |
38 | Halted | 0 ms | 0 KB | - |