Submission #493895

#TimeUsernameProblemLanguageResultExecution timeMemory
493895KarabasanZigZag (COCI17_zigzag)C++17
80 / 80
58 ms8344 KiB
#include <bits/stdc++.h> #define ll long long #define fast1 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define endl "\n" using namespace std; #pragma GCC optimize("Ofast") #pragma GCC target("fma,sse,sse2,sse3,avx") #pragma GCC optimize("unroll-loops") int n,a,b,k; string s[100005]; char dizi[100005]; pair<int,int> ptr[30]; void solve() { memset(ptr,-1,sizeof ptr); cin>>n>>k; for(int i=0;i<n;i++) cin>>s[i]; for(int i=0;i<k;i++) cin>>dizi[i]; sort(s,s+n); for(int i=0;i<n;i++) { if(ptr[s[i][0]-'a'].first==-1) ptr[s[i][0]-'a']={i,i}; } for(int i=0;i<k;i++) { if(s[ptr[dizi[i]-'a'].second][0]!=dizi[i]) ptr[dizi[i]-'a'].second=ptr[dizi[i]-'a'].first; cout<<s[ptr[dizi[i]-'a'].second]<<endl; ptr[dizi[i]-'a'].second++; } } signed main() { fast1 //freopen ("lca.gir","r",stdin); //freopen ("lca.cik","w",stdout); int t=1; //cin>>t; while(t--) { solve(); } return 0; }

Compilation message (stderr)

zigzag.cpp: In function 'void solve()':
zigzag.cpp:16:29: warning: 'void* memset(void*, int, size_t)' writing to an object of type 'struct std::pair<int, int>' with no trivial copy-assignment [-Wclass-memaccess]
   16 |     memset(ptr,-1,sizeof ptr);
      |                             ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from zigzag.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:211:12: note: 'struct std::pair<int, int>' declared here
  211 |     struct pair
      |            ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...