Submission #622439

# Submission time Handle Problem Language Result Execution time Memory
622439 2022-08-04T09:34:04 Z kabika Programiranje (COCI17_programiranje) C++14
40 / 80
3000 ms 1732 KB
#include <bits/stdc++.h>
using namespace std;

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    int q;
    cin >> q;
    while(q--)
    {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        
        if(b-a != d-c)
        {
            cout << "NE\n";
            continue;
        }
        
        if(a == c && b == d)
        {
            cout << "DA\n";
            continue;
        }
        
        if(a >= c && b >= d)
        {
            swap(a,c);
            swap(b,d);
        }
        
        if(b >= c)
        {
            swap(b,c);
            --b;
            ++c;
        }
        //cout << a << " " << b << " " << c << " " << d << '\n';
        
        string s1(s,a-1,b-a+1);
        string s2(s,c-1,d-c+1);
        //cout << s1 << " " << s2 << '\n';
        
        sort(s1.begin(),s1.end());
        sort(s2.begin(),s2.end());
        if(s1 == s2)
            cout << "DA\n";
        else
            cout << "NE\n";
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 7 ms 340 KB Output is correct
2 Correct 7 ms 340 KB Output is correct
3 Correct 7 ms 340 KB Output is correct
4 Correct 9 ms 356 KB Output is correct
5 Correct 7 ms 340 KB Output is correct
6 Execution timed out 3057 ms 1732 KB Time limit exceeded
7 Execution timed out 3056 ms 1676 KB Time limit exceeded
8 Execution timed out 3077 ms 1688 KB Time limit exceeded
9 Execution timed out 3079 ms 1644 KB Time limit exceeded
10 Execution timed out 3053 ms 1592 KB Time limit exceeded