Submission #1056502

#TimeUsernameProblemLanguageResultExecution timeMemory
1056502vnm06Dungeons Game (IOI21_dungeons)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #define endl '\n' using namespace std; int n, t, m; string s[100005][4]; vector<string> izp; int be, en, ans=0; bool mtch(int id) { for(int i=0; i<t; i++) { for(int j=0; j<izp.size(); j++) if(izp[j]==s[id][i]) return 1; } return 0; } void solve(int le, int ri) { if(ri-le+1<=ans) return; if(!izp.size()) { int mid=(le+ri)/2; be=mid, en=mid; for(int j=0; j<t; j++) { izp.push_back(s[mid][j]); while(be>le && (s[be-1][0]==s[mid][j] || s[be-1][1]==s[mid][j] || s[be-1][2]==s[mid][j] || s[be-1][3]==s[mid][j])) be--; while(en<ri && (s[en+1][0]==s[mid][j] || s[en+1][1]==s[mid][j] || s[en+1][2]==s[mid][j] || s[en+1][3]==s[mid][j])) en++; solve(le, ri); izp.resize(0); be=en=mid; } solve(le, mid-1); solve(mid+1, ri); } else if(izp.size()==m || (be==le && ri==en)) { ans=max(ans, en-be+1); return; } else { int be1=be, en1=en; for(int j=0; j<t; j++) { if(be!=le) { izp.push_back(s[be-1][j]); while(be>le && mtch(be-1)) be--; while(en<ri && mtch(en+1)) en++; solve(le, ri); izp.resize(izp.size()-1); be=be1; en=en1; } if(en!=ri) { izp.push_back(s[en+1][j]); while(be>le && mtch(be-1)) be--; while(en<ri && mtch(en+1)) en++; solve(le, ri); izp.resize(izp.size()-1); be=be1; en=en1; } } } } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>t>>m; for(int i=0; i<n; i++) { for(int j=0; j<t; j++) cin>>s[i][j]; } solve(0, n-1); cout<<ans<<endl; return 0; }

Compilation message (stderr)

dungeons.cpp: In function 'bool mtch(int)':
dungeons.cpp:16:23: 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]
   16 |         for(int j=0; j<izp.size(); j++) if(izp[j]==s[id][i]) return 1;
      |                      ~^~~~~~~~~~~
dungeons.cpp: In function 'void solve(int, int)':
dungeons.cpp:40:23: warning: comparison of integer expressions of different signedness: 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   40 |     else if(izp.size()==m || (be==le && ri==en))
      |             ~~~~~~~~~~^~~
/usr/bin/ld: /tmp/ccn26wbT.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccxVlTET.o:dungeons.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccn26wbT.o: in function `main':
grader.cpp:(.text.startup+0x3bd): undefined reference to `init(int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
/usr/bin/ld: grader.cpp:(.text.startup+0x440): undefined reference to `simulate(int, int)'
collect2: error: ld returned 1 exit status