Submission #1032017

#TimeUsernameProblemLanguageResultExecution timeMemory
10320177againProgramiranje (COCI17_programiranje)C++17
80 / 80
26 ms14380 KiB
#include <bits/stdc++.h> #define int long long #define endl "\n" #define f first #define s second #define pb push_back #define in insert #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define yes cout<<"Yes\n" #define no cout<<"No\n" #define FAST ios::sync_with_stdio(0);cout.tie(0);cin.tie(0) using namespace std ; void setIO(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);} const int N = 60000 , MOD = 1e9+7 ; //bool inside(int x,int y){return(x<n&&y<m&&x>-1&&y>-1&&a[x][y]!='#');} //int dx[4]{1 , -1 , 0 , 0} , dy[4]{0 , 0 , 1 , -1} ; int pfx[27][N] ; void slv() { string s ; cin >> s ; int n = s.size() ; fill_n(&pfx[0][0] , (27) * (N) , 0) ; for(int i = 1 ; i <= n ; i++) { for(char c = 'a' ; c <= 'z' ; c++) { if(s[i - 1] == c) pfx[c - 'a'][i]++ ; pfx[c - 'a'][i] += pfx[c - 'a'][i - 1] ; } } int q ; cin >> q ; while(q--) { int l1 , r1 , l2 , r2 , Ok = 1 ; cin >> l1 >> r1 >> l2 >> r2 ; l1-- , l2-- ; for(char c = 'a' ; c <= 'z' ; c++) { if(pfx[c - 'a'][r1] - pfx[c - 'a'][l1] != pfx[c - 'a'][r2] - pfx[c - 'a'][l2]) { cout << "NE" << endl ; Ok = 0 ; break ; } } if(Ok) cout << "DA" << endl ; } } main() { //setIO("lasers") ; FAST ; int t = 1 ; //cin >> t ; while(t--) slv() ; }

Compilation message (stderr)

programiranje.cpp:67:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   67 | main()
      | ^~~~
programiranje.cpp: In function 'void setIO(std::string)':
programiranje.cpp:16:29: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 | void setIO(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
programiranje.cpp:16:66: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 | void setIO(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                                                           ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...