Submission #659948

#TimeUsernameProblemLanguageResultExecution timeMemory
659948RambaXGorillaBoard (CEOI13_board)C++17
20 / 100
12 ms756 KiB
#include<cstdio> #include<algorithm> #include<string> using namespace std; string pos[2] = {"0", "0"}; string sub[2] = {"0", "0"}; void inc(string &a){ for(int i = a.size() - 1;i > -1;i--){ if(a[i] - '0'){ a[i] = '0'; } else{ a[i] = '1'; break; } } } int main(){ for(int i = 0;i < 2;i++){ char a; while(scanf("%c",&a) != EOF){ if(a == '1'){ pos[i].push_back('0'); sub[i].push_back('0'); } else if (a == '2'){ pos[i].push_back('1'); sub[i].push_back('0'); } else if (a == 'U'){ bool check = false; if(pos[i].back() < sub[i].back()){ check = true; } pos[i].pop_back(); sub[i].pop_back(); if(check){ inc(sub[i]); } } else if(a == 'L'){ inc(sub[i]); } else if(a == 'R'){ inc(pos[i]); } else{ break; } } } for(int i = 0;i < 2;i++){ bool borr = false; for(int j = pos[i].size() - 1;j > -1;j--){ if(pos[i][j] > sub[i][j]){ pos[i][j] -= borr; borr = false; } else if(pos[i][j] < sub[i][j]){ pos[i][j] += 1 - borr; borr = true; } else{ pos[i][j] = borr + '0'; } } } sort(pos, pos + 2); int len = min(pos[0].size(), pos[1].size()); int last = len; int add = 0; for(int i = 0;i < len;i++){ if(pos[0][i] < pos[1][i]){ last = i + 1; add = 1; break; } } for(int i = last;i < len;i++){ if(pos[0][i] >= pos[1][i]){ last = i + 1; } if(pos[0][i] == pos[1][i]){ add = 2; } if(pos[0][i] <= pos[1][i]){ break; } } printf("%d",pos[0].size() + pos[1].size() - last * 2 + add); }

Compilation message (stderr)

board.cpp: In function 'int main()':
board.cpp:90:14: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wformat=]
   90 |     printf("%d",pos[0].size() + pos[1].size() - last * 2 + add);
      |             ~^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |              |                                           |
      |              int                                         std::__cxx11::basic_string<char>::size_type {aka long unsigned int}
      |             %ld
#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...