Submission #475306

# Submission time Handle Problem Language Result Execution time Memory
475306 2021-09-21T20:08:52 Z Beboo44 ZigZag (COCI17_zigzag) C++14
48 / 80
2000 ms 9348 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0)

int main()
{
ios_base::sync_with_stdio(0) ;
cin.tie(0) ;

   ll n,m;
   cin>>n>>m;
   vector<vector<string>>v(26);
   string s;
   for(int i=0; i<n; ++i){
    cin>>s;
    int x = (int)s[0]-'a';
    v[x].push_back(s);
   }

   vector<string>t;
   for(int i=0; i<26; ++i){
    for(int j=0; j< v[i].size(); ++j){
        t.push_back(v[i][j]);
    }
    sort(t.begin(),t.end());
    for(int j=0; j<v[i].size(); ++j){
        v[i][j] = t[j];
    }
    t.clear();
   }

   char y;
    while(m--){
      cin>>y;
      ll f = (int)y-'a';
      cout<<v[f][0]<<endl;
      v[f].push_back(v[f][0]);
      v[f].erase(v[f].begin());

    }





    return 0;
}

Compilation message

zigzag.cpp: In function 'int main()':
zigzag.cpp:23:19: 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]
   23 |     for(int j=0; j< v[i].size(); ++j){
      |                  ~^~~~~~~~~~~~~
zigzag.cpp:27:19: 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]
   27 |     for(int j=0; j<v[i].size(); ++j){
      |                  ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Execution timed out 2086 ms 9276 KB Time limit exceeded
8 Execution timed out 2045 ms 9216 KB Time limit exceeded
9 Execution timed out 2087 ms 9348 KB Time limit exceeded
10 Execution timed out 2084 ms 9244 KB Time limit exceeded