Submission #120943

#TimeUsernameProblemLanguageResultExecution timeMemory
120943kimbj0709Ispit (COCI19_ispit)C++17
0 / 90
59 ms1160 KiB
#include <bits/stdc++.h> using namespace std; bool find(vector<char> vect1,vector<char> vect2){ for(int i=0;i<vect1.size();i++){ if(vect1[i]!=vect2[i]){ return 0; } } return 1; //1 is same 0 is different } int find2(vector<char> vect1,vector<char> vect2){ int startpos = INT_MAX; int endpos = INT_MAX; for(int i=0;i<vect1.size();i++){ if(vect1[i]!=vect2[i]){ startpos = i; break; } } for(int i=vect1.size()-1;i>=0;i--){ if(vect1[i]!=vect2[i]){ endpos = i; break; } } if(startpos==INT_MAX){ return 0; } else{ return endpos-startpos+1; } } int main() { char input; int width,height; int contig; //vect1 is unsorted //vect2 is sorted vector<vector<char> > vect1(501); vector<vector<char> > vect2(501); cin >> width >> contig; for(int i=0;i<width;i++){ for(int j=0;j<width;j++){ cin >> input; vect1[i].push_back(input); } vect2[i] = vect1[i]; sort(vect2[i].begin(),vect2[i].end()); } for(int i=0;i<width;i++){ for(int j=i+1;j<width;j++){ if(find(vect2[i],vect2[j])==0){ continue; } else{ int k = find2(vect2[i],vect2[j]); if(k<=contig){ cout << "DA"; return 0; } } } } cout << "NE"; }

Compilation message (stderr)

ispit.cpp: In function 'bool find(std::vector<char>, std::vector<char>)':
ispit.cpp:4:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<vect1.size();i++){
               ~^~~~~~~~~~~~~
ispit.cpp: In function 'int find2(std::vector<char>, std::vector<char>)':
ispit.cpp:15:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<vect1.size();i++){
               ~^~~~~~~~~~~~~
ispit.cpp: In function 'int main()':
ispit.cpp:37:13: warning: unused variable 'height' [-Wunused-variable]
   int width,height;
             ^~~~~~
#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...