답안 #655000

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
655000 2022-11-02T11:33:26 Z _Knyaz_ Programiranje (COCI17_programiranje) C++17
40 / 80
3000 ms 856 KB
#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);
}
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];
        x = s.substr(a-1, b-a+1); y = s.substr(c-1, d-c+1);
        sort(all(x)); sort(all(y));
        size_t found = y.find(x);
        cout << (found!=string::npos?"DA\n":"NE\n");
    }
}
signed main(){
    cin.tie(0)->sync_with_stdio(0);
    int t; t = 1;
    //cin >> t;
    while(t--) solve();
}
/*
        ██╗  ██╗███╗   ██╗██╗   ██╗ █████╗ ███████╗
        ██║ ██╔╝████╗  ██║╚██╗ ██╔╝██╔══██╗╚══███╔╝
        █████╔╝ ██╔██╗ ██║ ╚████╔╝ ███████║  ███╔╝
        ██╔═██╗ ██║╚██╗██║  ╚██╔╝  ██╔══██║ ███╔╝
███████╗██║  ██╗██║ ╚████║   ██║   ██║  ██║███████╗███████╗
╚══════╝╚═╝  ╚═╝╚═╝  ╚═══╝   ╚═╝   ╚═╝  ╚═╝╚══════╝╚══════╝
*/

Compilation message

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);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 384 KB Output is correct
2 Correct 31 ms 352 KB Output is correct
3 Correct 33 ms 380 KB Output is correct
4 Correct 31 ms 376 KB Output is correct
5 Correct 31 ms 356 KB Output is correct
6 Execution timed out 3063 ms 800 KB Time limit exceeded
7 Execution timed out 3089 ms 704 KB Time limit exceeded
8 Execution timed out 3066 ms 856 KB Time limit exceeded
9 Execution timed out 3073 ms 728 KB Time limit exceeded
10 Execution timed out 3061 ms 796 KB Time limit exceeded