제출 #1162696

#제출 시각아이디문제언어결과실행 시간메모리
1162696cbnhtmanhNivelle (COCI20_nivelle)C++20
0 / 110
17 ms584 KiB
#include <bits/stdc++.h>
#define fi(i, a, b) for( int i = a; i <= b; i++ )
#define fid(i, a, b) for( int i = a; i >= b; i-- )
#define getbit(x, i) ((x>>i)&1)
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define st first
#define nd second
#define mp make_pair
#define HTManh ""
#define maxn 100009
#define endl '\n'
using namespace std;

int test;

int n;
string str;

int chu[26];
set<int> s;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);
	if (fopen(HTManh".inp", "r"))
    {
        freopen(HTManh".inp", "r", stdin);
        freopen(HTManh".out", "w", stdout);
    }

    cin >> n >> str;
    str = ' ' + str;

    s.insert(0);
    pll res = {1e9,1};
    int dau, cuoi;
    dau = cuoi = 1;
    fi(i,1,n)
    {
        if (chu[str[i]-'a'] != 0) s.erase(chu[str[i]-'a']);
        chu[str[i]-'a'] = i;

        int dem = s.size();
        for(int x: s)
        {
            //cout << i << "|" << dem << "/" << (i-x) << endl;
            if (res.st*(i-x) > res.nd*dem)
            {
                res = {dem, i};
                dau = x+1;
                cuoi = i;
            }
            dem--;
        }
        s.insert(i);

//        for(int x: s) cout << x << " ";
//        cout << endl;
    }

    cout << dau << " " << cuoi << endl;

}

컴파일 시 표준 에러 (stderr) 메시지

nivelle.cpp: In function 'int main()':
nivelle.cpp:32:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |         freopen(HTManh".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
nivelle.cpp:33:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |         freopen(HTManh".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...