Submission #654998

#TimeUsernameProblemLanguageResultExecution timeMemory
654998_Knyaz_Programiranje (COCI17_programiranje)C++17
40 / 80
3099 ms976 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define int ll #define all(x) (x).begin(),(x).end() const int mod = 1e9+7; const double PI = acos( -1. ); void in(){ freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); } bool get(string x, string y){ sort(x.begin(), x.end()); sort(y.begin(), y.end()); int ans = 0, id = 0; for(int i = 0; i < x.size() && id < y.size(); i++){ if(x[i]==y[id]) ans++; else i--; id++; } return ans == x.size(); } void solve(){ //in(); string s; cin >> s; int q; cin >> q; while(q--){ string x, y; int a, b, c, d; cin >> a >> b >> c >> d; for(int i = a-1; i < b; i++) x+=s[i]; for(int i = c-1; i < d; i++) y+=s[i]; cout << (get(y, x)?"DA\n":"NE\n"); } } signed main(){ cin.tie(0)->sync_with_stdio(0); int t; t = 1; //cin >> t; while(t--) solve(); } /* ██╗ ██╗███╗ ██╗██╗ ██╗ █████╗ ███████╗ ██║ ██╔╝████╗ ██║╚██╗ ██╔╝██╔══██╗╚══███╔╝ █████╔╝ ██╔██╗ ██║ ╚████╔╝ ███████║ ███╔╝ ██╔═██╗ ██║╚██╗██║ ╚██╔╝ ██╔══██║ ███╔╝ ███████╗██║ ██╗██║ ╚████║ ██║ ██║ ██║███████╗███████╗ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝ */

Compilation message (stderr)

programiranje.cpp: In function 'bool get(std::string, std::string)':
programiranje.cpp:16:22: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for(int i = 0; i < x.size() && id < y.size(); i++){
      |                    ~~^~~~~~~~~~
programiranje.cpp:16:39: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for(int i = 0; i < x.size() && id < y.size(); i++){
      |                                    ~~~^~~~~~~~~~
programiranje.cpp:18:9: warning: this 'else' clause does not guard... [-Wmisleading-indentation]
   18 |         else i--; id++;
      |         ^~~~
programiranje.cpp:18:19: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'else'
   18 |         else i--; id++;
      |                   ^~
programiranje.cpp:20:16: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     return ans == x.size();
      |            ~~~~^~~~~~~~~~~
programiranje.cpp: In function 'void in()':
programiranje.cpp:9:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     freopen("input.txt", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
programiranje.cpp:10:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     freopen("output.txt", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...