Submission #880682

#TimeUsernameProblemLanguageResultExecution timeMemory
880682mychecksedadMars (APIO22_mars)C++17
0 / 100
0 ms352 KiB
#include<mars.h> #include<bits/stdc++.h> using namespace std; #define ll long long int #define MOD (1000000000+7) #define MOD1 (998244353) #define pb push_back #define all(x) x.begin(), x.end() #define en cout << '\n' const int N = 1e6+100, M = 1e5+10, K = 52, MX = 30; struct Dsu { vector<int> s, p; int sz; Dsu(int n){ sz = n; s.resize(n+1, 1); p.resize(n+1); for(int i = 0; i <= n; ++i) p[i] = i; } int find(int v){ if(p[v] == v) return v; return (p[v] = find(p[v])); } void merge(int a, int b){ a = find(a); b = find(b); if(a != b){ if(s[a] > s[b]){ swap(a, b); } s[b] += s[a]; p[a] = b; sz--; } } }; std::string process(vector<vector<string>> a,int i,int j,int k,int n){ Dsu d(9); int zero; for(int i = 0; i < 3; ++i){ for(int j = 0; j < 3; ++j){ if(a[i][j][0] == '0'){ zero++; continue; } if(j < 2){ if(a[i][j][0] == '1' && a[i][j + 1][0] == '1') d.merge(i*3+j, i*3+j+1); } if(i < 2){ if(a[i][j][0] == '1' && a[i + 1][j][0] == '1') d.merge(i*3+j, i*3+j+3); } } } int val = d.sz - zero; string ans = ""; for(int i = 0; i < 100; ++i) ans.pb(' '); ans[0] = (val % 2) + '0'; ans[1] = ((val&2) > 0) + '0'; ans[2] = ((val&4) > 0) + '0'; return ans; }

Compilation message (stderr)

mars.cpp: In function 'std::string process(std::vector<std::vector<std::__cxx11::basic_string<char> > >, int, int, int, int)':
mars.cpp:46:9: warning: 'zero' may be used uninitialized in this function [-Wmaybe-uninitialized]
   46 |     zero++;
      |     ~~~~^~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...