답안 #625944

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
625944 2022-08-11T03:59:57 Z elesis Programiranje (COCI17_programiranje) C++14
80 / 80
33 ms 11644 KB
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);
#define int long long 
#define pii pair<int,int> 
#define ff first
#define ss second
const int inf=1e11+7;
const int N=107;
const int mod =1000000007;
vector <int> adj[N];
void solve()
{
    string s;
    cin>>s;
    vector <vector <int>> pref(26,vector <int> (s.size()+1,0));
    //cout << pref[1][0] << '\n';
    int n=s.size();
    
    for(int i=0;i<26;i++)
    {
        for(int j=1;j<=n;j++)
        {
            pref[i][j]=pref[i][j-1];
            if((s[j-1]-97)==i)
            {
                pref[i][j]++;
            }
        }
    }
    //cout << pref[1][5] << "\n";
    int q;
    cin>>q;
    
    while(q--)
    {
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        bool flag=true;
        for(int i=0;i<26;i++)
        {
            if((pref[i][b]-pref[i][a-1])!=pref[i][d]-pref[i][c-1])
            {
                //cout << a << " " << b << " " << c << " " << d << '\n';
                flag=false;
                break;
            }
        }   
        if(flag)
        {
            cout << "DA" << '\n';
        }
        else
        {
            cout << "NE" << "\n";
        }
    }
}
signed main()
{
    fast
    clock_t start, end;
    start = clock();
    solve();
    end = clock();
    double time_taken=double(end-start)/double(CLOCKS_PER_SEC);
    //cout << "time taken" << " " << time_taken << "\n";
}

Compilation message

programiranje.cpp: In function 'int main()':
programiranje.cpp:66:12: warning: unused variable 'time_taken' [-Wunused-variable]
   66 |     double time_taken=double(end-start)/double(CLOCKS_PER_SEC);
      |            ^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 30 ms 11640 KB Output is correct
7 Correct 33 ms 11644 KB Output is correct
8 Correct 29 ms 11616 KB Output is correct
9 Correct 29 ms 11596 KB Output is correct
10 Correct 28 ms 11608 KB Output is correct