4792 | 2023-03-31 12:32:45 | Eyusie | Leghosszabb béke (75 pont) | cpp17 | Forditási hiba |
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define MAXN 100000
#ifdef MAXN
// no getchar_unlocked on Windows so just call getchar
inline int getchar_unlocked() { return getchar(); }
inline int putchar_unlocked(int c) { return putchar(c); }
#endif
int n, k, m, l, mx, counter, indmx, indcur;
bool x, ag1, ag2, neg_x;
bool a[MAXN + 1];
int i;
int j = 1;
inline void fastscan(int &number)
{
//variable to indicate sign of input number
register int c;
number = 0;
// extract current character from buffer
c = getchar();
// Keep on extracting characters if they are integers
// i.e ASCII Value lies from '0'(48) to '9' (57)
for (; (c>47 && c<58); c=getchar_unlocked())
number = number *10 + c - 48;
}
int main()
{
//iostream::sync_with_stdio(0);
//cin.tie(0);
//register bool x, ag1, ag2, neg_x;
fastscan(n);
fastscan(k);
for(; i < k; ++i)
{
fastscan(m);
fastscan(l);
fill(a+m, a+l+1,1);
}
for(; j <= n; ++j)
{
/*
if(a[j])
{
if(mx < counter)
{
indmx = indcur;
mx = counter;
}
counter = 0;
}
else
{
if(counter == 0)
{
indcur = j;
counter++;
}
else counter++;
}*/
ag1 = a[j];
ag2 = !ag1;
x = ag2*(counter == 0) + ag1*(mx < counter);
neg_x = !x;
indmx = ag2*indmx + ag1*(indmx*neg_x + indcur*x);
mx = ag2*mx + ag1*(mx*neg_x + counter*x);
indcur = ag2*(indcur*neg_x + j*x) + ag1*indcur;
counter = ag2*(counter+1);
//cout << ag1 << " " << ag2 << "\n";
//cout << x << " " << indmx << " " << mx << " " << indcur << " " << counter << "\n";
}
if(mx < counter)
{
mx = counter;
indmx = indcur;
}
if(mx == 0)
{
putchar_unlocked('-');
putchar_unlocked('1');
return 0;
}
cout << mx << " " << indmx << "\n";
}
exit status 1
main.cpp:10:12: error: 'int getchar_unlocked()' redeclared inline without 'gnu_inline' attribute
10 | inline int getchar_unlocked() { return getchar(); }
| ^~~~~~~~~~~~~~~~
In file included from /usr/include/stdio.h:891,
from /usr/include/c++/11/cstdio:42,
from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:46,
from main.cpp:1:
/usr/include/x86_64-linux-gnu/bits/stdio.h:73:1: note: 'int getchar_unlocked()' previously defined here
73 | getchar_unlocked (void)
| ^~~~~~~~~~~~~~~~
main.cpp:11:12: error: 'int putchar_unlocked(int)' redeclared inline without 'gnu_inline' attribute
11 | inline int putchar_unlocked(int c) { return putchar(c); }
| ^~~~~~~~~~~~~~~~
In file included from /usr/include/stdio.h:891,
from /usr/include/c++/11/cstdio:42,
from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:46,
from main.cpp:1:
/usr/include/x86_64-linux-gnu/bits/stdio.h:...