Submission #653147

#TimeUsernameProblemLanguageResultExecution timeMemory
653147aryan12Mars (APIO22_mars)C++17
14 / 100
16 ms2268 KiB
#include "mars.h" #include <bits/stdc++.h> using namespace std; string process(vector<vector<string> > a, int startR, int startC, int k, int n) { string ans = ""; if(k != 0) { for(int k = 0; k < 100; k++) { int f = 0; for(int i = 0; i < a.size(); i++) { for(int j = 0; j < a[i].size(); j++) { if(a[i][j][k] == '1') { f++; } } } ans += (f != 0) ? "1" : "0"; } n = 2 * n + 1; } else if(k == 0) { n = 2 * n + 1; ans = string(100, '0'); for(int i = 0; i < a.size(); i++) { for(int j = 0; j < a[i].size(); j++) { int idx = n * (startR + i) + startC + j; ans[idx] = a[i][j][0]; } } } n = (n - 1) / 2; if(k == n - 1) { n = 2 * n + 1; string ans2 = ans; vector<bool> ok(100, false); int cnt = 0; for(int i = 0; i < ans2.size(); i++) { if(ans2[i] == '1' && !ok[i]) { cnt++; queue<int> q; q.push(i); while(!q.empty()) { int node = q.front(); q.pop(); if(ok[node]) continue; ok[node] = true; if(node + 1 <= 100 && ans2[node + 1] == '1' && (node + 1) % n != 0) { q.push(node + 1); } if(node - 1 >= 0 && ans2[node - 1] == '1' && node % n != 0) { q.push(node - 1); } if(node - n >= 0 && ans2[node - n] == '1') { q.push(node - n); } if(node + n <= 100 && ans2[node + n] == '1') { q.push(node + n); } } } } for(int i = 0; i < 100; i++) { if(i >= 10) { ans[i] = '0'; } else { ans[i] = ((1 << i) & cnt) ? '1' : '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:13:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<std::__cxx11::basic_string<char> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |    for(int i = 0; i < a.size(); i++)
      |                   ~~^~~~~~~~~~
mars.cpp:15:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     for(int j = 0; j < a[i].size(); j++)
      |                    ~~^~~~~~~~~~~~~
mars.cpp:31:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<std::__cxx11::basic_string<char> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |   for(int i = 0; i < a.size(); i++)
      |                  ~~^~~~~~~~~~
mars.cpp:33:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |    for(int j = 0; j < a[i].size(); j++)
      |                   ~~^~~~~~~~~~~~~
mars.cpp:47:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |   for(int i = 0; i < ans2.size(); i++)
      |                  ~~^~~~~~~~~~~~~
#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...