답안 #1032017

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1032017 2024-07-23T10:05:45 Z 7again Programiranje (COCI17_programiranje) C++17
80 / 80
26 ms 14380 KB
#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

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);}
      |                                                           ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 12888 KB Output is correct
2 Correct 2 ms 12892 KB Output is correct
3 Correct 2 ms 12892 KB Output is correct
4 Correct 2 ms 12892 KB Output is correct
5 Correct 2 ms 12892 KB Output is correct
6 Correct 16 ms 14380 KB Output is correct
7 Correct 15 ms 14184 KB Output is correct
8 Correct 16 ms 14172 KB Output is correct
9 Correct 26 ms 14160 KB Output is correct
10 Correct 16 ms 14172 KB Output is correct