Submission #872680

#TimeUsernameProblemLanguageResultExecution timeMemory
872680vjudge1Nivelle (COCI20_nivelle)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #ifdef LOCAL #include "Essentials/algo/debug.h" #else #define debug(...) 69 #endif using namespace std; typedef long long ll; typedef long double ldb; typedef pair<int,int> pii; const int N = 1e5 + 23; const int LOG = 26; const ll inf = 1e18; #define F first #define S second #define pb push_back #define kill(x) cout<<x<<endl, exit(0); #define all(x) x.begin(),x.end() #define sz(x) (int)x.size() #define lc (v << 1) #define rc ((v<<1) |1) int n; string s; int a[N]; int b[N]; vector<int> vals; pair<ldb,pii> ans = {1.0 , {1,1}}; void check(int x) { int l = 1; int s = __builtin_popcount(x); for(int i = 1 ; i<=n ; i++) { b[i] = (x >> a[i]) &1; //debug(i,b[i]); if(b[i] == 0) { if(b[i-1] == 0 || i == 1) { l = i+1; continue; } int r = i-1; debug((ldb)s/(r-l+1),s,(r-l+1)); ans = min(ans, {(ldb)s/(r-l+1), {l,r}}); l = i+1; } if(i > 1 && b[i] == b[i-1] && b[i] == 1) { debug(x,i,i-1); } } if(b[n] != 0) { int r = n; ans = min(ans, {(ldb)s/(r-l+1), {l,r}}); } } bool mark[LOG+23]; int32_t main() { cin.tie(nullptr)->sync_with_stdio(false); cin>>n>>s; vector<int> sex; for(int i = 1; i<= n ; i++) { a[i] = s[i-1] -'a'; } sex.pb(a[n]); vals.pb(a[n]); for(int i = 1; i<= n; i++) { if(!mark[a[i]]) { sex.pb(a[i]); int f = 0; for(int j = sz(sex); j>= 0 ;j--) { int x = sex[j]; f |= (1 << x); vals.pb(f); } mark[a[i]] = true; } else { sex.erase(find(all(sex),a[i])) sex.pb(a[i]); int f = 0; for(int j = sz(sex); j>= 0 ;j--) { int x = sex[j]; f |= (1 << x); vals.pb(f); } } } sort(all(vals)); vals.resize(unique(all(vals)) - vals.begin()); for(int x : vals) check(x); cout<<ans.S.F << ' '<< ans.S.S << '\n'; return 0; }

Compilation message (stderr)

nivelle.cpp: In function 'void check(int)':
nivelle.cpp:5:20: warning: statement has no effect [-Wunused-value]
    5 | #define debug(...) 69
      |                    ^~
nivelle.cpp:45:4: note: in expansion of macro 'debug'
   45 |    debug((ldb)s/(r-l+1),s,(r-l+1));
      |    ^~~~~
nivelle.cpp:5:20: warning: statement has no effect [-Wunused-value]
    5 | #define debug(...) 69
      |                    ^~
nivelle.cpp:50:4: note: in expansion of macro 'debug'
   50 |    debug(x,i,i-1);
      |    ^~~~~
nivelle.cpp: In function 'int32_t main()':
nivelle.cpp:81:34: error: expected ';' before 'sex'
   81 |    sex.erase(find(all(sex),a[i]))
      |                                  ^
      |                                  ;
   82 |    sex.pb(a[i]);
      |    ~~~