submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3 values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s547125876 | p03789 | C++ | #include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int N=501010;
char s[N];
struct Bigint
{
int a[N],n;
int& operator [] (const int &x){return a[x];}
Bigint(){memset(a,0,sizeof(a));n=0;}
Bigint(char *s){n=strlen(s);for(int i=0;i<n;i++)a[i]=s[n-i-1]-'0';}
void carry()
{
for(int i=0;i<n;i++)
{
if(a[i]<=9) continue;
a[i+1]+=a[i]/10;
a[i]%=10;
if(i==n-1) n++;
}
}
Bigint& operator *= (int x){for(int i=0;i<n;i++)a[i]*=x;carry();return *this;}
int get(){int res=0;for(int i=0;i<n;i++)res+=a[i];return res;}
void gao(int &sum)
{
a[0]+=9;sum+=9;
for(int i=0;a[i]>9;i++)
{
sum-=a[i];sum-=a[i+1];
a[i+1]+=a[i]/10;a[i]%=10;
sum+=a[i];sum+=a[i+1];
if(i==n-1) n++;
}
}
} A;
int main()
{
scanf("%s",s);
A=s;A*=9;
int sum=A.get(),k;
for(k=1;true;k++)
{
A.gao(sum);
if(sum<=9*k&&sum%9==0) break;
}
cout<<k<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:47:5: error: 'cout' was not declared in this scope
47 | cout<<k<<endl;
| ^~~~
a.cc:4:1: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
3 | #include <algorithm>
+++ |+#include <iostream>
4 | using namespace std;
a.cc:47:14: error: 'endl' was not declared in this scope
47 | cout<<k<<endl;
| ^~~~
a.cc:4:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
3 | #include <algorithm>
+++ |+#include <ostream>
4 | using namespace std;
|
s030815905 | p03789 | C | #include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
#define inf 2147483647
#define eps 1e-9
using namespace std;
typedef long long ll;
int n,tot,a[800001];
char s[500001];
void mul(int a[],int &n,int k){
int p=0;
tot=0;
for(int i=1;i<=n;i++){
p=a[i]*k+p;
a[i]=p%10;
tot+=a[i];
p/=10;
}
if(p)a[++n]=p;
tot+=p;
}
void add(int a[],int &n,int k){
int p=0;
tot-=a[1];
a[1]+=k;
p=a[1]/10;
a[1]%=10;
tot+=a[1];
for(int i=2;i<=n;i++){
tot-=a[i];
a[i]+=p;
p=a[i]/10;
a[i]%=10;
tot+=a[i];
if(!p)break;
}
if(p)a[++n]=p;
tot+=p;
}
int main(){
scanf("%s",s);
n=strlen(s);
for(int i=1;i<=n;i++){
a[i]=s[n-i]-'0';
}
mul(a,n,9);
for(int i=1;i<=n;i++){
add(a,n,9);
if(tot%9==0&&i*9>=tot)return printf("%d",i),0;
}
return 0;
} | main.c:1:9: fatal error: algorithm: No such file or directory
1 | #include<algorithm>
| ^~~~~~~~~~~
compilation terminated.
|
s549769405 | p03789 | C++ | #include<bits/stdc++.h>
using namespace std;
char s[500010];
int main(){
//freopen("in","r",stdin);
//freopen("out1","w",stdout);
scanf("%s",s+1);
int n=strlen(s+1);
for(int i=1;i<=n;i++) s[i]-='0';
s[0]=0;
int p=1,ans=0,flag=1,last=0;
while(p<=n){
//printf("p=%d\n",p);
if(s[p]<s[p-1]){
//printf("fake");
//for(int i=p;i<=n;i++) printf("9");cout<<endl;
ans+=p-last;
// printf("ans=%d\n",ans);
//printf("last=%d ,%d p=%d ,%d ans=%d\n",last,s[last],p,s[p],ans);
//p=last+1;
//printf("%d",s[p-1]-1);
s[p-1]=0;
s[n]+=p-last;
for(int i=n;i>=p;i--){
if(s[i]<10) break;
s[i-1]+=s[i]/10;
s[i]%=10;
}
//cout<<endl;
flag=1;
last=p-1;
// for(int i=p;i<=n;i++) printf("%d",s[i]);cout<<endl;
// puts("------------------");
}
//printf("%d",s[p]);
if(s[p]!=s[p-1]) last=p;
p++;
}
cout<<ans+1<<endl;
r | a.cc: In function 'int main()':
a.cc:40:5: error: 'r' was not declared in this scope
40 | r
| ^
a.cc:40:6: error: expected '}' at end of input
40 | r
| ^
a.cc:4:11: note: to match this '{'
4 | int main(){
| ^
|
s513049279 | p03789 | C++ | #include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision;
int main() {
mp::cpp_int N;
cin >> N;
N *= 9;
auto check = [&](mp::cpp_int v) {
v *= 9;
auto x = (N + v).str();
for(int i = 0; i < x.size(); i++) {
v -= x[i] - '0';
if(v < 0) return false;
}
return true;
};
int ok = 5000001, ng = 0;
while(ok - ng > 1) {
int mid = (ok + ng) / 2;
if(check(mid)) ok = mid;
else ng = mid;
}
cout << ok << endl;
} | a.cc:2:10: fatal error: boost/multiprecision/cpp_int.hpp: No such file or directory
2 | #include <boost/multiprecision/cpp_int.hpp>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
|
s935760118 | p03789 | C++ | #include<bits/stdc++.h>
using namespace std;
const int N=5e5+10;
char s[N];int n;
int main()
{
gets(s+1);
n=strlen(s+1);
for (int i=1;i<=n;i++) s[i]-='0';
s[n+1]=127;
int ans=0;
for (int p=1;p<=n;){
ans++;
for (int i=p,now=0;i<=n;i++){
now=max(now,(int)s[i]);
int j=i;
while (s[j]==now) j++;
if (s[j]<now){
now--;
s[i]=0;
int j=n;
while (s[j]==9) s[j--]=0;
s[j]++;
break;
}
else{
for (;i<j;s[i++]=0);
i--;
}
}
while (!s[p]&&p<=n) p++;
}
printf("%d\n",ans);
return 0;
} | a.cc: In function 'int main()':
a.cc:7:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
7 | gets(s+1);
| ^~~~
| getw
|
s394493628 | p03789 | C++ | #include<bits/stdc++.h>
using namespace std;
long long n,num,shu[20];
long long read()
{
long long ans=0;
char ch=getchar();
while(!isdigit(ch))
ch=getchar();
for(;isdigit(ch);ch=getchar())
{
assert(ans<1000000000000000000ll);
ans=ans*10+ch-'0';
}
return ans;
}
int main()
{
n=read();
for(int i=1;i<=18;i++)
value[i]=value[i-1]*10+1;
for(int i=18;i;i--)
while(n>=value[i])
{
n-=value[i];
num++;
}
printf("%d",num/9+(num%9!=0));
} | a.cc: In function 'int main()':
a.cc:21:17: error: 'value' was not declared in this scope
21 | value[i]=value[i-1]*10+1;
| ^~~~~
a.cc:23:26: error: 'value' was not declared in this scope
23 | while(n>=value[i])
| ^~~~~
|
s741818338 | p03789 | C++ | #include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N = 500010;
char s[N];
int n,a[N],ans;
int main(){
//freopen("in.txt","r",stdin);
//scanf("%s",s);
gets(s);
n = strlen(s);
reverse(s,s+n);
for(int i=0;i<n;i++) a[i]=s[i]-'0';
a[n] = 0;
bool pd = false;
int pos = n;
for(int i=n-1;i>=0;i--){
if(a[i]<a[i+1]){
if(pd){
a[0]++;
for(int j=0;j<pos;j++)
if(a[j]>=10){
a[j+1]++;
a[j]-=10;
} else break;
ans++;
}
i = pos;
a[i] = 0;
pd=false;
} else {
if(a[i]>0) pd = true;
if(a[i]!=a[i+1]) pos = i;
}
}
ans++;
printf("%d\n",ans);
return 0;
} | a.cc: In function 'int main()':
a.cc:12:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
12 | gets(s);
| ^~~~
| getw
|
s520017461 | p03789 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 500010;
char s[N];
int n,a[N],ans;
int main(){
//freopen("in.txt","r",stdin);
//scanf("%s",s);
gets(s);
n = strlen(s);
reverse(s,s+n);
for(int i=0;i<n;i++) a[i]=s[i]-'0';
a[n] = 0;
bool pd = false;
int pos = n;
for(int i=n-1;i>=0;i--){
if(a[i]<a[i+1]){
if(pd){
a[0]++;
for(int j=0;j<pos;j++)
if(a[j]>=10){
a[j+1]++;
a[j]-=10;
} else break;
ans++;
}
i = pos;
a[i] = 0;
pd=false;
} else {
if(a[i]>0) pd = true;
if(a[i]!=a[i+1]) pos = i;
}
}
ans++;
printf("%d\n",ans);
return 0;
} | a.cc: In function 'int main()':
a.cc:10:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
10 | gets(s);
| ^~~~
| getw
|
s026605300 | p03789 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 500010;
char s[N];
int n,a[N],ans;
int main(){
//freopen("in.txt","r",stdin);
//scanf("%s",s);
gets(s);
n = strlen(s);
reverse(s,s+n);
for(int i=0;i<n;i++) a[i]=s[i]-'0';
a[n] = 0;
bool pd = false;
int pos = n;
for(int i=n-1;i>=0;i--){
if(a[i]<a[i+1]){
if(pd){
a[0]++;
for(int j=0;j<pos;j++)
if(a[j]>=10){
a[j+1]++;
a[j]-=10;
} else break;
ans++;
}
i = pos;
a[i] = 0;
pd=false;
} else {
if(a[i]>0) pd = true;
if(a[i]!=a[i+1]) pos = i;
}
}
ans++;
printf("%d\n",ans);
return 0;
} | a.cc: In function 'int main()':
a.cc:10:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
10 | gets(s);
| ^~~~
| getw
|
s303762354 | p03789 | Java | #include <bits/stdc++.h>
using namespace std;
#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define FORalld(it, a) for (__typeof((a).rbegin()) it = (a).rbegin(); it != (a).rend(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
template<class T> inline T isqrt(T k) {T r = sqrt(k) + 1; while (r * r > k) r--; return r;}
template<class T> inline T icbrt(T k) {T r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
const int maxn = 5e5 + 5;
int n;
int a[maxn];
int stmx[maxn << 1];
int stmn[maxn << 1];
void updmx(int st[], int p, int val) {
for (st[p += n] = val; p > 1; ) p >>= 1, st[p] = max(st[p << 1], st[p << 1 | 1]);
}
int querymx(int st[], int l, int r) {
int res = -INF;
for (l += n, r += n + 1; l < r; l >>= 1, r >>= 1) {
if (l & 1) chkmax(res, st[l++]);
if (r & 1) chkmax(res, st[--r]);
}
return res;
}
void updmn(int st[], int p, int val) {
for (st[p += n] = val; p > 1; ) p >>= 1, st[p] = min(st[p << 1], st[p << 1 | 1]);
}
int querymn(int st[], int l, int r) {
int res = +INF;
for (l += n, r += n + 1; l < r; l >>= 1, r >>= 1) {
if (l & 1) chkmin(res, st[l++]);
if (r & 1) chkmin(res, st[--r]);
}
return res;
}
void solve() {
string s; cin >> s;
n = sz(s);
FOR(i, 0, n) a[i] = s[i] - '0';
FOR(i, 0, n - 1) updmx(stmx, i, a[i] - a[i + 1]);
FOR(i, 0, n - 1) updmn(stmn, i, a[i] - a[i + 1]);
int ans = 0, ptr = 0;
while (ptr < n) {
ans++;
if (querymx(stmx, ptr, n - 2) <= 0) {
break;
}
int lo = ptr, hi = n - 2;
while (lo < hi) {
int mi = lo + hi >> 1;
if (querymx(stmx, ptr, mi) <= 0) {
lo = mi + 1;
}
else {
hi = mi;
}
}
int nptr = lo + hi >> 1;
lo = ptr, hi = nptr;
while (lo < hi) {
int mi = lo + hi + 1 >> 1;
if (querymn(stmn, mi - 1, nptr - 1) < 0) {
lo = mi;
}
else {
hi = mi - 1;
}
}
ptr = (lo + hi >> 1) + 1;
int rem = 1;
for (int i = n - 1; i >= nptr; i--) {
a[i] += rem;
rem = a[i] % 10;
a[i] /= 10;
if (!rem) break;
}
}
cout << ans << "\n";
}
int main() {
#ifdef _LOCAL_
freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout);
#else
ios_base::sync_with_stdio(0); cin.tie(0);
#endif
solve();
cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s\n";
return 0;
}
| Main.java:1: error: illegal character: '#'
#include <bits/stdc++.h>
^
Main.java:1: error: class, interface, enum, or record expected
#include <bits/stdc++.h>
^
Main.java:4: error: illegal character: '#'
#define ms(s, n) memset(s, n, sizeof(s))
^
Main.java:4: error: class, interface, enum, or record expected
#define ms(s, n) memset(s, n, sizeof(s))
^
Main.java:5: error: illegal character: '#'
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
^
Main.java:5: error: class, interface, enum, or record expected
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
^
Main.java:5: error: class, interface, enum, or record expected
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
^
Main.java:6: error: illegal character: '#'
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
^
Main.java:6: error: class, interface, enum, or record expected
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
^
Main.java:6: error: class, interface, enum, or record expected
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
^
Main.java:7: error: illegal character: '#'
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
^
Main.java:7: error: class, interface, enum, or record expected
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
^
Main.java:7: error: class, interface, enum, or record expected
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
^
Main.java:8: error: illegal character: '#'
#define FORalld(it, a) for (__typeof((a).rbegin()) it = (a).rbegin(); it != (a).rend(); it++)
^
Main.java:8: error: class, interface, enum, or record expected
#define FORalld(it, a) for (__typeof((a).rbegin()) it = (a).rbegin(); it != (a).rend(); it++)
^
Main.java:8: error: class, interface, enum, or record expected
#define FORalld(it, a) for (__typeof((a).rbegin()) it = (a).rbegin(); it != (a).rend(); it++)
^
Main.java:9: error: illegal character: '#'
#define sz(a) int((a).size())
^
Main.java:10: error: illegal character: '#'
#define present(t, x) (t.find(x) != t.end())
^
Main.java:11: error: illegal character: '#'
#define all(a) (a).begin(), (a).end()
^
Main.java:12: error: illegal character: '#'
#define uni(a) (a).erase(unique(all(a)), (a).end())
^
Main.java:13: error: illegal character: '#'
#define pb push_back
^
Main.java:14: error: illegal character: '#'
#define pf push_front
^
Main.java:15: error: illegal character: '#'
#define mp make_pair
^
Main.java:16: error: illegal character: '#'
#define fi first
^
Main.java:17: error: illegal character: '#'
#define se second
^
Main.java:18: error: illegal character: '#'
#define prec(n) fixed<<setprecision(n)
^
Main.java:19: error: illegal character: '#'
#define bit(n, i) (((n) >> (i)) & 1)
^
Main.java:20: error: illegal character: '#'
#define bitcount(n) __builtin_popcountll(n)
^
Main.java:22: error: class, interface, enum, or record expected
typedef unsigned long long ull;
^
Main.java:23: error: class, interface, enum, or record expected
typedef long double ld;
^
Main.java:24: error: class, interface, enum, or record expected
typedef pair<int, int> pi;
^
Main.java:25: error: class, interface, enum, or record expected
typedef vector<int> vi;
^
Main.java:26: error: class, interface, enum, or record expected
typedef vector<pi> vii;
^
Main.java:27: error: class, interface, enum, or record expected
const int MOD = (int) 1e9 + 7;
^
Main.java:28: error: class, interface, enum, or record expected
const int INF = (int) 1e9;
^
Main.java:29: error: class, interface, enum, or record expected
const ll LINF = (ll) 1e18;
^
Main.java:30: error: class, interface, enum, or record expected
const ld PI = acos((ld) -1);
^
Main.java:31: error: class, interface, enum, or record expected
const ld EPS = 1e-9;
^
Main.java:32: error: class, interface, enum, or record expected
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
^
Main.java:32: error: class, interface, enum, or record expected
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
^
Main.java:32: error: class, interface, enum, or record expected
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
^
Main.java:32: error: class, interface, enum, or record expected
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
^
Main.java:32: error: class, interface, enum, or record expected
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
^
Main.java:32: error: class, interface, enum, or record expected
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
^
Main.java:33: error: class, interface, enum, or record expected
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
^
Main.java:34: error: class, interface, enum, or record expected
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
^
Main.java:34: error: class, interface, enum, or record expected
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
^
Main.java:34: error: class, interface, enum, or record expected
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
^
Main.java:34: error: class, interface, enum, or record expected
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
^
Main.java:34: error: class, interface, enum, or record expected
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
^
Main.java:34: error: class, interface, enum, or record expected
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
^
Main.java:35: error: '{' expected
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
^
Main.java:35: error: unnamed classes are a preview feature and are disabled by default.
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
^
(use --enable-preview to enable unnamed classes)
Main.java:35: error: <identifier> expected
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
^
Main.java:35: error: : expected
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
^
Main.java:36: error: class, interface, enum, or record expected
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
^
Main.java:36: error: '{' expected
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
^
Main.java:36: error: <identifier> expected
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
^
Main.java:36: error: : expected
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
^
Main.java:37: error: class, interface, enum, or record expected
template<class T> inline T isqrt(T k) {T r = sqrt(k) + 1; while (r * r > k) r--; return r;}
^
Main.java:37: error: '{' expected
template<class T> inline T isqrt(T k) {T r = sqrt(k) + 1; while (r * r > k) r--; return r;}
^
Main.java:37: error: illegal start of type
template<class T> inline T isqrt(T k) {T r = sqrt(k) + 1; while (r * r > k) r--; return r;}
^
Main.java:37: error: <identifier> expected
template<class T> inline T isqrt(T k) {T r = sqrt(k) + 1; while (r * r > k) r--; return r;}
^
Main.java:37: error: <identifier> expected
template<class T> inline T isqrt(T k) {T r = sqrt(k) + 1; while (r * r > k) r--; return r;}
^
Main.java:37: error: <identifier> expected
template<class T> inline T isqrt(T k) {T r = sqrt(k) + 1; while (r * r > k) r--; return r;}
^
Main.java:37: error: <identifier> expected
template<class T> inline T isqrt(T k) {T r = sqrt(k) + 1; while (r * r > k) r--; return r;}
^
Main.java:37: error: illegal start of type
template<class T> inline T isqrt(T k) {T r = sqrt(k) + 1; while (r * r > k) r--; return r;}
|
s042891310 | p03789 | C++ | import java.io.*;
import java.util.*;
import java.math.*;
public class Main {
Input in;
PrintWriter out;
final static int INF = (int) 1e9;
final static int MOD = (int) 1e9 + 7;
final static long LINF = (long) 1e18;
final static double PI = (double) Math.acos(-1.0);
final static double EPS = (double) 1e-9;
void solve() {
BigInteger A = new BigInteger(in.nextString());
int ans = 0;
while (A.compareTo(BigInteger.ZERO) > 0) {
ans++;
String S = A.toString();
String T = "";
for (int i = 0; i < S.length() - 1; i++) {
if (S.charAt(i) > S.charAt(i + 1)) {
for (int j = i; j >= 0; j--) {
if (j == 0 || S.charAt(j - 1) < S.charAt(j)) {
for (int k = 0; k < j; k++) {
T += S.charAt(k);
}
T += S.charAt(j) - '0' - 1;
for (int k = j + 1; k < S.length(); k++) {
T += 9;
}
break;
}
}
break;
}
}
if (T.equals("")) T = S;
BigInteger B = new BigInteger(T);
A = A.subtract(B);
}
out.println(ans);
}
public static void main(String[] args) {
(new Main()).run();
}
public void run() {
in = new Input();
try {
out = new PrintWriter(System.out);
//out = new PrintWriter(new FileWriter("a.out"));
}
catch (Exception ex) {
}
long stime = System.currentTimeMillis();
//int test = in.nextInt(); while (test-- > 0)
solve();
//if (System.getProperty("ONLINE_JUDGE") == null) {
// out.println("\nTime elapsed: " + (System.currentTimeMillis() - stime) + "ms");
//}
out.close();
}
public class Input {
private StringTokenizer token = null;
private BufferedReader in;
public Input() {
try {
if (System.getProperty("ONLINE_JUDGE") == null) {
in = new BufferedReader(new InputStreamReader(System.in));
//in = new BufferedReader(new FileReader("in.txt"));
}
else {
in = new BufferedReader(new InputStreamReader(System.in));
}
}
catch (Exception ex) {
}
}
public int nextInt() {
return Integer.parseInt(nextString());
}
public long nextLong() {
return Long.parseLong(nextString());
}
public double nextDouble() {
return Double.parseDouble(nextString());
}
String nextString() {
try {
while (token == null || !token.hasMoreTokens()) {
token = new StringTokenizer(in.readLine());
}
}
catch (IOException e) {
}
return token.nextToken();
}
}
} | a.cc:1:1: error: 'import' does not name a type
1 | import java.io.*;
| ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
2 | import java.util.*;
| ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
3 | import java.math.*;
| ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: expected unqualified-id before 'public'
5 | public class Main {
| ^~~~~~
|
s760628988 | p03789 | C++ | #include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 500000 + 10;
int n, not_zero;
char s[maxn];
void addone(void) {
for (int i = n - 1; i >= not_zero; --i) {
if (s[i] != '9') {
++s[i];
break;
} else {
s[i] = '0';
}
}
}
int main(void) {
while (isdigit(s[n] = getchar())) ++n;
int ans = not_zero = 0;
while (not_zero < n) {
int begin = not_zero;
for (int i = not_zero + 1; i < n; ++i) {
if (s[i] > s[begin]) {
begin = i;
} else if (s[i] < s[begin]) {
not_zero = begin + 1;
addone();
++ans;
begin = -1;
break;
}
}
if (begin >= 0) {
++ans;
break;
}
}
printf("%d\n", ans);
return 0;
}
| a.cc: In function 'int main()':
a.cc:23:10: error: 'isdigit' was not declared in this scope
23 | while (isdigit(s[n] = getchar())) ++n;
| ^~~~~~~
|
s067408066 | p03789 | C++ | #include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 500000 + 10;
int n, not_zero;
char s[maxn];
void addone(void) {
for (int i = n - 1; i >= not_zero; --i) {
if (s[i] != '9') {
++s[i];
break;
} else {
s[i] = '0';
}
}
}
int main(void) {
gets(s);
n = strlen(s);
int ans = not_zero = 0;
while (not_zero < n) {
int begin = not_zero;
for (int i = not_zero + 1; i < n; ++i) {
if (s[i] > s[begin]) {
begin = i;
} else if (s[i] < s[begin]) {
not_zero = begin + 1;
addone();
++ans;
begin = -1;
break;
}
}
if (begin >= 0) {
++ans;
break;
}
}
printf("%d\n", ans);
return 0;
}
| a.cc: In function 'int main()':
a.cc:23:3: error: 'gets' was not declared in this scope; did you mean 'getw'?
23 | gets(s);
| ^~~~
| getw
|
s228565601 | p03789 | C++ | #include <stdio.h>
#include <iostream>
#include <string>
using namespace std;
string strInc(string N)
{
int i = N.size()-1;
while (1){
//cout << N << endl;
if (N[i] == '9'){
N[i] = '0';
if (i == 0){
N = "1" + N;
break;
}
else{
i--;
}
}
else{
N[i]++;
break;
}
}
return N;
}
void main()
{
string N;
int X[100];
cin >> N;
//cout << N << endl;
//cout << strInc(N)<< endl;
//N = "7204647845201772120166980358816078279571541735614841625060678056933503";
//N = "20170312";
//N = "123456789";
//N = "80";
//N = "678056933528";
//N = "9998";
int cnt = 1;
bool flg = true;
cout << N << endl;
for (int i= 0; i < N.size()-1; i++){
if (N[i] > N[i + 1]){
cnt++;
N = strInc(N);
for (int j = 0; j <= i; j++){
cout << " ";
}
for (int j = i + 1; j < N.size(); j++){
cout << N[j];
}
cout << endl;
}
}
cout << cnt<< endl;
}
| a.cc:34:1: error: '::main' must return 'int'
34 | void main()
| ^~~~
|
s756295352 | p03789 | Java | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Random;
import java.util.StringTokenizer;
/**
* @author Pavel Mavrin
*/
public class E {
private void solve() throws IOException {
String s = next();
z = true;
out.println(solve(s));
// Random random = new Random();
// while (true) {
// String s = "" + Math.abs(random.nextLong()) + Math.abs(random.nextLong()) + Math.abs(random.nextLong());
// System.out.println(s);
// z = false;
// int s1 = solve(s);
// z = true;
// int s2 = solve(s);
// if (s1 != s2) {
// System.out.println(s + " " + s1 + " " + s2);
// return;
// }
// }
}
private int solve(String s) {
long l = 0;
long r = 1;
while (!can(s, r)) r *= 2;
while (r > l + 1) {
long m = (l + r) / 2;
if (can(s, m)) {
r = m;
} else {
l = m;
}
}
return (int) r;
}
boolean z = false;
private boolean can(String s, long q) {
q *= 9;
long ss = 0;
for (int i = s.length() - 1; i >= 0; i--) {
int d = s.charAt(i) - '0';
// d - (q / 10) + 10 * k <= q
// k <= (q - d + (q / 10)) / 10
long max = q;
if (z) {
if (i < 18) {
max = Math.min(max, Long.parseLong(s.substring(0, i + 1)) - ss);
}
}
if (max - d + ss < 0) return false;
long k = (max - d + ss) / 10;
long qq = d + k * 10 - ss;
if (qq > max) throw new RuntimeException();
q = qq;
ss = q / 10;
}
return true;
}
// ------------------
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
PrintWriter out = new PrintWriter(System.out);
String next() throws IOException {
while (st == null || !st.hasMoreTokens()) {
st = new StringTokenizer(br.readLine());
}
return st.nextToken();
}
int nextInt() throws IOException {
return Integer.parseInt(next());
}
public static void main(String[] args) throws IOException {
new E().run();
}
private void run() throws IOException {
solve();
out.close();
}
}
| Main.java:11: error: class E is public, should be declared in a file named E.java
public class E {
^
1 error
|
s184338035 | p03790 | C++ | #include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
const int INF=1001001001001001001ll;
struct segtree{
static const int SEG=1<<17;
vint dat;
segtree():dat(SEG*2,INF),put(SEG*2,INF){}
inline void push(int k){
chmin(dat[k],put[k]);
if(k<SEG-1){
chmin(put[k*2+1],put[k]);
chmin(put[k*2+2],put[k]);
}
}
void update(int a,int b,int x,int k=0,int l=0,int r=SEG){
push(k);
if(r<=a||b<=l)return;
if(a<=l&&r<=b){
put[k]=x;
push(k);
return;
}
update(a,b,x,k*2+1,l,(l+r)/2);
update(a,b,x,k*2+2,(l+r)/2,r);
dat[k]=min(dat[k*2+1],dat[k*2+2]);
}
int query(int a,int b,int k=0,int l=0,int r=SEG){
push(k);
if(r<=a||b<=l)return INF;
if(a<=l&&r<=b)return dat[k];
return min(query(a,b,k*2+1,l,(l+r)/2),query(a,b,k*2+2,(l+r)/2,r));
}
};
int N,K;
int A[111111],B[111111];
int S[111111];
int to[20][111111],cost[20][111111];
signed main(){
cin>>N>>K;
rep(i,N){
cin>>A[i]>>B[i];
A[i]*=2;
}
rep(i,N){
if(A[i]>K){
cout<<-1<<endl;
return 0;
}
}
rep(i,N)S[i+1]=S[i]+A[i];
vint lis;
rep(i,N+1)lis.pb(S[i]%K);
sort(all(lis));lis.erase(unique(all(lis)),lis.end());
rep(i,20)to[i][N]=N;
segtree seg;
for(int i=N-1;i>=0;i--){
int w=lower_bound(all(lis),S[i]%K)-lis.begin();
int z=seg.qeury(w,w+1);
if(z==INF){
to[0][i]=N;
cost[0][i]=sum[N]-sum[i]
}
else{
to[0][i]=z;
cost[0][i]=(sum[z]-sum[i])/K+1;
}
for(int j=0;j<19;j++){
to[j+1][i]=to[j][to[j][i]];
cost[j+1][i]=cost[j][i]+cost[j][to[j][i]];
}
if(B[i]==1){
int l=lower_bound(all(lis),S[i]%K)-lis.begin();
int r=lower_bound(all(lis),S[i+1]%K)-lis.begin();
if(l<r){
seg.update(l+1,r,i);
}
else{
seg.update(l+1,lis.size(),i);
seg.update(0,r,i);
}
}
}
rep(i,lis.size()){
if(seg.qery(i,i+1)==INF){
cout<<S[N]<<endl;
return 0;
}
}
assert(0);
return 0;
} | a.cc: In constructor 'segtree::segtree()':
a.cc:23:30: error: class 'segtree' does not have any field named 'put'
23 | segtree():dat(SEG*2,INF),put(SEG*2,INF){}
| ^~~
a.cc: In member function 'void segtree::push(long long int)':
a.cc:25:22: error: 'put' was not declared in this scope; did you mean 'putw'?
25 | chmin(dat[k],put[k]);
| ^~~
| putw
a.cc: In member function 'void segtree::update(long long int, long long int, long long int, long long int, long long int, long long int)':
a.cc:35:13: error: 'put' was not declared in this scope; did you mean 'putw'?
35 | put[k]=x;
| ^~~
| putw
a.cc: In function 'int main()':
a.cc:78:19: error: 'struct segtree' has no member named 'qeury'; did you mean 'query'?
78 | int z=seg.qeury(w,w+1);
| ^~~~~
| query
a.cc:81:24: error: 'sum' was not declared in this scope
81 | cost[0][i]=sum[N]-sum[i]
| ^~~
a.cc:85:25: error: 'sum' was not declared in this scope
85 | cost[0][i]=(sum[z]-sum[i])/K+1;
| ^~~
a.cc:105:16: error: 'struct segtree' has no member named 'qery'; did you mean 'query'?
105 | if(seg.qery(i,i+1)==INF){
| ^~~~
| query
|
s488499176 | p03790 | C++ | #define NDEBUG
#include <bits/stdc++.h>
#include <windows.h>
#define mset(a,b) memset(a,b,sizeof a)
#define mcpy(a,b) memcpy(a,b,sizeof b)
#define xx first
#define yy second
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define pii pair<int,int>
#define lb(x) ((x)&(-(x)))
#define dalao 1000000007
#define inf 0x3f3f3f3f
#define N 200005
using namespace std;
typedef long long ll;
int n,K,a[N],b[N],mi[N<<2];
ll s,l[N],r[N],x[N],num,f[N],tot,ans=1ll*inf*inf;
inline void modify(int x,int l,int r,int L,int R,int v){
if(l>r)return;
if(l==L&&r==R){mi[x]=v;return;}
int mid=L+R>>1;
if(r<=mid)modify(x<<1,l,r,L,mid,v);
else if(l>mid)modify(x<<1|1,l,r,mid+1,R,v);
else modify(x<<1,l,mid,L,mid,v),modify(x<<1|1,mid+1,r,mid+1,R,v);
}
inline int ask(int x,int p,int l,int r){
if(l==r)return mi[x];
int mid=l+r>>1;
if(p<=mid)return min(ask(x<<1,p,l,mid),mi[x]);
return min(ask(x<<1|1,p,mid+1,r),mi[x]);
}
int main(){
scanf("%d%d",&n,&K);
for(int i=1;i<=n;i++)scanf("%d%d",&a[i],&b[i]),tot+=a[i]<<1;
for(int i=1;i<=n;i++){
if(b[i]==1&&a[i]*2>K)return puts("-1"),0;
if(b[i]==1)l[i]=s,r[i]=((s-2*a[i])%K+K)%K,x[++num]=l[i],x[++num]=r[i];
else l[i]=0,r[i]=K-1;
s=(s-2*a[i]%K+K)%K;
// cout<<l[i]<<" "<<r[i]<<endl;
}
sort(x+1,x+1+num),num=unique(x+1,x+1+num)-x-1;
for(int i=1;i<=n;i++)
l[i]=lower_bound(x+1,x+1+num,l[i])-x,r[i]=lower_bound(x+1,x+1+num,r[i])-x;
for(int i=1;i<=(num<<2);i++)mi[i]=n+1;
for(int i=n;i;i--){
int t=ask(1,l[i],1,num);
if(t^n+1)f[i]=f[t]+(x[l[t]]-x[l[i]]+K)%K;
if(l[i]<=r[i])modify(1,r[i]+1,num,1,num,i),modify(1,1,l[i]-1,1,num,i);
else modify(1,r[i]+1,l[i]-1,1,num,i);
// cout<<l[i]<<" "<<r[i]<<" "<<t<<" "<<f[i]<<endl;
}
for(int i=1;i<=num;i++){
int t=ask(1,i,1,num);
if(t<=n)ans=min(ans,f[t]+((x[l[t]]-x[i])%K+K)%K);
else ans=0;
}
if(ans>=1ll*inf*inf)puts("-1");
else cout<<ans+tot;
return 0;
} | a.cc:3:10: fatal error: windows.h: No such file or directory
3 | #include <windows.h>
| ^~~~~~~~~~~
compilation terminated.
|
s418874345 | p03790 | C++ | #include <cstdio>
#include <algorithm>
#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
using namespace std;
typedef long long LL;
const int N = 100010;
int t[N * 8];
int num = 0;
void build(int x, int l, int r)
{
t[x] = 2e9;
if (l == r) return;
int mid = (l + r) >> 1;
build(x << 1, l, mid); build(x << 1 | 1, mid + 1, r);
}
void modify(int x, int l, int r, int a, int b, int c)
{
if (a > b) return;
if (a <= l && r <= b){ t[x] = c; return;}
int mid = (l + r) >> 1;
if (a <= mid) modify(x << 1, l, mid, a, b, c);
if (b > mid) modify(x << 1 | 1, mid + 1, r, a, b, c);
}
int query(int x, int l, int r, int a)
{
int ret = t[x];
if (l == r) return ret;
int mid = (l + r) >> 1;
if (a <= mid) ret = min(ret, query(x << 1, l, mid, a));
else ret = min(ret, query(x << 1 | 1, mid + 1, r, a));
return ret;
}
int b[N], cnt;
LL L[N], R[N], s[N], f[N], a[N], h[N];
int main()
{
int n, k;
scanf("%d%d", &n, &k);
Rep(i, n) scanf("%lld%d", &a[i], &b[i]);
Rep(i, n){
if (b[i] == 1 && a[i] * 2 > k) { printf("-1\n"); return 0;}
a[i] += a[i - 1], s[i] = a[i] % k;
if (b[i] == 1){
L[i] = ((-s[i - 1] * 2) % k + k) % k, h[++ cnt] = L[i];
R[i] = ((-s[i] * 2) % k + k) % k, h[++ cnt] = R[i];
}
}
h[++ cnt] = 0, h[++ cnt] = k - 1;
sort(h + 1, h + 1 + cnt);
cnt = unique(h + 1, h + 1 + cnt) - h - 1;
Rep(i, n) if (b[i] == 1) {
L[i] = lower_bound(h + 1, h + 1 + cnt, L[i]) - h;
R[i] = lower_bound(h + 1, h + 1 + cnt, R[i]) - h;
}
build(1, 1, cnt);//printf("%d\n", cnt);
for (int i = n; i; i --) if (b[i] == 1) {
int tmp = query(1, 1, cnt, L[i]);
if (tmp != 2e9) f[i] = f[tmp] + (h[L[tmp]] - h[L[i]] + k) % k;
else f[i] = 0;
if (L[i] <= R[i]){
modify(1, 1, cnt, 1, L[i] - 1, i);
modify(1, 1, cnt, R[i] + 1, cnt, i);
}
else modify(1, 1, cnt, R[i] + 1, L[i] - 1, i);
}
LL ans = 1e18;
Rep(i, n) if (b[i] == 1){
int tmp = query(1, 1, cnt, L[i]);
if (tmp != 2e9) ans = min(ans, f[tmp] + (h[L[tmp]] - h[L[i]] + k) % k);
else ans = 0;
tmp = query(1, 1, cnt, R[i]);
if (tmp != 2e9) ans = min(ans, f[tmp] + (h[L[tmp]] - h[R[i]] + k) % k);
else ans = 0;A
}
printf("%lld\n", ans + a[n] * 2);
return 0;
} | a.cc: In function 'int main()':
a.cc:80:30: error: 'A' was not declared in this scope
80 | else ans = 0;A
| ^
|
s239200215 | p03791 | C++ | #include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define int ll
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a) rep2(i,0,a-1)
main(){
int n;cin>>n;
vector<int> v;
rep(i,n){int x;cin>>x;v.push_back(x);}
int now=0;
ll ans=1;
rep(i,n){
while(now<n and x[now]>(now-i)*2)now++;
ans=(ans*(now+1-i))%1000000007ll;
}
cout<<ans;
} | a.cc:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
9 | main(){
| ^~~~
a.cc: In function 'int main()':
a.cc:16:19: error: 'x' was not declared in this scope
16 | while(now<n and x[now]>(now-i)*2)now++;
| ^
|
s463003137 | p03791 | C++ | oxoxoxoxoxoxoxoxoxoxoo
11223344
01234567
9*
#include <bits/stdc++.h>
#define range(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, b) for (int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x) cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;
template <typename X, typename T>
auto vectors(X x, T a) {
return vector<T>(x, a);
}
template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
auto cont = vectors(y, z, zs...);
return vector<decltype(cont)>(x, cont);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
rep(i, v.size()) { os << v[i] << (i == v.size() - 1 ? "" : " "); }
return os;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
for (T& x : v) { is >> x; }
return is;
}
const int M = 1000000007;
signed main() {
int n;
cin >> n;
int ans = 1;
int f = 0;
rep(i, n) {
int a;
cin >> a;
//cout << (a + 1) / 2 << ' ' << f << endl;
if ((a + 1) / 2 <= f)
ans *= f + 1;
else
f++;
}
rep(i, f) {
ans *= i + 1;
ans %= M;
}
cout << ans << endl;
}
| a.cc:1:1: error: 'oxoxoxoxoxoxoxoxoxoxoo' does not name a type
1 | oxoxoxoxoxoxoxoxoxoxoo
| ^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:62,
from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:5:
/usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity
164 | __is_null_pointer(std::nullptr_t)
| ^
/usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)'
159 | __is_null_pointer(_Type)
| ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'?
164 | __is_null_pointer(std::nullptr_t)
| ^~~~~~~~~
In file included from /usr/include/c++/14/cstddef:50,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:41:
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: 'nullptr_t' declared here
443 | typedef decltype(nullptr) nullptr_t;
| ^~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'?
666 | struct is_null_pointer<std::nullptr_t>
| ^~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: 'nullptr_t' declared here
443 | typedef decltype(nullptr) nullptr_t;
| ^~~~~~~~~
/usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid
666 | struct is_null_pointer<std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid
670 | struct is_null_pointer<const std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid
674 | struct is_null_pointer<volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid
678 | struct is_null_pointer<const volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^
/usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1438 | : public integral_constant<std::size_t, 0> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid
1438 | : public integral_constant<std::size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared
1440 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope
1441 | struct rank<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid
1441 | struct rank<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared
2086 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope
2087 | struct remove_extent<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid
2087 | struct remove_extent<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared
2099 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope
2100 | struct remove_all_extents<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid
2100 | struct remove_all_extents<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared
2171 | template<std::size_t _Len>
| ^~~
/usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope
2176 | unsigned char __data[_Len];
| ^~~~
/usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared
2194 | template<std::size_t _Len, std::size_t _Align =
| ^~~
/usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared
2194 | template<std::size_t _Len, std::size_t _Align =
| ^~~
/usr/include/c++/14/type_traits:2195:55: error: '_Len' was not declared in this scope
2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)>
| ^~~~
/usr/include/c++/14/type_traits:2195:59: error: template argument 1 is invalid
2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)>
| ^
/usr/include/c++/14/type_traits:2202:30: error: '_Len' was not declared in this scope
2202 | unsigned char __data[_Len];
| ^~~~
/usr/include/c++/14/type_traits:2203:44: error: '_Align' was not declared in this scope
2203 | struct __attribute__((__aligned__((_Align)))) { } __align;
| ^~~~~~
In file included from /usr/include/c++/14/bits/stl_tempbuf.h:59,
from /usr/include/c++/14/bits/stl_algo.h:69,
from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/new:131:26: error: declaration of 'operator new' as non-function
131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~~~
/usr/include/c++/14/new:131:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:132:41: error: attributes after parenthesized initializer ignored [-fpermissive]
132 | __attribute__((__externally_visible__));
| ^
/usr/include/c++/14/new:133:26: error: declaration of 'operator new []' as non-function
133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~~~
/usr/include/c++/14/new:133:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:134:41: error: attributes after parenthesized initializer ignored [-fpermissive]
134 | __attribute__((__externally_visible__));
|
s693957492 | p03791 | C++ | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
ll lmax(ll a,ll b){
if(a<b)return b;
else return a;
}
ll lmin(ll a,ll b){
if(a<b)return a;
else return b;
}
ll n;
vector<ll> v;
ll f(ll k){
ll ki=v[k-1];
ll now=ki+1;
ll ret=n;
rep(i,k,n+1){
if(v[i]>=now){
now+=2;
}
else{
ret=i;
break;
}
}
return ret;
}
int main(){
cin>>n;
v.clear();
v.push_back(0);
rep(i,0,n){
ll u;cin>>u;
v.push_back(u);
}
ll now=1;
ll ans=1;
ll cnt=0;
for(;;){
ll g=f(v,now);
if(g==n){
if(n==cnt)break;
rrep(i,n-cnt,1){
ans*=i;
ans%=mod;
}
break;
}
ans*=(g-cnt+mod)%mod;
cnt++;
now=g+1;
ans%=mod;
}
cout<<ans<<endl;
}
| a.cc: In function 'int main()':
a.cc:53:16: error: cannot convert 'std::vector<long long int>' to 'll' {aka 'long long int'}
53 | ll g=f(v,now);
| ^
| |
| std::vector<long long int>
a.cc:26:9: note: initializing argument 1 of 'll f(ll)'
26 | ll f(ll k){
| ~~~^
|
s930443132 | p03791 | C++ | #include <iostream>
#include <string>
using namespace std;
int main(){
int N,a,b;
string str;
cin>>str>>N;
for (int i=0;i<N;i++){
string stre(joi);
cin>>a>>b;
for (int j=a-1;j<b;j++) stre+=str[j];
int key=0;
int jk=0;
int si=b-a+1;
while(si!=0){
jk=0;
for (key=0;key<si;key++){
if (stre[key]==stre[key+1]&&stre[key]!='z'){
stre[key]+=1;
for (int i=key+1;i<stre.size();i++) stre[i]=stre[i+1];
si-=1;
jk=1;
break;
}
else if (stre[key]==stre[key+1]&&stre[key]=='z'){
for (int i=key;i<si;i++) stre[i]=stre[i+2];
si-=2;
jk=1;
break;
}
}
if (jk==0) break;
}
if (jk!=0) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:9:29: error: 'joi' was not declared in this scope
9 | string stre(joi);
| ^~~
|
s605757146 | p03791 | C++ | #include<stdio.h>
long long N,r[100006];
long long sum=1;
int main(){
scanf("%lld",&N);
for(int i=0;i<N;i++){
scanf("%lld",&r[i])
}
int j=0;
for(int i=0;i<N;i++){
for(j;j<N&&2*(j-i)+1<r[j];j++);
sum*=j;
sum%=1000000007;
}
printf("%lld",sum);
return 0;
} | a.cc: In function 'int main()':
a.cc:9:36: error: expected ';' before '}' token
9 | scanf("%lld",&r[i])
| ^
| ;
10 | }
| ~
|
s759373713 | p03791 | C++ | #include<stdio.h>
long long N,r[100006];
long long sum=1;
int main(){
scanf("%d",&N);
for(int i=0;i<N;i++){
scanf("%d",&r[i])
}
int j=0;
for(int i=0;i<N;i++){
for(j;j<N&&2*(j-i)+1<r[j];j++);
sum*=j;
sum%=1000000007;
}
printf("%d",sum);
return 0;
} | a.cc: In function 'int main()':
a.cc:9:34: error: expected ';' before '}' token
9 | scanf("%d",&r[i])
| ^
| ;
10 | }
| ~
|
s250051012 | p03791 | C | #include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<string>
#include<sstream>
#include<cctype>
#include<map>
#include<stack>
#include<queue>
#include<cstdlib>
#include<ctime>
using namespace std;
#define INF 0x3f3f3f3f
typedef long long ll;
int gcd(int a, int b){return b==0?a:gcd(b,a%b);}
const int MOD = 1e9 + 7;
int main()
{
// freopen("input1.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
int n, x, k = 0;
ll ans = 1;
scanf("%d", &n);
while(n--)
{
scanf("%d", &x);
k++;
if(x < 2 * k - 1)
{
ans = ans * k % MOD;
k--;
}
}
for(int i = 2; i <= k; i++)
ans = ans * i % MOD;
printf("%d\n", (int)ans);
return 0;
} | main.c:1:9: fatal error: cstdio: No such file or directory
1 | #include<cstdio>
| ^~~~~~~~
compilation terminated.
|
s489390682 | p03791 | C++ | #include<bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int n, a[100005];
int main() {
scanf("%d", &n);
for( int i = 0; i < n; i++ ) scanf("%d", &a[i]);
int ans = 1, t = 0;
for( int i = 0; i < n; i++ ){
while( t<n && a[t] > (t-i)*2 ) t++;
if( t<n && a[t]==(t-i)*2 ) t++;
ans = 1LL*ans*(t-i)%mod;
}
printf("%d\n", ans);
ansurn 0;
} | a.cc: In function 'int main()':
a.cc:15:9: error: 'ansurn' was not declared in this scope
15 | ansurn 0;
| ^~~~~~
|
s226931406 | p03791 | C++ | #include <cstdlib>
#include <iostream>
int main(void) {
int n;
while (std::cin >> n) {
const int mod = 1000000007;
int stack = 0, *arr;
long long ans = 1;
arr = new int[n];
for (int i = 0; i < n; ++i) {
std::cin >> arr[i];
}
for (int i = 0; i < n; ++i) {
if (arr[i] < 2 * ++stack - 1) {
ans *= stack--;
ans %= mod;
}
}
for (int i = 0; i < value; ++i) {
ans *= i + 1;
ans %= mod;
}
std::cout << ans << std::endl;
delete[] arr;
}
return EXIT_SUCCESS;
} | a.cc: In function 'int main()':
a.cc:19:37: error: 'value' was not declared in this scope
19 | for (int i = 0; i < value; ++i) {
| ^~~~~
|
s625743662 | p03791 | C++ | #include <cstdlib>
#include <iostream>
int main(void) {
const long long mod = 1000000007;
int n;
while (std::cin >> n) {
long long ans = 1, stack = 0, *arr, *cnt;
int fail = 0;
arr = new long long[n];
cnt = new long long[n];
for (int i = 0; i < n; ++i) {
std::cin >> arr[i];
++cnt[(fail + 1) / 2];
if(i == 0) {
arr[0] = 1;
}
else{
if(arr[i] >= arr[i - 1] + 2) {
arr[i] = arr[i - 1] + 2;
}
if(arr[i - 1] + 1 == arr[i]) {
++fail;
}
}
}
for (int i = 0; i < n; ++i) {
stack += cnt[i];
(anst *= stack) %= mod;
--stack;
}
std::cout << ans << std::endl;
delete[] arr;
delete[] cnt;
}
return EXIT_SUCCESS;
} | a.cc: In function 'int main()':
a.cc:28:26: error: 'anst' was not declared in this scope; did you mean 'ans'?
28 | (anst *= stack) %= mod;
| ^~~~
| ans
|
s848532447 | p03791 | C++ | #include <cstdlib>
#include <iostream>
int main(void) {
const long long mod = 1000000007;
int n;
while (std::cin >> n) {
long long ans = 1, stack = 0, *arr, *cnt;
int fail = 0;
arr = new long long[n];
cnt = new long long[n];
for (int i = 0; i < n; ++i) {
std::cin >> arr[i];
++cnt[(fail + 1) / 2];
if(i == 0) {
arr[0] = 1;
}
else{
if(arr[i] >= arr[i - 1] + 2) {
arr[i] = arr[i - 1] + 2;
}
if(arr[i - 1] + 1 == arr[i]) {
++fail;
}
}
}
for (int i = 0; i < n; ++i) {
stack += cnt[i];
(ret *= stack) %= mod;
--stack;
}
std::cout << ans << std::endl;
delete[] arr;
delete[] cnt;
}
return EXIT_SUCCESS;
} | a.cc: In function 'int main()':
a.cc:28:26: error: 'ret' was not declared in this scope
28 | (ret *= stack) %= mod;
| ^~~
|
s177235036 | p03791 | C++ | #include <cmath>
#include <cstdlib>
#include <iostream>
long long factorial(const long long &value) {
long long ret = 1;
for (int i = 0; i < value; ++i) {
ret *= i + 1;
}
return ret;
}
int main(void) {
const long long mod = pow(10.0, 9.0) + 7;
int n;
while (std::cin >> n) {
long long ans = 1, stack = 0, *arr;
arr = new int[n];
for (int i = 0; i < n; ++i) {
std::cin >> arr[i];
}
for (int i = 0; i < n; ++i) {
int x = arr[i];
if (x < 2 * ++stack - 1) {
ans *= stack--;
ans %= mod;
}
}
ans *= factorial(stack) % mod;
ans %= mod;
std::cout << ans << std::endl;
delete[] arr;
}
return EXIT_SUCCESS;
} | a.cc: In function 'int main()':
a.cc:16:23: error: cannot convert 'int*' to 'long long int*' in assignment
16 | arr = new int[n];
| ^~~~~~~~~~
| |
| int*
|
s865174945 | p03791 | C++ | #include <cmath>
#include <cstdlib>
#include <iostream>
int factorial(const int &value) {
int ret = 1;
for (int i = 0; i < value; ++i) {
ret *= i + 1;
}
return ret;
}
int main(void) {
const int mod = pow(10.0, 9.0) + 7;
while (std::cin >> n) {
int ans = 1, stack = 0, n, *arr;
arr = new int[n];
for (int i = 0; i < n; ++i) {
std::cin >> arr[i];
}
for (int i = 0; i < n; ++i) {
int x = arr[i];
if (x < 2 * ++stack - 1) {
ans *= stack--;
ans %= mod;
}
}
ans *= factorial(stack) % mod;
ans %= mod;
std::cout << ans << std::endl;
delete[] arr;
}
return EXIT_SUCCESS;
} | a.cc: In function 'int main()':
a.cc:13:28: error: 'n' was not declared in this scope; did you mean 'yn'?
13 | while (std::cin >> n) {
| ^
| yn
|
s059429981 | p03791 | C++ | #include <cstdio>
using namespace std;
const int mod = 1000000007;
inline
int modMultiple(int a, int b){return (static_cast<long long>(a) * b) % mod;}
int main()
{
int N;
scanf("%d\n", &N);
int result = 1;
int k = 0;
for (int i = 0; i < N; ++i){
int Xi;
scanf("%d", &Xi); getchar();
while (Xi < k * 2 + 1){
result = modMultiple(result, k + 1);
--k;
}
++k;
}
for (; k > 0; --k){
result = modMultiple(result, k);
}
printf("%d\n", result);
} | a.cc:1:1: error: '\U0000ff03include' does not name a type
1 | #include <cstdio>
| ^~~~~~~~~
a.cc: In function 'int main()':
a.cc:12:5: error: 'scanf' was not declared in this scope
12 | scanf("%d\n", &N);
| ^~~~~
a.cc:17:27: error: 'getchar' was not declared in this scope
17 | scanf("%d", &Xi); getchar();
| ^~~~~~~
a.cc:1:1: note: 'getchar' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
+++ |+#include <cstdio>
1 | #include <cstdio>
a.cc:27:5: error: 'printf' was not declared in this scope
27 | printf("%d\n", result);
| ^~~~~~
a.cc:27:5: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
|
s551646581 | p03791 | C++ | #include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
inline
int modMultiple(int a, int b){return (static_cast<long long>(a) * b) % mod;}
int main()
{
int N;
scanf("%d\n", &N);
int result = 1;
int k = 0;
for (int i = 0; i < N; ++i){
int Xi;
scanf("%d", &Xi); getchar();
while (Xi < k * 2 + 1){
result = modMultiple(result, k + 1);
--k;
}
++k;
}
for (; k > 0; --k){
result = modMultiple(result, k);
}
printf("%d\n", result);
} | a.cc:1:1: error: '\U0000ff03include' does not name a type
1 | #include <bits/stdc++.h>
| ^~~~~~~~~
a.cc: In function 'int main()':
a.cc:12:5: error: 'scanf' was not declared in this scope
12 | scanf("%d\n", &N);
| ^~~~~
a.cc:17:27: error: 'getchar' was not declared in this scope
17 | scanf("%d", &Xi); getchar();
| ^~~~~~~
a.cc:1:1: note: 'getchar' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
+++ |+#include <cstdio>
1 | #include <bits/stdc++.h>
a.cc:27:5: error: 'printf' was not declared in this scope
27 | printf("%d\n", result);
| ^~~~~~
a.cc:27:5: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
|
s358453480 | p03791 | Java | //package jp.atcoder.mujin_pc_2017;
import java.io.*;
import java.math.*;
import java.util.*;
import java.text.*;
class Solver{
private Scanner stdin;
private PrintWriter stdout;
public void run(){
stdin = new Scanner(new BufferedInputStream(System.in));
stdout = new PrintWriter(new BufferedOutputStream(System.out));
while(stdin.hasNextInt()){
int n = stdin.nextInt();
List<Integer> a = new ArrayList<Integer>(n);
int curr=0;
for(int i=1; i<=n; i++){
int pos=stdin.nextInt();
a.add(n-curr);
curr=Math.max(curr, i-(pos+1)/2);
}
long ans=1L, prev=0L;
long mod=1000000007;
for(int i=n-1; i>=0; i--){
//stdout.printf("a[%d]=%d\n", i, a.get(i));
ans=ans*(a.get(i)-(n-i-1))%mod;
}
stdout.println(ans);
}
stdin.close();
stdout.close();
}
}
public class A {
public static void main(String[] args)throws Exception{
Solver solver = new Solver();
solver.run();
}
}
| Main.java:39: error: class A is public, should be declared in a file named A.java
public class A {
^
1 error
|
s780406729 | p03791 | C++ | #include <iostream>
#define maxN 100000
#define mod 1000000007
using namespace std;
int x[maxN+10],F[maxN + 10], h[maxN + 10];
long long int result = 1;
main(){
int N;
cin >> N;
for(int i=1;i<=N;i++){
cin >> x[i];
}
F[1] = 1;
F[2] = 1;
// if(x[2] > 2){
// F[3] = 1;
// } else {
// F[3] = 2;
// }
for(int i=2;i<=N-1;i++){
if(x[i+1] > 2*(i+1-F[i])){
F[i+1] = F[i];
} else if((x[i+1] == 2*(i+1-F[i])) && (x[i] == x[i+1]-1)){
F[i+1] = F[i];
} else {
F[i+1] = F[i]+1;
}
}
for(int i=1;i<N;i++){
if(F[i]<F[i+1]){
h[F[i]] = i;
}
}
h[F[N]] = N;
for(int i=F[N]+1;i<=N;i++){
h[i] = h[i-1] ;
}
for(int i=1;i<=N;i++){
result = result * (h[i] - (i-1)) % mod;
result %= mod;
}
cout << result; | a.cc:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
9 | main(){
| ^~~~
a.cc: In function 'int main()':
a.cc:49:24: error: expected '}' at end of input
49 | cout << result;
| ^
a.cc:9:7: note: to match this '{'
9 | main(){
| ^
|
s845673683 | p03791 | C++ | #include <iostream>
#define maxN 100000
#define mod 1000000007
using namespace std;
int x[maxN+10],F[maxN + 10], h[maxN + 10];
long long int result = 1;
main(){
int N;
cin >> N;
for(int i=1;i<=N;i++){
cin >> x[i];
}
F[1] = 1;
F[2] = 1;
// if(x[2] > 2){
// F[3] = 1;
// } else {
// F[3] = 2;
// }
for(int i=2;i<=N-1;i++){
if(x[i+1] > 2*(i+1-F[i])){
F[i+1] = F[i];
} else if((x[i+1] == 2*(i+1-F[i])) && (x[i] == x[i+1]-1)){
F[i+1] = F[i];
} else {
F[i+1] = F[i]+1;
}
}
// mang F co dang 1 1 .. 2 2 .. 3 3 .....
// cout << "mang F : " ;
// for(int i=1;i<=N;i++){
// cout<< F[i] << " " ;
// }
for(int i=1;i<N;i++){
if(F[i]<F[i+1]){
h[F[i]] = i;
}
}
h[F[N]] = N;
// cout << "mang h:";
// for(int i=1;i<=N;i++){
// cout << h[i] << " ";
// }
for(int i=F[N]+1;i<=N;i++){
h[i] = h[i-1] ;
}
// cout << "mang h:";
for(int i=1;i<=N;i++){
// cout << h[i] << " ";
result = result * (h[i] - (i-1)) % mod;
result %= mod;
}
// cout << "\ndap an : ";
cout << result; | a.cc:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
9 | main(){
| ^~~~
a.cc: In function 'int main()':
a.cc:56:24: error: expected '}' at end of input
56 | cout << result;
| ^
a.cc:9:7: note: to match this '{'
9 | main(){
| ^
|
s143742336 | p03791 | C++ | #include <iostream>
#define maxN 100000
#define mod 1000000007
using namespace std;
int x[maxN+10],F[maxN + 10], h[maxN + 10];
long long int result = 1;
main(){
int N;
cin >> N;
for(int i=1;i<=N;i++){
cin >> x[i];
}
F[1] = 1;
F[2] = 1;
// if(x[2] > 2){
// F[3] = 1;
// } else {
// F[3] = 2;
// }
for(int i=2;i<=N-1;i++){
if(x[i+1] > 2*(i+1-F[i])){
F[i+1] = F[i];
} else if((x[i+1] == 2*(i+1-F[i])) && (x[i] == x[i+1]-1)){
F[i+1] = F[i];
} else {
F[i+1] = F[i]+1;
}
}
// mang F co dang 1 1 .. 2 2 .. 3 3 .....
// cout << "mang F : " ;
// for(int i=1;i<=N;i++){
// cout<< F[i] << " " ;
// }
for(int i=1;i<N;i++){
if(F[i]<F[i+1]){
h[F[i]] = i;
}
}
h[F[N]] = N;
// cout << "mang h:";
// for(int i=1;i<=N;i++){
// cout << h[i] << " ";
// }
for(int i=F[N]+1;i<=N;i++){
h[i] = h[i-1] ;
}
// cout << "mang h:";
for(int i=1;i<=N;i++){
// cout << h[i] << " ";
result = result * (h[i] - (i-1)) % mod;
result %= mod;
}
// cout << "\ndap an : ";
cout << result; | a.cc:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
9 | main(){
| ^~~~
a.cc: In function 'int main()':
a.cc:56:24: error: expected '}' at end of input
56 | cout << result;
| ^
a.cc:9:7: note: to match this '{'
9 | main(){
| ^
|
s606729276 | p03791 | C++ | #include <stdio.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
int N;
cin >> N;
int* x = new int[N];
for (size_t i = 0; i < N; i++)
cin >> x[i];
int* ways = new int[N];
for (size_t j = 0; j < N; j++)
ways[j] = 0;
ways[0] = 2;
long long start = 0;
for (size_t i = 2; i < N; i++)
{
int canleft = (x[i - 1] + 1) / 2;
if (i - left > start)
start++;
ways[start]++;
}
for (size_t i = 1; i < N; i++)
ways[i] += ways[i-1];
long long result = ways[0];
for (int j = 1; j < N; j++)
result = (result * (ways[j] - j)) % 1000000007;
cout << result;
return 0;
} | a.cc: In function 'int main()':
a.cc:29:23: error: invalid operands of types 'size_t' {aka 'long unsigned int'} and 'std::ios_base&(std::ios_base&)' to binary 'operator-'
29 | if (i - left > start)
| ~ ^ ~~~~
| | |
| | std::ios_base&(std::ios_base&)
| size_t {aka long unsigned int}
|
s651012055 | p03791 | C++ | dsjahfla | a.cc:1:1: error: 'dsjahfla' does not name a type
1 | dsjahfla
| ^~~~~~~~
|
s196343922 | p03791 | C++ | #include<bits/stdc++.h>
using namespace std;
bool b[3][3];
int cnt=0,m=10000,n;
void dfs(){
bool b1[3][3];
bool c[3];
if(cnt>6)return ;
int f=0;
for(int i=0;i<n;i++)
for(int j=0;j<n;j++){
if(b[i][j]==0)f=1;
b1[i][j]=b[i][j];
}
if(f==0){if(m>cnt)m=cnt;}
else{
for(int i=0;i<n;i++){
for(int j=0;j<n;j++)c[j]=b[i][j];
for(int k=0;k<n;k++){
for(int l=0;l<n;l++)b[I][k]=c[l];
cnt++;
dfs();
for(int I=0;I<n;I++)
for(int j=0;j<n;j++)b[I][j]=b1[I][j];
cnt--;
}
}
}
}
int main(){
char a;
cin>>n;
if(n<=3){
for(int i=0;i<n;i++)
for(int j=0;j<n;j++){
cin>>a;
if(a=='#')b[i][j]=1;
}
dfs();
if(m==10000)cout<<-1<<endl;
else cout<<m<<endl;
}
return 0;
} | a.cc: In function 'void dfs()':
a.cc:22:26: error: 'I' was not declared in this scope
22 | for(int l=0;l<n;l++)b[I][k]=c[l];
| ^
|
s633282743 | p03791 | C++ | #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin >> n;
long long int ans=1, n, x;
stack<long long int> st;
while(n--){
cin >> x;
st.push(x);
if(x >= 2*st.size() - 1){
}
else{
ans *= st.size();
st.pop();
}
}
rep(i,st.size())
ans *= i+1;
ans %= 1000000007;
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:19:30: error: conflicting declaration 'long long int n'
19 | long long int ans=1, n, x;
| ^
a.cc:16:13: note: previous declaration as 'int n'
16 | int n;
| ^
|
s432692183 | p03791 | C++ | include<stdio.h>
#include<iostream>
#include<string.h>
using namespace std;
int moji(string s,long long int a,long long int b);
int main(){
string s;
long long int n;
long long int q[500000][2];
long long int i;
int how;
cin>>s;
cin>>n;
for(i=0;i<n;i++){
cin>>q[i][0]>>q[i][1];
}
for(i=0;i<n;i++){
how=moji(s,q[i][0],q[i][1]);
if(how==0){
cout<<"NO"<<endl;
}
if(how==1){
cout<<"YES"<<endl;
}
}
return 0;
}
int moji(string s,long long int a,long long int b){
char k[500000];
long long int i;
long long int j;
int sub;
sub=b-a;
for(i=0;i<=sub;i++){
k[i]=s[a-1+i];
}
for(i=0;i<=sub;i++){
if((k[i]==k[i+1])&&k[i]=='z'){
for(j=i;j<=sub-2;j++){
k[j]=k[j+2];
}
k[sub-1]='0';
k[sub]='0';
if(i>2){
i=i-2;
}else{
i=-1;
}
}else if((k[i]==k[i+1])&&k[i]!='0'){
k[i]=k[i]+0x01;
for(j=i+1;j<=sub-1;j++){
k[j]=k[j+1];
}
k[sub]='0';
if(i>2){
i=i-2;
}else{
i=-1;
}
}
for(j=0;j<=sub;j++){
cout<<k[j];
}
cout<<endl;
}
for(i=0;i<=sub;i++){
if(k[i]!='0'){
return 0;
}
}
return 1;
}
| a.cc:1:1: error: 'include' does not name a type
1 | include<stdio.h>
| ^~~~~~~
In file included from /usr/include/c++/14/iosfwd:42,
from /usr/include/c++/14/ios:40,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:2:
/usr/include/c++/14/bits/postypes.h:68:11: error: 'ptrdiff_t' does not name a type
68 | typedef ptrdiff_t streamsize; // Signed integral type
| ^~~~~~~~~
/usr/include/c++/14/bits/postypes.h:41:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
40 | #include <cwchar> // For mbstate_t
+++ |+#include <cstddef>
41 |
In file included from /usr/include/c++/14/bits/exception_ptr.h:38,
from /usr/include/c++/14/exception:166,
from /usr/include/c++/14/ios:41:
/usr/include/c++/14/new:131:26: error: declaration of 'operator new' as non-function
131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~~~
/usr/include/c++/14/new:131:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~
In file included from /usr/include/wchar.h:35,
from /usr/include/c++/14/cwchar:44,
from /usr/include/c++/14/bits/postypes.h:40:
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:132:41: error: attributes after parenthesized initializer ignored [-fpermissive]
132 | __attribute__((__externally_visible__));
| ^
/usr/include/c++/14/new:133:26: error: declaration of 'operator new []' as non-function
133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~~~
/usr/include/c++/14/new:133:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:134:41: error: attributes after parenthesized initializer ignored [-fpermissive]
134 | __attribute__((__externally_visible__));
| ^
/usr/include/c++/14/new:140:29: error: 'std::size_t' has not been declared
140 | void operator delete(void*, std::size_t) _GLIBCXX_USE_NOEXCEPT
| ^~~
/usr/include/c++/14/new:142:31: error: 'std::size_t' has not been declared
142 | void operator delete[](void*, std::size_t) _GLIBCXX_USE_NOEXCEPT
| ^~~
/usr/include/c++/14/new:145:26: error: declaration of 'operator new' as non-function
145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~~~~
/usr/include/c++/14/new:145:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:145:52: error: expected primary-expression before 'const'
145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~
/usr/include/c++/14/new:147:26: error: declaration of 'operator new []' as non-function
147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~~~~
/usr/include/c++/14/new:147:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:147:54: error: expected primary-expression before 'const'
147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~
/usr/include/c++/14/new:154:26: error: declaration of 'operator new' as non-function
154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t)
| ^~~~~~~~
/usr/include/c++/14/new:154:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:154:68: error: expected primary-expression before ')' token
154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t)
| ^
/usr/include/c++/14/new:155:73: error: attributes after parenthesized initializer ignored [-fpermissive]
155 | __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__));
| ^
/usr/include/c++/14/new:156:26: error: declaration of 'operator new' as non-function
156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~~~~
/usr/include/c++/14/new:156:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:156:68: error: expected primary-expression before ',' token
156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
| ^
/usr/include/c++/14/new:156:70: error: expected primary-expression before 'const'
156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~
/usr/include/c++/14/new:162:26: error: declaration of 'operator new []' as non-function
162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t)
| ^~~~~~~~
/usr/include/c++/14/new:162:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:162:70: error: expected primary-expression before ')' token
162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t)
| ^
/usr/include/c++/14/new:163:73: error: attributes after parenthesized initializer ignored [-fpermissive]
163 | __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__));
| ^
/usr/include/c++/14/new:164:26: error: declaration of 'operator new []' as non-function
164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~~~~
/usr/include/c++/14/new:164:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:164:70: error: expected primary-expression before ',' token
164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
| ^
/usr/include/c++/14/new:164:72: error: expected primary-expression before 'const'
164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~
/usr/include/c++/14/new:171:29: error: 'std::size_t' has not been declared
171 | void operator delete(void*, std::size_t, std::align_val_t)
| ^~~
/usr/include/c++/14/new:173:31: error: 'std::size_t' has not been declared
173 | void operator delete[](void*, std::size_t, std::align_val_t)
| ^~~
/usr/include/c++/14/new:179:33: error: declaration of 'operator new' as non-function
179 | _GLIBCXX_NODISCARD inline void* operator new(std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT
| ^~~~~~~~
/usr/include/c++/14/new:179:51: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
179 | _GLIBCXX_N |
s485671879 | p03791 | Java | import java.io.*;
import java.util.*;
public class Main {
static final int M = 1_000_000_007;
void run() {
int n = in.nextInt();
int[] x = new int[n];
for (int i = 0; i < n; i++) {
x[i] = in.nextInt();
}
long ans = 1;
int m = 0;
for (int i = 0; i < n; i++) {
if (x[i] == 2 * m) {
ans *= m + 1;
ans %= M;
} else {
m++;
}
}
while (m > 0) {
ans *= m;
ans %= M;
m--;
}
out.println(ans);
}
static MyScanner in;
static PrintWriter out;
public static void main(String[] args) throws IOException {
boolean stdStreams = true;
String fileName = A.class.getSimpleName().replaceFirst("_.*", "").toLowerCase();
String inputFileName = fileName + ".in";
String outputFileName = fileName + ".out";
Locale.setDefault(Locale.US);
BufferedReader br;
if (stdStreams) {
br = new BufferedReader(new InputStreamReader(System.in));
out = new PrintWriter(System.out);
} else {
br = new BufferedReader(new FileReader(inputFileName));
out = new PrintWriter(outputFileName);
}
in = new MyScanner(br);
int tests = 1;//in.nextInt();
for (int test = 0; test < tests; test++) {
new Main().run();
}
br.close();
out.close();
}
static class MyScanner {
BufferedReader br;
StringTokenizer st;
MyScanner(BufferedReader br) {
this.br = br;
}
void findToken() {
while (st == null || !st.hasMoreTokens()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
String next() {
findToken();
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
}
}
| Main.java:36: error: cannot find symbol
String fileName = A.class.getSimpleName().replaceFirst("_.*", "").toLowerCase();
^
symbol: class A
location: class Main
1 error
|
s554512563 | p03791 | C++ | #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <queue>
#include <iomanip>
using namespace std;
typedef long long ll;
#define MOD (int)(1e9+7)
int x[100000];
int n;
ll A[100001];
int main()
{
A[0] = 1;
for (int i = 1; i <= 100000; i++)A[i] = i*A[i - 1];
cin >> n;
for (int i = 0; i < n; i++)cin >> x[i];
vector<int>index;
int j = 0;
for (int i = 1; i < n-1; i++) {
if (x[i-1] >= 2 * j + 1)x[i-1] = 2 * j + 1;
if(x[i]-x[i-1]==1){
index.push_back(i+1);
i++;
}
j++;
}
ll ans = 1;
int cnt = 0;
for (int i = 0; i < index.size(); i++) {
ans *= long long(index[i]-cnt);
ans %= MOD;
cnt++;
}
ans *= A[n - cnt];
cout << ans%MOD << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:37:24: error: expected primary-expression before 'long'
37 | ans *= long long(index[i]-cnt);
| ^~~~
|
s036671112 | p03791 | C++ | #include <iostream>
#include <vector>
#define int long long
using namespace std;
int n;
int x[100000];
signed main() {
int i, j;
cin >> n;
for (i = 0; i < n; i++) cin >> x[i];
for (i = 0; i < n; i++) x[i] -= 2 * i + 1;
for (i = 0; i < n; i++) x[i] = -x[i];
int yose = 0;
vector<int> vec;
for (i = 0; i < n; i++) {
if (yose == 0) vec.push_back(0);
else vec.push_back(yose + 1);
yose = max(yose, x[i]);
}
sort(vec.begin(), vec.end());
int ans = 1;
for (i = (int)vec.size() - 1; i >= 0; i--) {
int cnt = n - (vec[i] + 1);
cnt -= i - ((int)vec.size() - 1);
ans *= cnt;
ans %= 1000000007;
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:25:9: error: 'sort' was not declared in this scope; did you mean 'short'?
25 | sort(vec.begin(), vec.end());
| ^~~~
| short
|
s730513715 | p03791 | C++ | #include <iostream>
#include <vector>
#define int long long
using namespace std;
int n;
int x[100000];
signed main() {
int i, j;
cin >> n;
for (i = 0; i < n; i++) cin >> x[i];
for (i = 0; i < n; i++) x[i] -= 2 * i + 1;
for (i = 0; i < n; i++) x[i] = -x[i];
int yose = 0;
vector<int> vec;
for (i = 0; i < n; i++) {
if (yose == 0) vec.push_back(0);
else vec.push_back(yose + 1);
yose = max(yose, x[i]);
}
sort(vec.begin(), vec.end());
int ans = 1;
for (i = (int)vec.size() - 1; i >= 0; i--) {
int cnt = n - (vec[i] + 1);
cnt -= i - ((int)vec.size() - 1);
ans *= cnt;
ans %= 1000000007;
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:25:9: error: 'sort' was not declared in this scope; did you mean 'short'?
25 | sort(vec.begin(), vec.end());
| ^~~~
| short
|
s520995288 | p03791 | C++ | #include <vector>
#include <map>
#include <cstring>
#include <algorithm>
#include <cstdio>
#define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; i++)
using namespace std;
const long long MOD = 1000000000 + 7;
const int MAXN = 100111;
long long a[MAXN];
int n;
int main() {
ios::sync_with_stdio(false);
cin >> n;
FOR(i, 1, n) cin >> a[i];
long long cnt = 0;
long long j = 1;
long long res = 1;
FOR(i, 1, n) {
res = (res * (i-cnt)) % MOD;
if (a[i] >= j) j += 2;
else cnt++;
}
cout << res << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:17:3: error: 'ios' has not been declared
17 | ios::sync_with_stdio(false);
| ^~~
a.cc:18:3: error: 'cin' was not declared in this scope
18 | cin >> n;
| ^~~
a.cc:6:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
5 | #include <cstdio>
+++ |+#include <iostream>
6 |
a.cc:28:3: error: 'cout' was not declared in this scope
28 | cout << res << endl;
| ^~~~
a.cc:28:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:28:18: error: 'endl' was not declared in this scope
28 | cout << res << endl;
| ^~~~
a.cc:6:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
5 | #include <cstdio>
+++ |+#include <ostream>
6 |
|
s605041851 | p03791 | C++ | >
#include <vector>
#include <map>
#include <cstring>
#include <algorithm>
#include <cstdio>
#define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; i++)
using namespace std;
const long long MOD = 1000000000 + 7;
const int MAXN = 100111;
long long a[MAXN];
int n;
int main() {
ios::sync_with_stdio(false);
cin >> n;
FOR(i, 1, n) cin >> a[i];
long long cnt = 0;
long long j = 1;
long long res = 1;
FOR(i, 1, n) {
res = (res * (i-cnt)) % MOD;
if (a[i] >= j) j += 2;
else cnt++;
}
cout << res << endl;
return 0;
} | a.cc:1:1: error: expected unqualified-id before '>' token
1 | >
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:62,
from /usr/include/c++/14/vector:62,
from a.cc:2:
/usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity
164 | __is_null_pointer(std::nullptr_t)
| ^
/usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)'
159 | __is_null_pointer(_Type)
| ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std'
164 | __is_null_pointer(std::nullptr_t)
| ^~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/type_traits:295:27: error: 'size_t' has not been declared
295 | template <typename _Tp, size_t = sizeof(_Tp)>
| ^~~~~~
/usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'
666 | struct is_null_pointer<std::nullptr_t>
| ^~~~~~~~~
/usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid
666 | struct is_null_pointer<std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid
670 | struct is_null_pointer<const std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid
674 | struct is_null_pointer<volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid
678 | struct is_null_pointer<const volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:984:26: error: 'size_t' has not been declared
984 | template<typename _Tp, size_t _Size>
| ^~~~~~
/usr/include/c++/14/type_traits:985:40: error: '_Size' was not declared in this scope
985 | struct __is_array_known_bounds<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:985:46: error: template argument 1 is invalid
985 | struct __is_array_known_bounds<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^~~~~~
/usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^
/usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'
1438 | : public integral_constant<std::size_t, 0> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid
1438 | : public integral_constant<std::size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared
1440 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope
1441 | struct rank<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid
1441 | struct rank<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1451:32: error: 'size_t' was not declared in this scope
1451 | : public integral_constant<size_t, 0> { };
| ^~~~~~
/usr/include/c++/14/type_traits:64:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
63 | #include <bits/version.h>
+++ |+#include <cstddef>
64 |
/usr/include/c++/14/type_traits:1451:41: error: template argument 1 is invalid
1451 | : public integral_constant<size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1451:41: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1453:26: error: 'size_t' has not been declared
1453 | template<typename _Tp, size_t _Size>
| ^~~~~~
/usr/include/c++/14/type_traits:1454:23: error: '_Size' was not declared in this scope
1454 | struct extent<_Tp[_Size], 0>
| ^~~~~
/usr/include/c++/14/type_traits:1454:32: error: template argument 1 is invalid
1454 | struct extent<_Tp[_Size], 0>
| ^
/usr/include/c++/14/type_traits:1455:32: error: 'size_t' was not declared in this scope
1455 | : public integral_constant<size_t, _Size> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1455:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/type_traits:1455:40: error: '_Size' was not declared in this scope
1455 | : public integral_constant<size_t, _Size> { };
| ^~~~~
/usr/include/c++/14/type_traits:1455:45: error: template argument 1 is invalid
1455 | : public integral_constant<size_t, _Size> { };
| ^
/usr/include/c++/14/type_traits:1455:45: error: template argument 2 is invalid
/usr/include/c++/14/type_traits:1457:42: error: 'size_t' has not been declared
1457 | template<typename _Tp, unsigned _Uint, size_t _Size>
| ^~~~~~
/usr/include/c++/14/type_traits:1458:23: error: '_Size' was not declared in this scope
1458 | struct extent<_Tp[_Size], _Uint>
| ^~~~~
/usr/include/c++/14/type_traits:1458:36: error: template argument 1 is invalid
1458 | struct extent<_Tp[_Size], _Uint>
| ^
/usr/include/c++/14/type_traits:1463:32: error: 'size_t' was not declared in this scope
1463 | : public integral_constant<size_t, 0> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1463:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/type_traits:1463:41: error: template argument 1 is invalid
1463 | : public integral_constant<size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1463:41: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1857:26: error: 'size_t' does not name a type
1857 | { static constexpr size_t __size = sizeof(_Tp); };
| ^~~~~~
/usr/include/c++/14/type_traits:1857:26: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/type_traits:1859:14: error: 'size_t' has not been declared
1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)>
| ^~~~~~
/usr/include/c++/14/type_traits:1859:48: error: '_Sz' was not declared in this scope
1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)>
| ^~~
/usr/include/c++/14/type_traits:1860:14: error: no default argument for '_Tp'
1860 | struct __select;
| ^~~~~~~~
/usr/include/c++/14/type_traits:1862:14: error: 'size_t' has not been declared
1862 | template<size_t _Sz, typename _Uint, typename... _UInts>
| ^~~~~~
/usr/include/c++/14/type_traits:1863:23: error: '_Sz' was not declared in this scope
1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true>
| ^~~
/usr/include/c++/14/type_traits:1863:57: error: template argument 1 is invalid
1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true>
| ^
/usr/include/c++/14/type_traits:1866:14: error: 'size_t' has not been declared
1866 | template<size_t _Sz, typename _Uint, typename... _UInts>
| ^~~~~~
/usr/include/c++/14/type_traits:1867:23: error: '_Sz' was not declared in this scope
1867 | struct __select<_Sz, _List<_Uint, _UInts...>, false>
| ^~~
/usr/include/c++/14/type_traits:1867:58: error: template argument 1 is invalid
1867 | struct __select<_Sz, _List<_Uint, _UInts...>, false>
| |
s784566573 | p03791 | C++ | >
#include <vector>
#include <map>
#include <cstring>
#include <algorithm>
#include <cstdio>
#define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; i++)
using namespace std;
const long long MOD = 1000000000 + 7;
const int MAXN = 100111;
long long a[MAXN];
int n;
int main() {
ios::sync_with_stdio(false);
cin >> n;
FOR(i, 1, n) cin >> a[i];
long long cnt = 0;
long long j = 1;
long long res = 1;
FOR(i, 1, n) {
res = (res * (i-cnt)) % MOD;
if (a[i] >= j) j += 2;
else cnt++;
}
cout << res << endl;
return 0;
} | a.cc:1:1: error: expected unqualified-id before '>' token
1 | >
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:62,
from /usr/include/c++/14/vector:62,
from a.cc:2:
/usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity
164 | __is_null_pointer(std::nullptr_t)
| ^
/usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)'
159 | __is_null_pointer(_Type)
| ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std'
164 | __is_null_pointer(std::nullptr_t)
| ^~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/type_traits:295:27: error: 'size_t' has not been declared
295 | template <typename _Tp, size_t = sizeof(_Tp)>
| ^~~~~~
/usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'
666 | struct is_null_pointer<std::nullptr_t>
| ^~~~~~~~~
/usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid
666 | struct is_null_pointer<std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid
670 | struct is_null_pointer<const std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid
674 | struct is_null_pointer<volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid
678 | struct is_null_pointer<const volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:984:26: error: 'size_t' has not been declared
984 | template<typename _Tp, size_t _Size>
| ^~~~~~
/usr/include/c++/14/type_traits:985:40: error: '_Size' was not declared in this scope
985 | struct __is_array_known_bounds<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:985:46: error: template argument 1 is invalid
985 | struct __is_array_known_bounds<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^~~~~~
/usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^
/usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'
1438 | : public integral_constant<std::size_t, 0> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid
1438 | : public integral_constant<std::size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared
1440 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope
1441 | struct rank<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid
1441 | struct rank<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1451:32: error: 'size_t' was not declared in this scope
1451 | : public integral_constant<size_t, 0> { };
| ^~~~~~
/usr/include/c++/14/type_traits:64:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
63 | #include <bits/version.h>
+++ |+#include <cstddef>
64 |
/usr/include/c++/14/type_traits:1451:41: error: template argument 1 is invalid
1451 | : public integral_constant<size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1451:41: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1453:26: error: 'size_t' has not been declared
1453 | template<typename _Tp, size_t _Size>
| ^~~~~~
/usr/include/c++/14/type_traits:1454:23: error: '_Size' was not declared in this scope
1454 | struct extent<_Tp[_Size], 0>
| ^~~~~
/usr/include/c++/14/type_traits:1454:32: error: template argument 1 is invalid
1454 | struct extent<_Tp[_Size], 0>
| ^
/usr/include/c++/14/type_traits:1455:32: error: 'size_t' was not declared in this scope
1455 | : public integral_constant<size_t, _Size> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1455:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/type_traits:1455:40: error: '_Size' was not declared in this scope
1455 | : public integral_constant<size_t, _Size> { };
| ^~~~~
/usr/include/c++/14/type_traits:1455:45: error: template argument 1 is invalid
1455 | : public integral_constant<size_t, _Size> { };
| ^
/usr/include/c++/14/type_traits:1455:45: error: template argument 2 is invalid
/usr/include/c++/14/type_traits:1457:42: error: 'size_t' has not been declared
1457 | template<typename _Tp, unsigned _Uint, size_t _Size>
| ^~~~~~
/usr/include/c++/14/type_traits:1458:23: error: '_Size' was not declared in this scope
1458 | struct extent<_Tp[_Size], _Uint>
| ^~~~~
/usr/include/c++/14/type_traits:1458:36: error: template argument 1 is invalid
1458 | struct extent<_Tp[_Size], _Uint>
| ^
/usr/include/c++/14/type_traits:1463:32: error: 'size_t' was not declared in this scope
1463 | : public integral_constant<size_t, 0> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1463:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/type_traits:1463:41: error: template argument 1 is invalid
1463 | : public integral_constant<size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1463:41: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1857:26: error: 'size_t' does not name a type
1857 | { static constexpr size_t __size = sizeof(_Tp); };
| ^~~~~~
/usr/include/c++/14/type_traits:1857:26: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/type_traits:1859:14: error: 'size_t' has not been declared
1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)>
| ^~~~~~
/usr/include/c++/14/type_traits:1859:48: error: '_Sz' was not declared in this scope
1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)>
| ^~~
/usr/include/c++/14/type_traits:1860:14: error: no default argument for '_Tp'
1860 | struct __select;
| ^~~~~~~~
/usr/include/c++/14/type_traits:1862:14: error: 'size_t' has not been declared
1862 | template<size_t _Sz, typename _Uint, typename... _UInts>
| ^~~~~~
/usr/include/c++/14/type_traits:1863:23: error: '_Sz' was not declared in this scope
1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true>
| ^~~
/usr/include/c++/14/type_traits:1863:57: error: template argument 1 is invalid
1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true>
| ^
/usr/include/c++/14/type_traits:1866:14: error: 'size_t' has not been declared
1866 | template<size_t _Sz, typename _Uint, typename... _UInts>
| ^~~~~~
/usr/include/c++/14/type_traits:1867:23: error: '_Sz' was not declared in this scope
1867 | struct __select<_Sz, _List<_Uint, _UInts...>, false>
| ^~~
/usr/include/c++/14/type_traits:1867:58: error: template argument 1 is invalid
1867 | struct __select<_Sz, _List<_Uint, _UInts...>, false>
| |
s469107105 | p03791 | C++ | #include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl
template<class T> bool set_min(T &a, const T &b) { return a > b ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }
const int INF = 1 << 30;
const ll INFL = 1LL << 60;
class Solver {
public:
bool solve() {
int N; cin >> N;
vector<int> X(N); cin >> X;
vector<ll> group;
ll m = 0;
int pre = 0;
int cnt = 0;
rep(i, N) {
cnt++;
int now = X[i];
m += now - pre;
if(m + 2 == cnt) {
group.push_back(cnt);
cnt = 0;
m = 0;
}
}
ll ans = 1;
for(ll a : group) ans = (ans * a) % (1000000000 + 7);
cout << a << endl;
return 0;
}
};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
Solver s;
s.solve();
return 0;
}
| a.cc: In member function 'bool Solver::solve()':
a.cc:44:17: error: 'a' was not declared in this scope
44 | cout << a << endl;
| ^
|
s726844609 | p03791 | C++ | #include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<map>
#include<set>
#include<functional>
#define P pair<int,int>
using namespace std;
int main() {
int a; cin >> a;
if (a <= 8) {
int S = 0;
int b[8];
for (int c = 0; c < a; c++)cin >> b[c];
int c[8];//ゴールする順番
for (int i = 0; i < a; i++)c[i] = i;
bool aru[8];
do {
bool OK = true;
int copy[8];
for (int i = 0; i < a; i++)copy[i] = b[i];
memset(aru, true, sizeof(aru));
for (int i = 0; i < a; i++) {//c[i]体目がゴールする
vector<P>V;
for (int j = 0; j < a; j++) {
if (aru[j] && copy[j] < copy[c[i]]) {
V.push_back(P(copy[j], j));
}
}
sort(V.begin(), V.end(), greater<P>());
for (int k = 0; k + 1 < (int)V.size(); k++) {
if (V[k].first - 1 <= V[k + 1].first) {
V[k + 1].first = V[k].first - 2;
}
}
for (int k = 0; k < V.size(); k++) {
copy[V[k].second] = V[k].first;
if (V[k].first <= 0)OK = false;
}
aru[c[i]] = false;
}
if (OK) { S++; }
} while (next_permutation(c, c + a));
cout << S << endl;
}
} | a.cc: In function 'int main()':
a.cc:27:25: error: 'memset' was not declared in this scope
27 | memset(aru, true, sizeof(aru));
| ^~~~~~
a.cc:11:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
10 | #include<functional>
+++ |+#include <cstring>
11 | #define P pair<int,int>
|
s095933709 | p03791 | C++ | #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> mat;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rep(i,n) FOR(i,0,n)
#define mset(a,x) memset(a,x,sizeof(a))
#define OUT(x) cout<<(x)<<"\n"
int n;
ll INF = 1145141919;
ll row[514];
ll ma = -1;
bool naname(mat f) {
return (f[0][0] == f[1][1] && f[0][1] == f[1][0]);
}
ll calc(mat f) {
if(ma == 0) return -1;
int cnt = 0;
rep(y, n) rep(x, n) {
cnt += f[y][x] == 1;
}
if(n == 1) {
return (f[0][0] == 0 ? -1 : 0);
}
if(n == 2) {
if(cnt == 4) return 0;
if(cnt == 3) return 1;
if(cnt == 1 || naname()) return 3;
return 2;
}
if(n == 3) {
int all = 0;
rep(x, n) {
auto t = f[0][x];
bool ok = true;
rep(i, n) if(t != f[i][x]) ok = false;
all += ok;
}
if(ma == 3) {
return 3 - all;
}
else if(ma == 2) {
return 5;
}
else if(ma == 1) {
return 2 + 3;
}
}
}
int main() {
cin >> n;
if(n > 3) return 0;
mat f(n + 1, vi(n + 1, 0));
mset(row, 0);
rep(y, n)rep(x, n) {
char c;
cin >> c;
if(c == '#') {
f[y][x] = 1;
row[y]++;
ma = max(ma, row[y]);
}
}
OUT(calc(f));
return 0;
} | a.cc: In function 'll calc(mat)':
a.cc:34:30: error: too few arguments to function 'bool naname(mat)'
34 | if(cnt == 1 || naname()) return 3;
| ~~~~~~^~
a.cc:17:6: note: declared here
17 | bool naname(mat f) {
| ^~~~~~
a.cc:56:1: warning: control reaches end of non-void function [-Wreturn-type]
56 | }
| ^
|
s732402144 | p03791 | C++ | import copy
def test(x,target):
r=x[target]
if target==0 or target==1:
return True
last=1
gap=0
bar=0
for i in range(0,target):
gap=gap+(x[i]-last)
bar=bar+1
last=x[i]+1
if gap<bar-1:
return False
#if x[i]+1==x[i+1]:
# return False
return True
def solve(x):
if len(x)==2:
return 2
total=0
for target in range(0,len(x)):
if(test(x,target)):
y=copy.deepcopy(x)
del y[target]
total=total+solve(y)
return total
n=int(raw_input())
c=raw_input().split()
x=[]
for s in c:
x.append(int(s))
ans=solve(x)
print ans%(1000000007) | a.cc:16:14: error: token "[" is not valid in preprocessor expressions
16 | #if x[i]+1==x[i+1]:
| ^
a.cc:16: error: unterminated #if
16 | #if x[i]+1==x[i+1]:
a.cc:1:1: error: 'import' does not name a type
1 | import copy
| ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
|
s881973416 | p03791 | C++ | #include <iostream>
#include <vector>
int main(){
int n,sum=1,cnt=0,hoge=0,mai=std::pow(10,9)+7;
std::vector<int> su;
std::cin>>n;
for(int i=0;i<n;i++){
std::cin>>hoge;
su.push_back(hoge);
}
for(int i=0;i<n;i++){
cnt=1;
for(int j=1;j<n;j++){
if(j-i<=0)
cnt++;
else if((su[j]/(j-i))>=2)
cnt++;
}
sum*=(cnt-i);
}
std::cout<<sum%mai<<std::endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:4:43: error: 'pow' is not a member of 'std'
4 | int n,sum=1,cnt=0,hoge=0,mai=std::pow(10,9)+7;
| ^~~
|
s932751385 | p03791 | C++ | #include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(long long x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl
#define NN 1000000007
#define all(x) x.begin(),x.end()
typedef pair<long long,long long> P;
typedef pair<long long,P> PP;
long long a[200005];
long long n;
long long M;
long long ans;
long long torino;
long long tor[200005];
int main()
{
cin>>n;
rep(i,n)cin>>a[i];
if(n==2)
{
cout<<2<<endl;
return 0;
}
rep2(i,1,n)
{
if(a[i]%2==0)
{
M=a[i]/2;
}
else M=a[i]/2+1;
tor[i]=max(i+1-M,0);
tor[i]=max(tor[i],tor[i-1]);
}
ans=1;
rep2(i,1,n)
{
ans*=(i+1-tor[i-1]);
ans%=NN;
}
cout<<ans<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:44:27: error: no matching function for call to 'max(long long int, int)'
44 | tor[i]=max(i+1-M,0);
| ~~~^~~~~~~~~
In file included from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:44:27: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
44 | tor[i]=max(i+1-M,0);
| ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:8:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:44:27: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
44 | tor[i]=max(i+1-M,0);
| ~~~^~~~~~~~~
|
s309715521 | p03791 | C++ | #include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(long long x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl
#define NN 1000000007
#define all(x) x.begin(),x.end()
typedef pair<long long,long long> P;
typedef pair<long long,P> PP;
long long a[200005];
long long n;
long long M;
long long ans;
long long torino;
long long tor[200005];
int main()
{
cin>>n;
rep(i,n)cin>>a[i];
if(n==2)
{
cout<<2<<endl;
return 0;
}
rep2(i,1,n)
{
if(a[i]%2==0)
{
M=a[i]/2;
}
else M=a[i]/2+1;
tor[i]=max(i+1-M,0);
tor[i]=max(tor[i],tor[i-1]);
}
ans=1;
rep2(i,1,n)
{
ans*=(i+1-tor[i-1]);
ans%=NN;
}
cout<<ans<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:43:27: error: no matching function for call to 'max(long long int, int)'
43 | tor[i]=max(i+1-M,0);
| ~~~^~~~~~~~~
In file included from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:43:27: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
43 | tor[i]=max(i+1-M,0);
| ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:7:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:43:27: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
43 | tor[i]=max(i+1-M,0);
| ~~~^~~~~~~~~
|
s483964096 | p03791 | C++ | #include <iostream>
#include <vector>
int main(){
int n,sum=1,cnt=0,hoge=0,mai=std::pow(10,9)+7;
std::vector<int> su;
std::cin>>n;
for(int i=0;i<n;i++){
std::cin>>hoge;
su.push_back(hoge);
}
for(int i=0;i<n;i++){
cnt=1;
for(int j=1;j<n;j++){
if(j-i<=0)
cnt++;
else if((su[j]/(j-i))>=2)
cnt++;
}
sum*=(cnt-i);
}
std::cout<<sum%mai<<std::endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:4:43: error: 'pow' is not a member of 'std'
4 | int n,sum=1,cnt=0,hoge=0,mai=std::pow(10,9)+7;
| ^~~
|
s723670161 | p03791 | C++ | #include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int n;
int a[100100];
long long frac[100100];
const int mo = 1e9 + 7;
int main(){
// freopen("in.txt","r",stdin);
scanf("%d",&n);
for (int i = 1; i <= n; i++)
scanf("%d",&a[i]);
frac[0] = 1;
for (int i = 1;i <= n; i++)
frac[i] = (frac[i - 1] * i) % mo;
int last = 0;
long long ans = 1;h
long long cnt = n;
for (int i = 1; i <= n; i++){
if (a[i] < 2 * (i - last) - 1){
ans = (ans * (i - last)) % mo;
last++;
cnt --;
}
}
if (last != n) ans = (ans * frac[n - last]) % mo;
cout << last << endl;
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:21:27: error: 'h' was not declared in this scope
21 | long long ans = 1;h
| ^
a.cc:27:25: error: 'cnt' was not declared in this scope; did you mean 'int'?
27 | cnt --;
| ^~~
| int
|
s391283186 | p03791 | C++ | #include <cstdio>
#include <set>
#include <algorithm>
using namespace std;
const int mod = 1e9+7;
int n, a[100001], b[100001], cnt[100001];
int FF(int start, int num){
return max(num-(start+1)/2, 0);
}
bool meet(int p1, int p2, int num){
return (p2-2*(num-1)) <= (p1+1);
}
struct Elem{
int place, num;
Elem(int place, int num){
this->place=place;
this->num=num;
}
};
int main(){
scanf("%d", &n);
for(int i=1; i<=n; i++)
scanf("%d", &a[i]);
vector<Elem> V;
V.push_back(Elem(a[1], 1));
for(int i=2; i<=n; i++){
V.push_back(Elem(a[2], 1));
while(V.size()>=2){
unsigned int p=V.size()-2;
unsigned int q=V.size()-1;
if(meet(V[p].place, V[q].place, V[q].num)){
V[p].place=V[q].place;
V[p].num+=V[q].num;
V.pop_back();
}
else break;
}
b[i]=FF(V[0].place, V[0].num);
}
cnt[1]++;
for(int i=2; i<=n; i++)
cnt[b[i-1]+1]++;
long long ans = 1;
int sum=0;
for(int i=1; i<=n; i++){
sum+=cnt[i];
ans=ans*sum%mod;
sum--;
}
printf("%lld", ans);
return 0;
}
| a.cc: In function 'int main()':
a.cc:29:9: error: 'vector' was not declared in this scope
29 | vector<Elem> V;
| ^~~~~~
a.cc:4:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
3 | #include <algorithm>
+++ |+#include <vector>
4 | using namespace std;
a.cc:29:20: error: expected primary-expression before '>' token
29 | vector<Elem> V;
| ^
a.cc:29:22: error: 'V' was not declared in this scope
29 | vector<Elem> V;
| ^
|
s688884128 | p03791 | C++ | int main(){
cout << -1 << endl;
} | a.cc: In function 'int main()':
a.cc:2:1: error: 'cout' was not declared in this scope
2 | cout << -1 << endl;
| ^~~~
a.cc:2:15: error: 'endl' was not declared in this scope
2 | cout << -1 << endl;
| ^~~~
|
s966419059 | p03791 | C++ | #include<bits\stdc++.h>
#define P 1000000007
#define ll long long
using namespace std;
ll n,a[10005];
int main()
{
scanf("%lld",&n);
for (ll i=1;i<=n;i++)
scanf("%lld",&a[i]);
sort(a+1,a+n+1);
ll Ans=1,sum=0;
for (ll i=1;i<=n;i++)
{
// cout<<Ans<<' '<<sum<<endl;
if (sum*2+1>a[i]+1)
Ans=Ans*sum%P;
else
if (sum*2+1==a[i]+1) Ans=Ans*(sum+1)%P;
else sum++;
//cout<<Ans<<' '<<sum<<endl;
}
while(sum) Ans=Ans*(sum--)%P;
printf("%lld\n",Ans);
} | a.cc:1:9: fatal error: bits\stdc++.h: No such file or directory
1 | #include<bits\stdc++.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
|
s930408139 | p03791 | Java | import java.io.*;
import java.util.*;
public class A {
FastScanner in;
PrintWriter out;
void solve() {
final int mod = (int) 1e9 + 7;
int n = in.nextInt();
int[] a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = in.nextInt();
}
long res = 1;
int cnt = 0;
for (int i = 0; i < n; i++) {
int pos = a[i];
cnt++;
int can = (pos + 1) / 2;
while (cnt > can) {
res = res * cnt % mod;
cnt--;
}
}
while (cnt > 1) {
res = res * cnt % mod;
cnt--;
}
out.println(res);
}
void run() {
try {
in = new FastScanner(new File("object.in"));
out = new PrintWriter(new File("object.out"));
solve();
out.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
void runIO() {
in = new FastScanner(System.in);
out = new PrintWriter(System.out);
solve();
out.close();
}
class FastScanner {
BufferedReader br;
StringTokenizer st;
public FastScanner(File f) {
try {
br = new BufferedReader(new FileReader(f));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
public FastScanner(InputStream f) {
br = new BufferedReader(new InputStreamReader(f));
}
String next() {
while (st == null || !st.hasMoreTokens()) {
String s = null;
try {
s = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
if (s == null)
return null;
st = new StringTokenizer(s);
}
return st.nextToken();
}
boolean hasMoreTokens() {
while (st == null || !st.hasMoreTokens()) {
String s = null;
try {
s = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
if (s == null)
return false;
st = new StringTokenizer(s);
}
return true;
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
}
public static void main(String[] args) {
new A().runIO();
}
} | Main.java:4: error: class A is public, should be declared in a file named A.java
public class A {
^
1 error
|
s641092875 | p03792 | C++ | #include<bits/stdc++.h>
//using namespace std;
#define rep(i,j,n) for(ll i=(ll)(j);i<(ll)(n);i++)
#define REP(i,j,n) for(ll i=(ll)(j);i<=(ll)(n);i++)
#define per(i,j,n) for(ll i=(ll)(j);(ll)(n)<=i;i--)
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(ll)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(ll)(key)))
#define pb push_back
#define mp std::make_pair
#define endl "\n"
using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::upper_bound;
using std::lower_bound;
using vi=vector<ll>;
using vii=vector<vi>;
using pii=std::pair<ll,ll>;
const ll MOD=1e9+7;
//const ll MOD=998244353;
//const ll MOD=100000;
const ll MAX=1e7;
const ll INF=(1ll<<60);
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
struct Binary_indexed_tree{
int N;
vi bit;
Binary_indexed_tree(int n):N(n){
bit.resize(N+1,0);
}
void add(int x,int a){
for(x;x<=N;x+=(x&-x)) bit[x]+=a;
}
ll sum(int x){
ll ret=0;
for(x;x>0;x-=(x&-x)) ret+=bit[x];
return ret;
}
};
struct Union_Find{
ll N;
vi par;
vi siz;
Union_Find(int n):N(n){
par.resize(N);
siz.resize(N,1);
rep(i,0,N) par[i]=i;
}
ll root(ll X){
if(par[X]==X) return X;
return par[X]=root(par[X]);
}
bool same(ll X,ll Y){
return root(X)==root(Y);
}
void unite(ll X,ll Y){
X=root(X);
Y=root(Y);
if(X==Y) return;
par[X]=Y;
siz[Y]+=siz[X];
siz[X]=0;
}
ll size(ll X){
return siz[root(X)];
}
};
ll modpow(ll X,ll Y){
ll sum=X,cnt=1;
vi A;
while(cnt<=Y){
A.pb(sum);
sum*=sum;
sum%=MOD;
cnt*=2;
}
int M=A.size();
ll ret=1;
REP(i,1,M){
if(Y>=(1ll<<M-i)){
Y-=(1ll<<M-i);
ret*=A[M-i];
ret%=MOD;
}
}
return ret;
}
ll fac[MAX],finv[MAX],inv[MAX];
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++){
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
ll COM(ll n,ll r){
if(n<r||n<0||r<0) return 0;
return fac[n]*finv[r]%MOD*finv[n-r];
}
signed main(){
ll N; cin>>N;
vector<string> S(N);
rep(i,0,N) cin>>S[i];
ll ans=INF;
rep(i,0,N){
ll cnt=0;
rep(j,0,N){
if(S[i][j]=='.') cnt++;
}
bool flag=1;
rep(j,0,N){
if(S[j][i]=='#') flag=0;
}
if(flag){
cnt++;
rep(j,0,N){
rep(k,0,N){
if(S[j][k]=='#') flag=0;
}
}
if(flag) continue;
}
rep(j,0,N){
bool flag=0;
rep(k,0,N){
if(S[k][j]=='.') flag=1;
}
if(flag) cnt++;
}
ans=std::min(ans,cnt);
}
if(ans==INF) ans=-1;
cout<<ans<<endl;
}
#include<bits/stdc++.h>
//using namespace std;
#define rep(i,j,n) for(ll i=(ll)(j);i<(ll)(n);i++)
#define REP(i,j,n) for(ll i=(ll)(j);i<=(ll)(n);i++)
#define per(i,j,n) for(ll i=(ll)(j);(ll)(n)<=i;i--)
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(ll)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(ll)(key)))
#define pb push_back
#define mp std::make_pair
#define endl "\n"
using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::upper_bound;
using std::lower_bound;
using vi=vector<ll>;
using vii=vector<vi>;
using pii=std::pair<ll,ll>;
const ll MOD=1e9+7;
//const ll MOD=998244353;
//const ll MOD=100000;
const ll MAX=1e7;
const ll INF=(1ll<<60);
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
struct Binary_indexed_tree{
int N;
vi bit;
Binary_indexed_tree(int n):N(n){
bit.resize(N+1,0);
}
void add(int x,int a){
for(x;x<=N;x+=(x&-x)) bit[x]+=a;
}
ll sum(int x){
ll ret=0;
for(x;x>0;x-=(x&-x)) ret+=bit[x];
return ret;
}
};
struct Union_Find{
ll N;
vi par;
vi siz;
Union_Find(int n):N(n){
par.resize(N);
siz.resize(N,1);
rep(i,0,N) par[i]=i;
}
ll root(ll X){
if(par[X]==X) return X;
return par[X]=root(par[X]);
}
bool same(ll X,ll Y){
return root(X)==root(Y);
}
void unite(ll X,ll Y){
X=root(X);
Y=root(Y);
if(X==Y) return;
par[X]=Y;
siz[Y]+=siz[X];
siz[X]=0;
}
ll size(ll X){
return siz[root(X)];
}
};
ll modpow(ll X,ll Y){
ll sum=X,cnt=1;
vi A;
while(cnt<=Y){
A.pb(sum);
sum*=sum;
sum%=MOD;
cnt*=2;
}
int M=A.size();
ll ret=1;
REP(i,1,M){
if(Y>=(1ll<<M-i)){
Y-=(1ll<<M-i);
ret*=A[M-i];
ret%=MOD;
}
}
return ret;
}
ll fac[MAX],finv[MAX],inv[MAX];
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++){
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
ll COM(ll n,ll r){
if(n<r||n<0||r<0) return 0;
return fac[n]*finv[r]%MOD*finv[n-r];
}
signed main(){
ll N; cin>>N;
vector<string> S(N);
rep(i,0,N) cin>>S[i];
ll ans=INF;
rep(i,0,N){
ll cnt=0;
rep(j,0,N){
if(S[i][j]=='.') cnt++;
}
bool flag=1;
rep(j,0,N){
if(S[j][i]=='#') flag=0;
}
if(flag){
cnt++;
rep(j,0,N){
rep(k,0,N){
if(S[j][k]=='#') flag=0;
}
}
if(flag) continue;
}
rep(j,0,N){
bool flag=0;
rep(k,0,N){
if(S[k][j]=='.') flag=1;
}
if(flag) cnt++;
}
ans=std::min(ans,cnt);
}
if(ans==INF) ans=-1;
cout<<ans<<endl;
}
| a.cc:163:10: error: redefinition of 'const long long int MOD'
163 | const ll MOD=1e9+7;
| ^~~
a.cc:22:10: note: 'const long long int MOD' previously defined here
22 | const ll MOD=1e9+7;
| ^~~
a.cc:166:10: error: redefinition of 'const long long int MAX'
166 | const ll MAX=1e7;
| ^~~
a.cc:25:10: note: 'const long long int MAX' previously defined here
25 | const ll MAX=1e7;
| ^~~
a.cc:167:10: error: redefinition of 'const long long int INF'
167 | const ll INF=(1ll<<60);
| ^~~
a.cc:26:10: note: 'const long long int INF' previously defined here
26 | const ll INF=(1ll<<60);
| ^~~
a.cc:169:7: error: redefinition of 'class prique<T>'
169 | class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
| ^~~~~~
a.cc:28:7: note: previous definition of 'class prique<T>'
28 | class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
| ^~~~~~
a.cc:170:8: error: redefinition of 'struct Binary_indexed_tree'
170 | struct Binary_indexed_tree{
| ^~~~~~~~~~~~~~~~~~~
a.cc:29:8: note: previous definition of 'struct Binary_indexed_tree'
29 | struct Binary_indexed_tree{
| ^~~~~~~~~~~~~~~~~~~
a.cc:185:8: error: redefinition of 'struct Union_Find'
185 | struct Union_Find{
| ^~~~~~~~~~
a.cc:44:8: note: previous definition of 'struct Union_Find'
44 | struct Union_Find{
| ^~~~~~~~~~
a.cc:213:4: error: redefinition of 'long long int modpow(long long int, long long int)'
213 | ll modpow(ll X,ll Y){
| ^~~~~~
a.cc:72:4: note: 'long long int modpow(long long int, long long int)' previously defined here
72 | ll modpow(ll X,ll Y){
| ^~~~~~
a.cc:233:4: error: redefinition of 'long long int fac [10000000]'
233 | ll fac[MAX],finv[MAX],inv[MAX];
| ^~~
a.cc:92:4: note: 'long long int fac [10000000]' previously declared here
92 | ll fac[MAX],finv[MAX],inv[MAX];
| ^~~
a.cc:233:13: error: redefinition of 'long long int finv [10000000]'
233 | ll fac[MAX],finv[MAX],inv[MAX];
| ^~~~
a.cc:92:13: note: 'long long int finv [10000000]' previously declared here
92 | ll fac[MAX],finv[MAX],inv[MAX];
| ^~~~
a.cc:233:23: error: redefinition of 'long long int inv [10000000]'
233 | ll fac[MAX],finv[MAX],inv[MAX];
| ^~~
a.cc:92:23: note: 'long long int inv [10000000]' previously declared here
92 | ll fac[MAX],finv[MAX],inv[MAX];
| ^~~
a.cc:234:6: error: redefinition of 'void COMinit()'
234 | void COMinit() {
| ^~~~~~~
a.cc:93:6: note: 'void COMinit()' previously defined here
93 | void COMinit() {
| ^~~~~~~
a.cc:244:4: error: redefinition of 'long long int COM(long long int, long long int)'
244 | ll COM(ll n,ll r){
| ^~~
a.cc:103:4: note: 'long long int COM(long long int, long long int)' previously defined here
103 | ll COM(ll n,ll r){
| ^~~
a.cc:248:8: error: redefinition of 'int main()'
248 | signed main(){
| ^~~~
a.cc:107:8: note: 'int main()' previously defined here
107 | signed main(){
| ^~~~
|
s880678939 | p03792 | C++ | //Link : https://atcoder.jp/contests/mujin-pc-2017/tasks/mujin_pc_2017_b
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 503
#define inf 200000000
char s[N][N];
void solve() {
int n;scanf("%d ", &n);
int row[N],column[N];
memset(row,0,sizeof(row));
memset(column,0,sizeof(column));
for(int i=0;i<n;++i) {
scanf(" %s ", s[i]);
for(int j=0;j<n;++j) {
if(s[i][j]=='#') {
++column[j];
++row[i];
}
}
}
int x = n;
int ret = inf;
for(int i=0;i<n;++i) {
if(row[i]==n) {
--x;
}
}
for(int c=0;c<n;++c) {
bool isGood = true;
int tmp = 0;
for(int j = 0;j<n;++j) {
if(s[c][j]=='.') {
if(c==j && column[j]==0) {
if(row[c])
tmp+=2;
else
isGood = false;
} else {
++tmp;
}
}
}
if(!isGood) {
continue;
}
for(int j=0;j<n;++j) if (s[c][j]=='.'||column[j].size()!=n) tmp++;
ret = min(ret,tmp);
}
if(ret==inf) {
ret = -1;
}
printf("%d\n", ret);
}
int main() {
//freopen("input.txt","r",stdin);
solve();
return 0;
}
| a.cc: In function 'void solve()':
a.cc:49:54: error: request for member 'size' in 'column[j]', which is of non-class type 'int'
49 | for(int j=0;j<n;++j) if (s[c][j]=='.'||column[j].size()!=n) tmp++;
| ^~~~
|
s115493599 | p03792 | C++ | #include <bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using bll = boost::multiprecision::cpp_int;
using bdouble = boost::multiprecision::cpp_dec_float_100;
#endif
#ifdef LOCAL_DEV
void debug_impl() { std::cerr << std::endl; }
template<typename Head, typename... Tail> void debug_impl(Head head, Tail... tail) { std::cerr << " " << head << (sizeof...(tail) ? "," : ""); debug_impl(tail...); }
#define debug(...) { std::cerr << std::boolalpha << "(" << #__VA_ARGS__ << ") ="; debug_impl(__VA_ARGS__); std::cerr << std::noboolalpha; }
#else
#define debug(...) {}
#endif
#ifdef LOCAL_TEST
#define BOOST_STACKTRACE_USE_ADDR2LINE
#define BOOST_STACKTRACE_ADDR2LINE_LOCATION /usr/local/opt/binutils/bin/addr2line
#define _GNU_SOURCE
#include <boost/stacktrace.hpp>
namespace std {
template<typename T> class dvector : public std::vector<T> {
public:
dvector() : std::vector<T>() {}
explicit dvector(size_t n, const T& value = T()) : std::vector<T>(n, value) {}
dvector(const std::vector<T>& v) : std::vector<T>(v) {}
dvector(const std::initializer_list<T> il) : std::vector<T>(il) {}
dvector(const typename std::vector<T>::iterator first, const typename std::vector<T>::iterator last) : std::vector<T>(first, last) {}
dvector(const std::string::iterator first, const std::string::iterator last) : std::vector<T>(first, last) {}
T& operator[](size_t n) {
try { return this->at(n); } catch (const std::exception& e) {
std::cerr << boost::stacktrace::stacktrace() << std::endl; return this->at(n);
}
}
const T& operator[](size_t n) const {
try { return this->at(n); } catch (const std::exception& e) {
std::cerr << boost::stacktrace::stacktrace() << std::endl; return this->at(n);
}
}
};
}
class dbool {
private:
bool boolvalue;
public:
dbool() : boolvalue(false) {}
dbool(bool b) : boolvalue(b) {}
dbool(const dbool &b) : boolvalue(b.boolvalue) {}
operator bool&() { return boolvalue; }
operator const bool&() const { return boolvalue; }
};
template<typename T> std::ostream& operator<<(std::ostream& s, const dvector<T>& v) {
for (int i = 0, len = v.size(); i < len; ++i){ s << v[i]; if (i < len - 1) s << "\t"; } return s; }
template<typename T> std::ostream& operator<<(std::ostream& s, const dvector< dvector<T> >& vv) {
for (int i = 0, len = vv.size(); i < len; ++i){ s << vv[i] << std::endl; } return s; }
template<typename T> std::ostream& operator<<(std::ostream& s, const std::set<T>& se) {
s << "{ "; for (auto itr = se.begin(); itr != se.end(); ++itr){ s << (*itr) << "\t"; } s << "}"; return s; }
template<typename T> std::ostream& operator<<(std::ostream& s, const std::multiset<T>& se) {
s << "{ "; for (auto itr = se.begin(); itr != se.end(); ++itr){ s << (*itr) << "\t"; } s << "}"; return s; }
template<typename T1, typename T2> std::ostream& operator<<(std::ostream& s, const std::map<T1, T2>& m) {
s << "{" << std::endl; for (auto itr = m.begin(); itr != m.end(); ++itr){ s << "\t" << (*itr).first << " : " << (*itr).second << std::endl; } s << "}"; return s; }
template<typename T1, typename T2> std::ostream& operator<<(std::ostream& s, const std::pair<T1, T2>& p) {
return s << "(" << p.first << ", " << p.second << ")"; }
#define vector dvector
#define bool dbool
class SIGFPE_exception : std::exception {};
class SIGSEGV_exception : std::exception {};
void catch_SIGFPE(int e) { std::cerr << boost::stacktrace::stacktrace() << std::endl; throw SIGFPE_exception(); }
void catch_SIGSEGV(int e) { std::cerr << boost::stacktrace::stacktrace() << std::endl; throw SIGSEGV_exception(); }
signed convertedmain();
signed main() { signal(SIGFPE, catch_SIGFPE); signal(SIGSEGV, catch_SIGSEGV); return convertedmain(); }
#define main() convertedmain()
#endif
//#define int long long
using ll = long long;
//constexpr int INF = 1e9;//INT_MAX=(1<<31)-1=2147483647
constexpr ll INF = (ll)1e18;//(1LL<<63)-1=9223372036854775807
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-9;
constexpr ll dx[4] = {1LL, 0LL, -1LL, 0LL};
constexpr ll dy[4] = {0LL, 1LL, 0LL, -1LL};
constexpr ll dx8[8] = {1LL, 0LL, -1LL, 0LL, 1LL, 1LL, -1LL, -1LL};
constexpr ll dy8[8] = {0LL, 1LL, 0LL, -1LL, 1LL, -1LL, 1LL, -1LL};
#define rep(i, n) for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define rrep(i, n) for(ll i=(n)-1; i>=0; --i)
#define rrepeq(i, n) for(ll i=(n) ; i>=1; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
void p() { std::cout << '\n'; }
template<typename Head, typename... Tail> void p(Head head, Tail... tail) { std::cout << head << (sizeof...(tail) ? " " : ""); p(tail...); }
template<typename T> inline void pv(std::vector<T> &v) { for(ll i=0, N=v.size(); i<N; i++) std::cout << v[i] << " \n"[i==N-1]; }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> inline bool chmax(T &a, T b) { return a < b && (a = b, true); }
template<typename T> inline bool chmin(T &a, T b) { return a > b && (a = b, true); }
template<typename T> inline void uniq(std::vector<T> &v) { v.erase(unique(v.begin(), v.end()), v.end()); }
/*-----8<-----template-----8<-----*/
/*-----8<-----library-----8<-----*/
void solve() {
ll N;
cin>>N;
std::vector<string> a(N,"");
rep(i,N)cin>>a[i];
if([&]{
rep(i,N)rep(j,N){
if(a[i][j]=='#')return false;
}
return true;
}()){
p(-1);return;
}
if([&]{
rep(i,N)rep(j,N){
if(a[i][j]=='.')return false;
}
return true;
}()){
p(0);return;
}
//横一列を作る
auto f = [&]{
rep(i,N){
bool ok=true;
rep(j,N){
if(a[i][j]=='.'){ok=false;break;}
}
if(ok)return 0LL;
}
vector<bool> kuro(N,false);
rep(i,N){
rep(j,N){
if(a[i][j]=='#')kuro[j]=true;
}
}
ll count=INF;
rep(i,N){
ll t=0;
rep(j,N){
if(a[i][j]=='.')t++;
}
if(!kuro[i])t++;
if(chmin(count,t))index=i;
}
return count;
};
//縦を塗る
auto g = [&]{
ll count=0;
rep(j,N){
rep(i,N){
if(a[i][j]=='.'){
count++;
break;
}
}
}
return count;
};
ll ans=0;
ans+=f();
ans+=g();
p(ans);
}
signed main() {
solve();
return 0;
}
| a.cc:4:18: fatal error: boost/multiprecision/cpp_int.hpp: No such file or directory
4 | #include <boost/multiprecision/cpp_int.hpp>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
|
s430716016 | p03792 | C++ | 3
.##
...
...
| a.cc:2:2: error: stray '##' in program
2 | .##
| ^~
a.cc:1:1: error: expected unqualified-id before numeric constant
1 | 3
| ^
|
s761491341 | p03792 | C++ | #include <bits/stdc++.h>
using namespace std;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
int main() {
int n, r=0, ans = IINF;
bool ok = false;
cin >> n;
vector<string> s(n);
for(int i=0;i<n;i++) cin >> s[i];
for(int j=0;j<n;j++){
int cnt = 0;
for(int i=0;i<n;i++){
if(s[i][j] == '#') cnt++;
}
if(cnt == n) r++;
ok |= cnt > 0;
}
if(!ok){
cout << -1 << endl;
return 0;
}
for(int j=0;j<n;j++){
int f = 1;
for(int i=0;i<n;i++){
if(s[i][j] == '#') f = 0;
}
int cnt = 0;
for(int i=0;i<n;i++){
if(s[j][i] == '.') cnt++;
}
ans = min(ans, cnt+n-r+f);
}
cout << (ans < IINF ? ans : -1) << endl;
return 0;
}
| a.cc:4:11: error: 'll' does not name a type
4 | constexpr ll LLINF = LLONG_MAX;
| ^~
|
s594526639 | p03792 | C++ | #include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
int main() {
cin.tie(nullptr); ios::sync_with_stdio(false);
int n; cin >> n;
int c = 0;
V<string> s(n);
for (auto&& e : s) {
cin >> e;
c += count(begin(e), end(e), '#');
}
if (!c) return cout << -1 << '\n', 0;
int res = 0;
int mn = 1e9;
for (int j = 0; j < n; ++j) {
c = 0;
for (int i = 0; i < n; ++i) c += s[i][j] == '#';
res += c < n;
if (c) {
mn = min(mn, count(begin(s[j]), end(s[j]), '.'));
}
}
res += mn;
cout << res << '\n';
} | a.cc: In function 'int main()':
a.cc:24:15: error: no matching function for call to 'min(int&, std::__iterator_traits<__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >, void>::difference_type)'
24 | mn = min(mn, count(begin(s[j]), end(s[j]), '.'));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:24:15: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'std::__iterator_traits<__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >, void>::difference_type' {aka 'long int'})
24 | mn = min(mn, count(begin(s[j]), end(s[j]), '.'));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:24:15: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
24 | mn = min(mn, count(begin(s[j]), end(s[j]), '.'));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
s913891175 | p03792 | C++ | #include "/Users/daikikodama/Desktop/stdc++.h"
//#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
#define endl '\n'
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
int n;
char c[510][510];
signed main(void){
cin.tie(0);
ios::sync_with_stdio(false);
cin>>n;
bool black=false;
rep(i,n)rep(j,n){
cin>>c[i][j];
if(c[i][j]=='#')black=true;
}
if(!black){
cout<<-1<<endl;
return 0;
}
int white=0;
rep(i,n){
bool b=false;
rep(j,n)if(c[j][i]=='.')b=true;
if(b)white++;
}
int ans=INF;
rep(i,n){
bool b=false;
int cnt=0;
rep(j,n){
if(c[j][i]=='#')b=true;
if(c[i][j]=='.')cnt++;
}
if(!b)cnt++;
chmin(ans, cnt+white);
}
cout<<ans<<endl;
return 0;
} | a.cc:1:10: fatal error: /Users/daikikodama/Desktop/stdc++.h: No such file or directory
1 | #include "/Users/daikikodama/Desktop/stdc++.h"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
|
s908749378 | p03792 | C++ | #include <vector>
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef long long ll;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef vector<PII> VP;
typedef vector<VP> VVP;
const int maxn = 501;
int g[maxn][maxn];
int n;
int main() {
ios::sync_with_stdio(false);
cin >> n;
VI ison(n, 0);
VI numoffinrow(n, 0);
VI colscount(n, 0;)
int numallblackcols = 0;
bool possible = false;
for (int i = 0; i < n; ++i) {
char c;
int black_count = 0;
for (int j = 0; j < n; ++j) {
cin >> c;
g[i][j] = (c == '#' ? 1 : 0);
if (g[i][j]) ison[j] = 1;
black_count += g[i][j];
if (!g[i][j]) ++numoffinrow[i];
colscount[j] += g[i][j];
}
if (black_count > 0) possible = true;
}
for (int j = 0; j < n; ++j) {
if (colscount[j] == n) ++numallblackcols;
}
if (!possible) {
cout << -1;
return 0;
}
int sol = 2*n + 1000;
for (int i = 0; i < n; ++i) {
if (ison[i]) {
sol = min(sol, numoffinrow[i] + (n-numallblackcols));
}
}
cout << sol;
} | a.cc: In function 'int main()':
a.cc:27:26: error: expected ')' before ';' token
27 | VI colscount(n, 0;)
| ~ ^
| )
a.cc:27:27: error: expected primary-expression before ')' token
27 | VI colscount(n, 0;)
| ^
a.cc:44:42: error: 'numallblackcols' was not declared in this scope
44 | if (colscount[j] == n) ++numallblackcols;
| ^~~~~~~~~~~~~~~
a.cc:53:60: error: 'numallblackcols' was not declared in this scope
53 | sol = min(sol, numoffinrow[i] + (n-numallblackcols));
| ^~~~~~~~~~~~~~~
|
s736999290 | p03792 | C++ | #include <bits/stdc++.h>
using namespace std;
const int N = 1234;
int col[N];
char s[N][N];
int main()
{
int h;
scanf("%d", &h);
int w = h;
for (int i = 0; i < h; i++)
scanf("%s", s[i]);
bool any = false;
for (int i = 0; i < h; i++)
for (int j = 0; j < w; j++)
any |= (s[i][j] == '#');
if (!any)
{
puts("-1");
return 0;
}
for (int i = 0; i < h; i ++)
for (int j = 0; j < w; j ++)
if (s[i][j] == '#')
col[j] ++;
int ans = (int) 2 * n + 1;
for (int i = 0; i < h; i ++)
{
int cur = 0;
if (col[i] == 0) cur ++;
for (int j = 0; j < w; j ++)
if (s[i][j] == '.')
cur ++;
for (int j = 0; j < w; j ++)
if (col[j] < h)
cur ++;
ans = min(ans, cur);
}
printf("%d\n", ans);
return 0;
} | a.cc: In function 'int main()':
a.cc:30:29: error: 'n' was not declared in this scope
30 | int ans = (int) 2 * n + 1;
| ^
|
s328057975 | p03792 | C++ | #include <bits/stdc++.h>
#define PAUSE system("pause")
#define LLI long long int
#define LD long double
#define PB push_back
#define PF push_front
#define MP make_pair
#define FORi(i, a, b) for(int i = a; i < b ; ++i)
#define FORd(i, a, b) for(int i = a; i > b ; --i)
using namespace std;
const int MOD = 1e9+7;
int solve(vector<vector<bool> > v){
vector<vector<bool> > b = v;
int n = v.size();
FORi(i,0,n){
FORi(j,0,n){
if (!v[i][j])
break;
if (j == n-1){
return 0;
}
}
}
int a=1e9;
FORi(r,0,n){
FORi(c,0,n){
FORi(i,0,n){
b[i][c] = v[r][i];
}
a = min(a, solve(b));
FORi(i,0,n){
b[i][c] = v[i][c];
}
}
}
return a;
}
int main() {
// ifstream fin("in.txt");
// ofstream fout("out.txt");
int n;
cin >> n;
vector<vector<bool> > black(n);
int cnt = 0, max_raw = 0; col_cnt = 0;
char ch;
FORi(i,0,n){
int raw = 0;
FORi(j,0,n){
cin >> ch;
x[i][j] = (ch == '#');
cnt += x[i][j];
raw += x[i][j];
}
max_raw = max(max_raw, raw);
}
FORi(j,0,n){
FORi(i,0,n){
if (!black[i][j]){
col_cnt++;
break;
}
}
}
if (!cnt){
cout << -1;
}
return solve(black) + col_cnt;
// if (cnt == n*n){
// cout << 0;
// }
// if (max_raw == n){
// cout << col_cnt;
// }
//
// if (n==2){
// cout << 4 - (black[0][0] || black[1][1] || black[0][1] && black[1][0]);
// }
//
// if (n==3){
// if (max_raw == 1){
// cout << 3 - (black[0][0] || black[1][1] || black[2][2]) + col_cnt;
// }
// }
// PAUSE;
// fin.close();
// fout.close();
return 0;
} | a.cc: In function 'int main()':
a.cc:51:35: error: 'col_cnt' was not declared in this scope
51 | int cnt = 0, max_raw = 0; col_cnt = 0;
| ^~~~~~~
a.cc:57:25: error: 'x' was not declared in this scope
57 | x[i][j] = (ch == '#');
| ^
|
s413273263 | p03792 | C++ | #include <cstring>
#include <cstdint>
#include <iostream>
#include <string>
#include <memory>
#include <queue>
#include <limits>
char color[510][510];
bool writeable_row[510];
int row_black[510];
int tate_black[510];
bool tate_filled[510];
int filled;
int min_whiteid = -1;
int min_white = 1000;
int main() {
int N;
std::cin >> N;
for (int i = 0; i < N; i++) for (int j = 0; j < N; j++)std::cin >> color[i][j];
filled = 0;
for (int i = 0; i < N; i++)
{
writeable_row[i] = false;
tate_black[i] = 0;
row_black[i] = 0;
}
for (int i = 0; i < N; i++)
{
for (int j = 0; j < N; j++)
{
if (color[i][j] == '#') {
writeable_row[j] = true;
row_black[i]++;
tate_black[j]++;
}
}
}
min_white = N + 1;
for (int j = 0; j < N; j++) {
if (writeable_row[j]) {
if (min_white > N - row_black[j]) {
min_white = N - row_black[j];
min_whiteid = j;
}
}
tate_filled[j] = (tate_black[j] == N);
if (row_black[i] == N)filled++;
}
int ans;
if (min_whiteid == -1) {
ans = -1;
}
else {
int tatef_cnt = 0;
for (int i = 0; i < N; i++)
{
if (tate_filled[i])tatef_cnt++;
}
if (filled == N) {
ans = 0;
}
else {
ans = min_white + N - tatef_cnt;
}
}
std::cout << ans;
return 0;
} | a.cc: In function 'int main()':
a.cc:48:31: error: 'i' was not declared in this scope
48 | if (row_black[i] == N)filled++;
| ^
|
s676832026 | p03792 | C++ | #include <bits/stdc++.h>
using namespace std;
long long int N, a[514][514], l[514], c[514], i, j, f, g, ans;
//vector<long long int> low[514], col[514];
vector<pair<long long int, long long int> > vp;
char C;
int main(){
scanf("%lld", &N);
for(i = 0; i < N; ++i){
for(j = 0; j < N; ++j){
scanf(" %c", &C);
a[i][j] = (C == '.') ? 0 : 1;
if(C != '.'){
++f;
//low[i].push_back(j);
//col[j].push_back(i);
++l[i];
++c[j];
}
}
}
if(f == 0)return 0 & puts("-1");
f = count(l, l + N, N);
g = count(c, c + N, N);
//cout << f << " " << g << endl;
if(f > 0)return 0 & printf("%lld\n", N - g);
ans = N * 2 + 1;
/*
cout << " ";
for(i = 0; i < N; ++i){
cout << " " << c[i];
}
cout << endl;
for(i = 0; i < N; ++i){
cout << l[i] << " ";
for(j = 0; j < N; ++j){
cout << a[i][j] << " ";
}
cout << endl;
}
*/
for(i = 0; i <= N; ++i){
//if(c[i] == 0)continue;
ans = min(ans, N * 2 - l[i] - g + (c[i] == 0) ? 0 : 1);
}
cout << ans << endl;
//f = max_element()
return 0;
}
| a.cc: In function 'int main()':
a.cc:46:18: error: no matching function for call to 'min(long long int&, int)'
46 | ans = min(ans, N * 2 - l[i] - g + (c[i] == 0) ? 0 : 1);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:46:18: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
46 | ans = min(ans, N * 2 - l[i] - g + (c[i] == 0) ? 0 : 1);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:46:18: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
46 | ans = min(ans, N * 2 - l[i] - g + (c[i] == 0) ? 0 : 1);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
s115912510 | p03792 | Java | //Not complete
package olymp2;
import java.util.Scanner;
/**
* Created by nickie on 25.02.17 at 14:21
* <p>
* yahoo
*/
public class Task2 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int N = scanner.nextInt();
char grid[][] = new char[N][N];
for (int i = 0; i < N; i++) {
String line = scanner.nextLine();
for (int j = 0; j < N; j++) {
if (line != null && line.length() > j) {
grid[i][j] = line.charAt(j);
} else {
System.out.printf("el in grid(%d,%d) was not written - input trouble\n RETRY", i, j);
line = null;
break;
}
}
}
}
private void copyGrid(char src[][], char dest[][]) {
int N;
if (src != null && dest != null && (N = src.length) == dest.length && N == src[0].length && N == dest[0].length) {
for (int i = 0; i < N; i++) {
System.arraycopy(src[i], 0, dest[i], 0, N);
}
} else {
System.out.println("unmet input parameters, unable to cpy grid");
}
}
private void copyRowToColumn(char src[][]) {
int N = 0;
if (src == null || (N = src.length) != src[0].length) {
System.out.println("copyRowToCol err: null pointer");
}
char dest[][] = new char[N][N];
copyGrid(src, dest);
for (int i = 0; i < N; i++) {
System.arraycopy(src[i], 0, dest[i], 0, N);
}
}
private boolean isPossible(char grid[][]) {
// it's possible if just one element in the whole grid is black (i.e. '#')
// that statement has obvious graphical argumentation, thus it's saving our time
int N;
boolean hasOneHash = false;
if (grid != null && (N = grid.length) >= 2 && N <= 500) {
for (int i = 0; i < N; i++) {
if (!hasOneHash) {
for (int j = 0; j < N; j++) {
if (grid[i][j] == '#') {
hasOneHash = true;
break;
}
}
}
}
}
return hasOneHash;
}
private boolean hasOneHash(char line[]) {
// it's possible if just one element in the whole grid is black (i.e. '#')
// that statement has obvious graphical argumentation, thus it's saving our time
int N;
boolean hasOneHash = false;
if (line != null && (N = line.length) >= 2 && N <= 500) {
for (int i = 0; i < N; i++) {
if (line[i] == '#') {
hasOneHash = true;
break;
}
}
}
return hasOneHash;
}
public int minimum(char grid[][]) {
//the fastest way to accomplish the task is to find one all black raw line on the grid or to make one
//e.g. we have {#.#
// #..
// ... }
//we get needed line in one step: copy transposed (turned at right angle to the right) 2nd row to 2nd column
// {###
// #..
// ... } then easily 1r -> 1c
// {###
// #..
// #.. } 1r -> 2c
// {###
// ##.
// ##. } finally 1r -> 3c
// {###
// ###
// ### } finally 1r -> 3c
//now we have empirical formula of getting the fastest solution: n = bR + N - bC
//which means n (minimum number of steps needed) equals to bR (steps needed to make one all-black row)
// plus N (length of square matrix) minus bC (already black columns)
if (isPossible(grid)) {
int minimum = 0;
int N = grid.length;
for (int i = 0; i < N; i++) {
char gridCopy[][] = new char[N][N];
copyGrid(grid, gridCopy);
minimum = 0;
for (int j = 0; j < N; j++) {
if (hasOneHash(gridCopy[j])) {
minimum++;
for (int k = j + 1; k < N; k++) {
if (hasOneHash(gridCopy[k])) {
}
}
}
}
}
return minimum;
} else {
return -1;
}
}
}
| Main.java:13: error: class Task2 is public, should be declared in a file named Task2.java
public class Task2 {
^
1 error
|
s491418321 | p03792 | C++ | #include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <map>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <set>
#include <queue>
#include <list>
using namespace std;
char s[505][505];
int x[505],y[505];
int main()
{
int n;
scanf("%d",&n);
getchar();
for(int i=1;i<=n;++i) gets(s[i]+1);
for(int i=1;i<=n;++i)
{
for(int j=1;j<=n;++j)
{
if(s[i][j]=='#'){
++x[i],++y[j];
}
}
}
int mii=0x3f3f3f3f,ki=-1;
for(int i=1;i<=n;++i)
{
//cout<<x[i]<<' ';
if(x[i]==n)
{
mii=0;
ki=i;
break;
}
else if(y[i]&&n-x[i]<mii)
{
mii=n-x[i];
ki=i;
}
}
//cout<<endl;
if(mii==0x3f3f3f3f)
printf("-1");
else
{
//cout<<mii<<endl;
int ff=0;
for(int j=1;j<=n;++j)
{
if(y[j]==n) ++ff;
}
//cout<<ff<<endl;
printf("%d",mii+n-ff);
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:24:27: error: 'gets' was not declared in this scope; did you mean 'getw'?
24 | for(int i=1;i<=n;++i) gets(s[i]+1);
| ^~~~
| getw
|
s889281849 | p03792 | C++ | #include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <map>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <set>
#include <queue>
#include <list>
using namespace std;
char s[505][505];
int x[505],y[505];
int main()
{
int n;
scanf("%d",&n);
getchar();
for(int i=1;i<=n;++i) gets(s[i]+1);
for(int i=1;i<=n;++i)
{
for(int j=1;j<=n;++j)
{
if(s[i][j]=='#'){
++x[i],++y[j];
}
}
}
int mii=0x3f3f3f3f,ki=-1;
for(int i=1;i<=n;++i)
{
//cout<<x[i]<<' ';
if(x[i]==n)
{
mii=0;
ki=i;
break;
}
else if(y[i]&&n-x[i]<mii)
{
mii=n-x[i];
ki=i;
}
}
//cout<<endl;
if(mii==0x3f3f3f3f)
printf("-1");
else
{
//cout<<mii<<endl;
int ff=0;
for(int j=1;j<=n;++j)
{
if(y[j]==n) ++ff;
}
//cout<<ff<<endl;
printf("%d",mii+n-ff);
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:24:27: error: 'gets' was not declared in this scope; did you mean 'getw'?
24 | for(int i=1;i<=n;++i) gets(s[i]+1);
| ^~~~
| getw
|
s358055693 | p03792 | C++ | #include <iostream>
#include <vector>
#include <cmath>
using namespace std;
vector<vector<char> > ch(vector< vector<char> > mp, int a, int b, int n) {
vector< vector<char> > mpp = mp;
for (int i = 0; i < n; i++) {
mpp[i][b] = mp[a][i];
}
return mpp;
}
int cc(vector< vector<char> > mp, int n) {
bool h = true;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (mp[i][j] != "#") {
h = false;
}
}
}
if (h) {
return 0;
} else {
int a = 10;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
a = min(a, 1+cc(ch(mp, i, j, n), n))
}
}
return a;
}
}
int main() {
int n;
cin >> n;
vector< vector<char> > mp(n, vector<char>(n));
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
cin >> mp[i][j];
}
}
cout << cc(mp, n) << endl;
return 0;
} | a.cc: In function 'int cc(std::vector<std::vector<char> >, int)':
a.cc:19:38: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
19 | if (mp[i][j] != "#") {
a.cc:30:69: error: expected ';' before '}' token
30 | a = min(a, 1+cc(ch(mp, i, j, n), n))
| ^
| ;
31 | }
| ~
|
s983567092 | p03792 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------
int N;
vector<string> S;
int ret;
int R[501],C[501];
void solve() {
int i,j,k,l,r,x,y; string s;
cin>>N;
int ok=0;
FOR(y,N) {
cin>>s;
S.push_back(s);
FOR(x,N) {
if(S[y][x]=='#') {
ok++;
R[y]++;
C[x]++;
}
}
}
if(ok==0) {
cout<<-1<<endl;
return;
}
int ok=0;
FOR(i,N) if(S[i][i]=='#') ok++;
assert(ok);
int mi=101010;
FOR(y,N) if(R[y]==N) {
int num=0;
FOR(x,N) if(C[x]!=N) num++;
mi=min(mi,num);
}
FOR(y,N) FOR(x,N) if(S[y][x]=='#') {
int num=0;
FOR(i,N) {
if(S[x][i]=='#') {
if(C[i]!=N) num++;
}
else {
num+=2;
}
}
mi=min(mi,num);
}
FOR(y,N) {
int num=0;
FOR(x,N) {
if(S[y][x]=='.') {
FOR(i,N) if(S[x][i]=='#') {
num+=3;
break;
}
if(i==N) break;
}
else {
if(C[x]!=N) num++;
}
}
if(x==N) mi=min(mi,num);
}
cout<<mi<<endl;
}
int main(int argc,char** argv){
string s;int i;
if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
FOR(i,argc-1) s+=argv[i+1],s+='\n';
FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
FOR(i,1) {
S.clear();
ZERO(R);
ZERO(C);
solve();
}
return 0;
}
| a.cc: In function 'void solve()':
a.cc:42:13: error: redeclaration of 'int ok'
42 | int ok=0;
| ^~
a.cc:25:13: note: 'int ok' previously declared here
25 | int ok=0;
| ^~
|
s879894958 | p03792 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
int ret = 2000;
int N;
string c[510];
bool all[510];
bool ex[510];
int d[510];
int main() {
cin >> N;
bool ng = 1;
queue<int> que;
memset(d, -1, sizeof(d));
rep(i, N) {
cin >> c[i];
rep(j, N) {
if (c[i][j] == '#') {
ex[j] = 1;
d[j] = 0;
que.push(j);
ng = 0;
}
}
}
while (!que.empty()) {
int v = que.front(); que.pop();
rep(j, N) if (c[i][j] == '#') {
if (d[j] == -1) {
d[j] = d[v] + 1;
que.push(j);
}
}
}
if (ng) {
puts("-1");
return 0;
}
rep(j, N) {
all[j] = 1;
rep(i, N) if (c[i][j] != '#') {
all[j] = 0;
}
}
rep(i, N) {
bool ok = 1;
rep(j, N) if (c[i][j] != '#') {
ok = 0;
}
if (ok) {
int sm = 0;
rep(j, N) {
if (!all[j]) ++sm;
}
ret = min(ret, sm);
}
}
rep(i, N) {
set<int> us;
memset(d, -1, sizeof(d));
//if (ex[i]) {
rep(j, N) if (c[i][j] != '#') {
us.insert(j);
}
if (us.size() == 0) {
continue;
}
int cnt = 0;
rep(j, N) {
bool t = 1;
if (!us.count(j)) {
++cnt;
} else {
if (!all[j]) {
++cnt;
}
}
}
int t = (int)us.size() + cnt + d[i];
//if (!ex[i]) ++t;
ret = min(ret, t);
//}
}
cout << ret << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:47:33: error: 'i' was not declared in this scope
47 | rep(j, N) if (c[i][j] == '#') {
| ^
|
s981654503 | p03792 | C++ | #include <iostream>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
int main() {
int n;
cin >> n;
vector< vector<char> > mp(n, vector<char>(n));
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
cin >> mp[i][j];
}
}
vector<int> d(n, 0);
vector<int> d2(n, 0);
int MAX = 0;
int aa = 0;
int MAX2 = 0;
vector<string> ss(n);
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (mp[i][j] == '#') {
d[i]++;
aa++;
ss[i] += mp[i][j];
}
if (mp[j][i] == '#') {
d2[i]++;
}
}
MAX = max(MAX, d[i]);
MAX2 = max(MAX2, d2[i]);
}
if (n == 2) {
if (aa == 4) {
cout << 0 << endl;
} else if (aa == 3) {
cout << 1 << endl;
} else if (MAX == 2 || MAX2 == 2) {
cout << 2 << endl;
} else if (aa == 2 || s[0] == "#." || s[1] == ".#") {
cout << 3 << endl;
} else if (aa == 1){
cout << 4 << endl;
} else {
cout << -1 << endl;
}
} else {
if (MAX == 3) {
int a = 0;
for (int i = 0; i < 3; i++) {
if (d2[i] != 3) {
a++;
}
}
cout << a << endl;
} else if (aa == 0){
cout << -1 << endl;
} else if (aa == 1 && (ss[0] == ".#." || ss[2] == ".#." || ss[1] == "#.." || ss[1] == "..#")) {
cout << 6 << endl;
} else if (aa == 1) {
cout << 5 << endl;
} else if (ss[0] == "##." || ss[1] == "##.") {
int a = 2;
for (int i = 0; i < 3; i++) {
if (d2[i] != 3 && i != 2) {
a++;
}
}
cout << a << endl;
} else if (ss[1] == ".##" || ss[2] == ".##") {
int a = 2;
for (int i = 0; i < 3; i++) {
if (d2[i] != 3 && i != 0) {
a++;
}
}
cout << a << endl;
} else if (ss[0] == "#.#" || ss[2] == "#.#") {
int a = 2;
for (int i = 0; i < 3; i++) {
if (d2[i] != 3 && i != 1) {
a++;
}
}
cout << a << endl;
} else {
int a = 2;
for (int i = 0; i < 3; i++) {
if (d2[i] != 3) {
a++;
}
}
cout << a << endl;
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:44:39: error: 's' was not declared in this scope; did you mean 'ss'?
44 | } else if (aa == 2 || s[0] == "#." || s[1] == ".#") {
| ^
| ss
|
s139917694 | p03792 | C++ | #include <iostream>
#include <vector>
#include <queue>
using namespace std;
class Board{
public:
Board(int n){
vector<char> tmp;
for(int i=0;i<n;i++){
tmp.push_back('#');
}
for(int i=0;i<n;i++){
board.push_back(tmp);
}
cost = 0;
size = n;
}
vector<vector<char> > board;
int getNumBlack() const{
int count = 0;
for(int i=0;i<size;i++){
for(int j=0;j<size;j++){
if(board[i][j] == '#')
count++;
}
}
return count;
}
int getWhite() const{
return size*size - getNumBlack();
}
int whiteColumn() const{
int count = 0;
for(int i=0;i<size;i++){
bool flag = false;
for(int j=0;j<size;j++){
if(board[j][i] == '.')
flag = true;
}
if(flag)
count++;
}
return count;
}
int eval() const{
/* return cost + getWhite(); */
return cost + whiteColumn();
}
int size;
int cost;
Board change(int i, int j){
Board newOne(size);
for(int k=0;k<size;k++){
for(int l=0;l<size;l++){
newOne.board[k][l] = this->board[k][l];
}
}
vector<char> tmp;
for(int k=0;k<size;k++){
tmp.push_back(this->board[i][k]);
}
for(int k=0;k<size;k++){
newOne.board[k][j] = tmp[k];
}
newOne.cost = this->cost + 1;
return newOne;
}
bool goal(){
return getNumBlack() == size*size;
}
void print(){
for(int i=0;i<size;i++){
for(int j=0;j<size;j++){
cout << board[i][j];
}
cout << endl;
}
cout << endl;
}
};
bool operator<(const Board& ls, const Board& rs){
return ls.eval() < rs.eval();
}
bool operator>(const Board& ls, const Board& rs){
return ls.eval() > rs.eval();
}
bool same(Board b1, Board b2){
for(int i=0;i<b1.size;i++){
for(int j=0;j<b1.size;j++){
if(b1.board[i][j] != b2.board[i][j])
return false;
}
}
return true;
}
bool exist(vector<Board> v, Board b){
if (v.size() == 0)
return false;
for(int i=0;i<v.size();i++){
for(int j=0;j<b.size;j++){
for(int k=0;k<b.size;k++){
if(v[i].board[j][k] != b.board[j][k])
return false;
}
}
}
return true;
}
int astar(priority_queue<Board,vector<Board>, greater<Board> > openList, vector<Board> closedList){
while(!openList.empty()){
Board b = openList.top();
/* b.print(); */
openList.pop();
if (b.goal())
return b.cost;
else{
for(int i=0;i<b.size;i++){
for(int j=0;j<b.size;j++){
Board newOne = b.change(i,j);
//closedList check
if ((!same(b,newOne)) &&(!exist(closedList, newOne)) ){
openList.push(newOne);
closedList.push_back();
}
}
}
closedList.push_back(b);
}
}
return -1;
}
int main(){
int n; cin >> n;
char c;
Board b(n);
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
cin >> c;
b.board[i][j] = c;
}
}
priority_queue<Board, vector<Board>, greater<Board> > openList;
vector<Board> closedList;
openList.push(b);
cout << astar(openList, closedList) << endl;
}
| a.cc: In function 'int astar(std::priority_queue<Board, std::vector<Board>, std::greater<Board> >, std::vector<Board>)':
a.cc:131:45: error: no matching function for call to 'std::vector<Board>::push_back()'
131 | closedList.push_back();
| ~~~~~~~~~~~~~~~~~~~~^~
In file included from /usr/include/c++/14/vector:66,
from a.cc:2:
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = Board; _Alloc = std::allocator<Board>; value_type = Board]'
1283 | push_back(const value_type& __x)
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = Board; _Alloc = std::allocator<Board>; value_type = Board]'
1300 | push_back(value_type&& __x)
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate expects 1 argument, 0 provided
|
s136249230 | p03792 | C++ | #include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int n,a[505][505],b[505],Ans,Mn;
char nc()
{
char c=getchar();
while(c!='#'&&c!='.') c=getchar();
return c;
}
int main()
{
scanf("%d",&n);
for (int i=1;i<=n;i++)b[i]=1;
for (int i=1;i<=n;i++)
for (int j=1;j<=n;j++)
a[i][j]=(nc()=='#'),b[j]&=a[i][j],sum+=b[j];
if (!sum) return puts("-1"),0;
for (int i=1;i<=n;i++)
if (!b[i]) Ans++;
Mn=100000000;
for (int i=1;i<=n;i++)
{
int t=0,now=0;
for (int j=1;j<=n;j++)
if (a[j][i]) {t=j;break;}
if (t==0) now++;
for (int j=1;j<=n;j++)
if (!a[i][j]) now++;
Mn=min(Mn,now);
}
if (Mn==100000000)
puts("-1");
else printf("%d\n",Mn+Ans);
}
| a.cc: In function 'int main()':
a.cc:18:51: error: 'sum' was not declared in this scope
18 | a[i][j]=(nc()=='#'),b[j]&=a[i][j],sum+=b[j];
| ^~~
a.cc:19:14: error: 'sum' was not declared in this scope
19 | if (!sum) return puts("-1"),0;
| ^~~
|
s213681633 | p03792 | C++ | #include <cstring>
#include <cstdint>
#include <iostream>
#include <string>
#include <memory>
#include <queue>
#include <limits>
char color[510][510];
char writeable_row[510];
int row_black[510];
int tate_black[510];
bool tate_filled[510];
int filled;
int min_whiteid = -1;
int min_white = INT_MAX;
int main() {
int N;
std::cin >> N;
for (int i = 0; i < N; i++) for (int j = 0; j < N; j++)std::cin >> color[i][j];
filled = 0;
for (int i = 0; i < N; i++)
{
tate_black[i] = 0;
row_black[i] = 0;
for (int j = 0; j < N; j++)
{
if (color[j][i] == '#') {
tate_black[i]++;
}
if (color[i][j] == '#') {
writeable_row[j] |= 1;
row_black[i]++;
}
if (row_black[i] == N)filled++;
}
}
min_white = N;
for (int j = 0; j < N; j++) {
if (writeable_row[j]) {
if (min_white > N - row_black[j]) {
min_white = N - row_black[j];
min_whiteid = j;
}
}
tate_filled[j] = (tate_black[j] == N);
}
int ans;
if (min_whiteid == -1) {
ans = -1;
}
else {
int tatef_cnt = 0;
for (int i = 0; i < N; i++)
{
if (tate_filled[i] && (color[min_whiteid][i] == '#'))tatef_cnt++;
}
if (filled == N) {
ans = 0;
}
else {
ans = min_white + N - tatef_cnt;
}
}
std::cout << ans;
return 0;
}
| a.cc:16:17: error: 'INT_MAX' was not declared in this scope
16 | int min_white = INT_MAX;
| ^~~~~~~
a.cc:8:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
7 | #include <limits>
+++ |+#include <climits>
8 |
|
s919078419 | p03792 | C++ | #include <iostream>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
int main() {
int n;
cin >> n;
vector< vector<char> > mp(n, vector<char>(n));
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
cin >> mp[i][j];
}
}
vector<int> d(n, 0);
vector<int> d2(n, 0);
int MAX = 0;
int aa = 0;
int MAX2 = 0;
vector<string> ss(n);
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (mp[i][j] == '#') {
d[i]++;
aa++;
ss[i] += mp[i][j];
}
if (mp[j][i] == '#') {
d2[i]++;
}
}
MAX = max(MAX, d[i]);
MAX2 = max(MAX2, d2[i]);
}
if (n == 2) {
if (aa == 4) {
cout << 0 << endl;
} else if (aa == 3) {
cout << 1 << endl;
} else if (MAX == 2 || MAX2 == 2) {
cout << 2 << endl;
} else if (aa == 2 || aa == 1) {
cout << 3 << endl;
} else {
cout << -1 << endl;
}
} else {
if (MAX == 3) {
int a = 0;
for (int i = 0; i < 3; i++) {
if (d2[i] != 3) {
a++;
}
}
cout << a << endl;
} else if (aa == 0){
cout << -1 << endl;
} else if (aa == 1) {
cout << 5 << endl;
} else if (s[0] == "##." || s[1] == "##." || s[1] == ".##" || s[2] == ".##" || s[0] == "#.#" || s[2] == "#.#") {
int a = 1;
for (int i = 0; i < 3; i++) {
if (d2[i] != 3) {
a++;
}
}
cout << a << endl;
} else {
int a = 2;
for (int i = 0; i < 3; i++) {
if (d2[i] != 3) {
a++;
}
}
cout << a << endl;
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:62:28: error: 's' was not declared in this scope; did you mean 'ss'?
62 | } else if (s[0] == "##." || s[1] == "##." || s[1] == ".##" || s[2] == ".##" || s[0] == "#.#" || s[2] == "#.#") {
| ^
| ss
|
s693915241 | p03792 | C++ | #include <cstdio>
#include <queue>
#include <iostream>
#include <cstring>
using namespace std;
int n;
string board[505];
int dist[505][505];
int main() {
scanf("%d", &n);
for (int i = 0; i < n; i++) {
cin >> board[i];
}
memset(dist, -1, sizeof dist);
queue< pair<int,int> > q;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (board[i][j] == '#') {
dist[i][j] = 0;
q.push(make_pair(i, j));
}
}
}
while (!q.empty()) {
int ux = q.front().first, uy = q.front().second;
q.pop();
for (int j = 0; j < n; j++) {
if (dist[uy][j] < 0) {
dist[uy][j] = dist[ux][uy] + 1;
q.push(make_pair(uy, j));
}
}
}
int empty_cols = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) if (board[i][j] == '.') {
empty_cols++;
break;
}
}
int ret = -1;
for (int i = 0; i < n; i++) {
sort(dist[i], dist[i] + n);
if (dist[i][0] < 0) {
continue;
}
int total_dist = 0, cnt = 0;
for (int j = 0; j < n; j++) {
if (dist[i][j] > 0) {
while (cnt + 1 < dist[i][j]) {
total_dist++;
cnt++;
}
total_dist++;
cnt = dist[i][j];
}
}
if (ret < 0 || ret > total_dist + empty_cols) {
ret = total_dist + empty_cols;
}
}
printf("%d\n", ret);
return 0;
} | a.cc: In function 'int main()':
a.cc:46:17: error: 'sort' was not declared in this scope; did you mean 'short'?
46 | sort(dist[i], dist[i] + n);
| ^~~~
| short
|
s364115368 | p03792 | C++ | // package atcoder.other2017.mujin2017;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
public class Main {
static final int INF = 100000;
public static void main(String[] args) {
InputReader in = new InputReader(System.in);
PrintWriter out = new PrintWriter(System.out);
int n = in.nextInt();
int[][] basetbl = new int[n][n];
for (int i = 0; i < n ; i++) {
char[] row = in.nextToken().toCharArray();
for (int j = 0; j < n ; j++) {
basetbl[i][j] = row[j] == '.' ? 0 : 1;
}
}
int ret = solve2(basetbl);
out.println(ret >= INF ? -1 : ret);
out.flush();
}
static int solve2(int[][] basetbl) {
int n = basetbl.length;
boolean hasOne = false;
for (int i = 0; i < n ; i++) {
for (int j = 0; j < n ; j++) {
hasOne |= basetbl[i][j] == 1;
}
}
if (!hasOne) {
return INF;
}
int[] tr = new int[n];
for (int i = 0; i < n ; i++) {
int[][] tbl = clone2(basetbl);
int time = 0;
if (tbl[i][i] == 0) {
boolean hasSub = false;
for (int j = 0; j < n ; j++) {
if (tbl[j][i] == 1) {
hasSub = true;
}
}
if (!hasSub) {
for (int j = 0; j < n; j++) {
int cnt = 0;
for (int k = 0; k < n; k++) {
cnt += tbl[j][k];
}
if (cnt >= 1) {
int[] tmp = tbl[j].clone();
for (int k = 0; k < n; k++) {
tbl[k][i] = tmp[k];
}
time++;
break;
}
}
}
for (int j = 0; j < n ; j++) {
if (tbl[j][i] == 1) {
int[] tmp = tbl[j].clone();
for (int k = 0; k < n ; k++) {
tbl[k][i] = tmp[k];
}
time++;
break;
}
}
}
int[] tmp = tbl[i].clone();
for (int j = 0; j < n ; j++) {
if (tbl[i][j] == 0) {
for (int k = 0; k < n ; k++) {
tbl[k][j] = tmp[k];
}
time++;
}
}
for (int j = 0; j < n ; j++) {
int cnt = 0;
for (int k = 0; k < n ; k++) {
cnt += tbl[k][j];
}
time += cnt < n ? 1 : 0;
}
tr[i] = time;
}
int ret = INF;
for (int i = 0; i < n ; i++) {
ret = Math.min(ret, tr[i]);
}
return ret;
}
static int[][] clone2(int[][] a) {
int[][] b = new int[a.length][];
for (int i = 0; i < a.length; i++) {
b[i] = a[i].clone();
}
return b;
}
static class InputReader {
private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
private int numChars;
public InputReader(InputStream stream) {
this.stream = stream;
}
private int[] nextInts(int n) {
int[] ret = new int[n];
for (int i = 0; i < n; i++) {
ret[i] = nextInt();
}
return ret;
}
private int[][] nextIntTable(int n, int m) {
int[][] ret = new int[n][m];
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
ret[i][j] = nextInt();
}
}
return ret;
}
private long[] nextLongs(int n) {
long[] ret = new long[n];
for (int i = 0; i < n; i++) {
ret[i] = nextLong();
}
return ret;
}
private long[][] nextLongTable(int n, int m) {
long[][] ret = new long[n][m];
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
ret[i][j] = nextLong();
}
}
return ret;
}
private double[] nextDoubles(int n) {
double[] ret = new double[n];
for (int i = 0; i < n; i++) {
ret[i] = nextDouble();
}
return ret;
}
private int next() {
if (numChars == -1)
throw new InputMismatchException();
if (curChar >= numChars) {
curChar = 0;
try {
numChars = stream.read(buf);
} catch (IOException e) {
throw new InputMismatchException();
}
if (numChars <= 0)
return -1;
}
return buf[curChar++];
}
public char nextChar() {
int c = next();
while (isSpaceChar(c))
c = next();
if ('a' <= c && c <= 'z') {
return (char) c;
}
if ('A' <= c && c <= 'Z') {
return (char) c;
}
throw new InputMismatchException();
}
public String nextToken() {
int c = next();
while (isSpaceChar(c))
c = next();
StringBuilder res = new StringBuilder();
do {
res.append((char) c);
c = next();
} while (!isSpaceChar(c));
return res.toString();
}
public int nextInt() {
int c = next();
while (isSpaceChar(c))
c = next();
int sgn = 1;
if (c == '-') {
sgn = -1;
c = next();
}
int res = 0;
do {
if (c < '0' || c > '9')
throw new InputMismatchException();
res *= 10;
res += c-'0';
c = next();
} while (!isSpaceChar(c));
return res*sgn;
}
public long nextLong() {
int c = next();
while (isSpaceChar(c))
c = next();
long sgn = 1;
if (c == '-') {
sgn = -1;
c = next();
}
long res = 0;
do {
if (c < '0' || c > '9')
throw new InputMismatchException();
res *= 10;
res += c-'0';
c = next();
} while (!isSpaceChar(c));
return res*sgn;
}
public double nextDouble() {
return Double.valueOf(nextToken());
}
public boolean isSpaceChar(int c) {
return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
}
public interface SpaceCharFilter {
public boolean isSpaceChar(int ch);
}
}
static void debug(Object... o) {
System.err.println(Arrays.deepToString(o));
}
}
| a.cc:3:1: error: 'import' does not name a type
3 | import java.io.IOException;
| ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
4 | import java.io.InputStream;
| ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: 'import' does not name a type
5 | import java.io.PrintWriter;
| ^~~~~~
a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:1: error: 'import' does not name a type
6 | import java.util.Arrays;
| ^~~~~~
a.cc:6:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:7:1: error: 'import' does not name a type
7 | import java.util.InputMismatchException;
| ^~~~~~
a.cc:7:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:9:1: error: expected unqualified-id before 'public'
9 | public class Main {
| ^~~~~~
|
s015347493 | p03792 | C++ | #include <cstdio>
#include <queue>
#include <climits>
#include <vector>
#include <algorithm>
using namespace std;
char dat[510][510];
int solve(vector<string> dat) {
int n = dat.size();
int ans = INT_MAX;
vector<int> colwhite(n), rowwhite(n);
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (dat[i][j] == '.') {
rowwhite[i]++;
colwhite[j]++;
}
}
}
for (int i = 0; i < n; i++) {
int repaint = 0;
int holecnt = 0;
for (int k = 0; k < n; k++) {
if (dat[i][k] == '#') {
if (colwhite[k] > 0) {
repaint++;
}
}
else {
holecnt++;
}
}
if (holecnt == 0) {
int cur = repaint;
ans = min(ans, cur);
continue;
}
for (int j = 0; j < n; j++) {
if (dat[j][i] != '#')
continue;
int cur = holecnt;
cur += repaint;
if (rowwhite[j] > 0) {
cur += holecnt;
}
ans = min(ans, cur);
}
if (holecnt < n && dat[i][i] == '.') { // at least one #
int cur = 1 + holecnt;
cur += repaint;
cur += holecnt;
ans = min(ans, cur);
}
}
if (ans == INT_MAX)
ans = -1;
return ans;
}
int main() {
int n;
scanf("%d", &n);
vector<string> inp;
for (int i = 0; i < n; i++) {
scanf("%s", dat[i]);
inp.emplace_back(dat[i]);
}
printf("%d\n", solve(inp));
return 0;
} | a.cc:13:18: error: 'string' was not declared in this scope
13 | int solve(vector<string> dat) {
| ^~~~~~
a.cc:6:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
5 | #include <algorithm>
+++ |+#include <string>
6 |
a.cc:13:24: error: template argument 1 is invalid
13 | int solve(vector<string> dat) {
| ^
a.cc:13:24: error: template argument 2 is invalid
a.cc: In function 'int solve(int)':
a.cc:14:15: error: request for member 'size' in 'dat', which is of non-class type 'int'
14 | int n = dat.size();
| ^~~~
a.cc:20:14: error: invalid types 'int[int]' for array subscript
20 | if (dat[i][j] == '.') {
| ^
a.cc:31:14: error: invalid types 'int[int]' for array subscript
31 | if (dat[i][k] == '#') {
| ^
a.cc:46:14: error: invalid types 'int[int]' for array subscript
46 | if (dat[j][i] != '#')
| ^
a.cc:55:27: error: invalid types 'int[int]' for array subscript
55 | if (holecnt < n && dat[i][i] == '.') { // at least one #
| ^
a.cc: In function 'int main()':
a.cc:71:10: error: 'string' was not declared in this scope
71 | vector<string> inp;
| ^~~~~~
a.cc:71:10: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
a.cc:71:16: error: template argument 1 is invalid
71 | vector<string> inp;
| ^
a.cc:71:16: error: template argument 2 is invalid
a.cc:74:9: error: request for member 'emplace_back' in 'inp', which is of non-class type 'int'
74 | inp.emplace_back(dat[i]);
| ^~~~~~~~~~~~
|
s105201973 | p03792 | C++ | #include<bits/stdc++.h>
using namespace std;
int main()
{
int n,maxi=0,i,j,row[10005],col[1000],in,c1=0,c2=0;
char a[600][600];
scanf("%d",&n);
for(i=0;i<n;i++)
{
int c=0;
for(j=0;j<n;j++)
{
scanf(" %c",&a[i][j]);
if(a[i][j]=='#')
c++,c2++;
}
row[i]=c;
if(row[i]>maxi)
maxi=row[i],in=i;
}
if(c2==0)
{
printf("-1");
return 0;
}
for(i=0;i<n;i++)
{
int c=0;
for(j=0;j<n;j++)
{
//scanf(" %c",&a[i][j]);
if(a[j][i]=='#')
c++;
}
col[i]=c;
}
for(i=0;i<n;i++)
{
if(a[in][i]=='.')
{
if(maxi==n)
continue;
c++;
}
else
{
if(col[i]<n)
c++;
}
}
printf("%d",c1+n-maxi);
} | a.cc: In function 'int main()':
a.cc:46:25: error: 'c' was not declared in this scope
46 | c++;
| ^
a.cc:51:25: error: 'c' was not declared in this scope
51 | c++;
| ^
|
s300033995 | p03792 | C++ | #include <bits/stdc++.h>
using namespace std;
#define For(i,l,r) for (int i = l; i <= r; ++i)
#define Cor(i,l,r) for (int i = l; i >= r; --i)
int n;
char A[555][555];g
int main() {
cin >> n;
For(i,1,n) scanf("%s", A[i] + 1);
int full_col = 0;
bool full_row = 0;
For(i,1,n) {
bool x = true;
For(j,1,n) if (A[i][j] == '.') { x = false ; break ; }
full_row |= x;
x = true;
For(j,1,n) if (A[j][i] == '.') { x = false ; break ; }
full_col += x;
}
int ans = n + n + 1;
if (full_row) {
ans = n - full_col;
} else {
For(i,1,n) For(j,1,n) if (A[i][j] == '#') {
int leak = 0;
For(k,1,n) if (A[j][k] == '.') ++leak;
ans = min(ans, leak + n - full_col);
}
}
if (ans >= n + n) puts("-1"); else cout << ans << endl;
return 0;
} | a.cc:8:18: error: 'g' does not name a type
8 | char A[555][555];g
| ^
|
s683752394 | p03792 | C++ | int main(){
int ans = -1;
cout << ans << endl;
} | a.cc: In function 'int main()':
a.cc:3:1: error: 'cout' was not declared in this scope
3 | cout << ans << endl;
| ^~~~
a.cc:3:16: error: 'endl' was not declared in this scope
3 | cout << ans << endl;
| ^~~~
|
s840457230 | p03792 | C++ | int main(){
cout << -1 << endl;
} | a.cc: In function 'int main()':
a.cc:2:1: error: 'cout' was not declared in this scope
2 | cout << -1 << endl;
| ^~~~
a.cc:2:15: error: 'endl' was not declared in this scope
2 | cout << -1 << endl;
| ^~~~
|
s729841306 | p03792 | C++ | #include <vector>
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <cstdio>
#include <utility>
#include <bitset>
#include <complex>
#include <stack>
#include <tuple>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const ll INF = 1e7;
int main(){
int N;
cin >> N;
vector<string> area(N);
for(int i=0;i<N;i++)
cin >> area[i];
vector<int> todo;
for(int x=0;x<N;x++){
bool flag=false;
for(int y=0;y<N;y++){
if(area[y][x]=='.')
flag=true;
}
if(flag)
todo.push_back(x);
}
ll ans=INF;
for(int base=0;base<N;base++){
int cost=INF;
bool flag=true;
for(int x=0;x<N;x++)
if(area[base][x]=='.')
flag=false;
if(flag)
cost=0;
else{
bool exist=false;
for(int y=0;y<N;y++){
if(area[y][base]=='#')
exist=true;
}
if(exist){
cost=0;
for(int x=0;x<N;x++)
if(area[base][x]=='.')
cost++;
}
}
ans=min(ans,(ll)cost+todo.size());
}
if(ans==INF)
cout << -1 << endl;
else
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:58:24: error: no matching function for call to 'min(ll&, long long unsigned int)'
58 | ans=min(ans,(ll)cost+todo.size());
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/vector:62,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:58:24: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
58 | ans=min(ans,(ll)cost+todo.size());
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:5:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:58:24: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
58 | ans=min(ans,(ll)cost+todo.size());
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
|
s970841326 | p03792 | C++ | #include <vector>
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <cstdio>
#include <utility>
#include <bitset>
#include <complex>
#include <stack>
#include <tuple>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const ll INF = 1e7;
int main(){
int N;
cin >> N;
vector<string> area(N);
for(int i=0;i<N;i++)
cin >> area[i];
vector<int> not;
for(int x=0;x<N;x++){
bool flag=false;
for(int y=0;y<N;y++){
if(area[y][x]=='.')
flag=true;
}
if(flag)
not.push_back(x);
}
ll ans=INF;
for(int base=0;base<N;base++){
int cost=INF;
bool flag=true;
for(int x=0;x<N;x++)
if(area[base][x]=='.')
flag=false;
if(flag)
cost=0;
else{
bool exist=false;
for(int y=0;y<N;y++){
if(area[y][base]=='#')
exist=true;
}
if(exist){
cost=0;
for(int x=0;x<N;x++)
if(area[base][x]=='.')
cost++;
}
}
ans=min(ans,(ll)cost+not.size());
}
if(ans==INF)
cout << -1 << endl;
else
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:26:21: error: expected unqualified-id before 'not' token
26 | vector<int> not;
| ^~~
a.cc:34:28: error: expected primary-expression before '.' token
34 | not.push_back(x);
| ^
a.cc:58:41: error: expected primary-expression before '.' token
58 | ans=min(ans,(ll)cost+not.size());
| ^
|
s801802972 | p03793 | C++ | //#pragma GCC optimize(2)
//#include<bits/stdc++.h>
//using namespace std;
//stack <char> q;
//char a[1200000];
//inline int read() {
// int X=0,w=0;
// char ch=0;
// while(!isdigit(ch)) {
// w|=ch=='-';
// ch=getchar();
// }
// while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
// return w?-X:X;
//}
//int main() {
// freopen("fusion.in","r",stdin);
// freopen("fusion.out","w",stdout);
// scanf("%s",a+1);
// int m;
// cin>>m;
// for(int i=1; i<=m; i++) {
// int x,y;
// x=read();
// y=read();
// while(!q.empty()) q.pop();
// for(int j=x; j<=y; j++) {
// if(q.empty()) {
// q.push(char(a[j]));
// continue;
// }
// char w=q.top();
// char at=a[j];
// q.push((char)a[j]);
// if(w==at) {
//L1:
// ;
// if(w=='z') {
// q.pop();
// q.pop();
// } else {
// q.pop();
// q.pop();
//
// at=(char)w+1;
// if(q.empty()) {
// q.push(at);
// continue;
// }
// w=q.top();
// q.push(at);
// if(at==w) goto L1;
// }
// }
// }
// if(q.empty()) puts("Yes");
// else puts("No");
// }
// return 0;
//}
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
char s[560000];
int n,m;
int to[560000][30],nxt[560000][30];
inline int read() {
int ret=0;
char c=getchar();
while((c>'9')||(c<'0'))c=getchar();
while((c>='0')&&(c<='9'))ret=(ret<<1)+(ret<<3)+c-'0',c=getchar();
return ret;
}
void pre() {
for(int i=1; i<=n+2; i++) {
for(int j=0; j<=26; j++) to[i][j]=n+2;
for(int j=0; j<=19; j++) nxt[i][j]=n+2;
}
for(int i=n; i; i--) {
to[i][s[i]]=i+1;//更新自己这一位
for(int j=s[i]+1; j<=26; j++) to[i][j]=to[to[i][j-1]][j-1]; //从k变到j(合并操作)
nxt[i][0]=to[i][26];//记录消除完的情况
for(int j=1; j<20; j++) nxt[i][j]=nxt[nxt[i][j-1]][j-1]; //更新多段消除完的情况
for(int j=0; j<26; j++) if(to[i][j]==n+2) to[i][j]=to[nxt[i][0]][j]; //如azzabcd…即对于前面没有算出东西的情况中,先消除掉一部分再进行计算。
}
}
bool check(int l,int r) {
for(int i=19; i>=0; i--) {
if(nxt[l][i]==r+1) return true;
if(nxt[l][i]<=r) l=nxt[l][i];
}
return false;
}
int main() {
// freopen("fusion.in","r",stdin);
// freopen("fusion.out","w",stdout);
scanf("%s",s+1);
n=strlen(s+1);
for(int i=1; i<=n; i++) s[i]-='a';
pre();
w=read();
while(m--) {
int l=read(),r=read();
if(check(l,r)) puts("Yes");
else puts("No");
}
return 0;
} | a.cc: In function 'int main()':
a.cc:141:9: error: 'w' was not declared in this scope
141 | w=read();
| ^
|
s286867608 | p03793 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef pair<double,int>Q;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
char str[500005];
int q;
int dp[500005][27];
int go[500005][21];
int main(){
scanf("%s%d",&str,&q); int n = strlen(str);
rep(i,500005) rep(j,27) dp[i][j] = INF;
for(int i=0;i<n;i++){
dp[i][str[i]-'a'] = i;
}
while(1){
bool upd = 0;
for(int j=1;j<=26;j++){
for(int i=0;i<n;i++){
if(dp[i][j-1] < n && dp[dp[i][j-1]+1][j-1] < n && dp[i][j] > dp[dp[i][j-1]+1][j-1]){
dp[i][j] = dp[dp[i][j-1]+1][j-1];
upd = 1;
}
if(dp[i][26] < n && dp[dp[i][26]+1][j] < n && dp[i][j] > dp[dp[i][26]+1][j]){
dp[i][j] = dp[dp[i][26]+1][j];
upd = 1;
}
}
}
if(!upd) break;
}
for(int i=0;i<str.size();i++){
go[i][0] = dp[i][26]+1;
//cout<<i<<" "<<go[i][0]<<endl;
}
go[n][0] = n;
for(int j=0;j<19;j++){
for(int i=0;i<=n;i++){
if(go[i][j] >= n) go[i][j+1] = INF;
else go[i][j+1] = go[go[i][j]][j];
}
}
//cout<<go[0][1]<<endl;
rep(i,q){
int x,y; scanf("%d%d",&x,&y); x--;
for(int i=19;i>=0;i--){
if(go[x][i] <= y) x = go[x][i];
}
// cout<<x<<" "<<y<<endl;
puts(x==y?"Yes":"No");
}
} | a.cc: In function 'int main()':
a.cc:48:27: error: request for member 'size' in 'str', which is of non-class type 'char [500005]'
48 | for(int i=0;i<str.size();i++){
| ^~~~
|
s528528019 | p03793 | C++ | //http://mujin-pc-2017.contest.atcoder.jp/tasks/mujin_pc_2017_c
#include <bits/stdc++.h>
using namespace std;
const int maxn = 500100;
const int maxj = 30;
int next[maxn][30],f[maxn][maxj],a[maxn],n,q;
string s;
int main() {
ios_base::sync_with_stdio(0);
// freopen("in.txt","r",stdin);
cin>>s;
int n = s.length();
for (int i=0;i<n;i++) a[i] = s[i] - 'a';
for (int i=0;i<=n;i++)
for (int c=0;c<=26;c++)
next[i][c]=-1;
//cout<<"fuck"<<endl;
for (int i=n-1;i>=0;i--) {
next[i][a[i]] = i+1;
for (int c=a[i]+1;c<=26;c++)
if (next[i][c-1]!=-1) next[i][c] = next[next[i][c-1]][c-1];
for (int c=0;c<a[i];c++)
if (next[i][26]!=-1) next[i][c] = next[next[i][26]][c];
}
// for (int i=0;i<n;i++) {
// for (int j=0;j<=26;j++) cout<<next[i][j]<<" ";
// cout<<endl;
// }
// cout<<"fuck"<<endl;
for (int i=0;i<=n;i++) f[i][0] = next[i][26];
for (int j=1;j<maxj;j++)
for (int i=0;i<=n;i++) {
if (f[i][j-1]==-1) f[i][j]=-1;
else f[i][j] = f[f[i][j-1]][j-1];
}
//cout<<"fuck"<<endl;
// for (int i=0;i<n;i++) {
// for (int j=0;j<maxj;j++) cout<<f[i][j]<<" ";
// cout<<endl;
// }
cin>>q;
int x,y;
for (int i=1;i<=q;i++) {
cin>>x>>y;
x--;
// cout<<x<<" "<<y<<endl;
for (int j=maxj-1;j>=0;j--) {
if (f[x][j]==-1) continue;
if (f[x][j]<=y) {
x = f[x][j];
}
}
// cout<<x<<" "<<y<<endl;
if (x>=y) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
}
| a.cc: In function 'int main()':
a.cc:20:13: error: reference to 'next' is ambiguous
20 | next[i][c]=-1;
| ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:2:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:9:5: note: 'int next [500100][30]'
9 | int next[maxn][30],f[maxn][maxj],a[maxn],n,q;
| ^~~~
a.cc:23:9: error: reference to 'next' is ambiguous
23 | next[i][a[i]] = i+1;
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:9:5: note: 'int next [500100][30]'
9 | int next[maxn][30],f[maxn][maxj],a[maxn],n,q;
| ^~~~
a.cc:25:17: error: reference to 'next' is ambiguous
25 | if (next[i][c-1]!=-1) next[i][c] = next[next[i][c-1]][c-1];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:9:5: note: 'int next [500100][30]'
9 | int next[maxn][30],f[maxn][maxj],a[maxn],n,q;
| ^~~~
a.cc:25:35: error: reference to 'next' is ambiguous
25 | if (next[i][c-1]!=-1) next[i][c] = next[next[i][c-1]][c-1];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:9:5: note: 'int next [500100][30]'
9 | int next[maxn][30],f[maxn][maxj],a[maxn],n,q;
| ^~~~
a.cc:25:48: error: reference to 'next' is ambiguous
25 | if (next[i][c-1]!=-1) next[i][c] = next[next[i][c-1]][c-1];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:9:5: note: 'int next [500100][30]'
9 | int next[maxn][30],f[maxn][maxj],a[maxn],n,q;
| ^~~~
a.cc:25:53: error: reference to 'next' is ambiguous
25 | if (next[i][c-1]!=-1) next[i][c] = next[next[i][c-1]][c-1];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:9:5: note: 'int next [500100][30]'
9 | int next[maxn][30],f[maxn][maxj],a[maxn],n,q;
| ^~~~
a.cc:27:17: error: reference to 'next' is ambiguous
27 | if (next[i][26]!=-1) next[i][c] = next[next[i][26]][c];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:9:5: note: 'int next [500100][30]'
9 | int next[maxn][30],f[maxn][maxj],a[maxn],n,q;
| ^~~~
a.cc:27:34: error: reference to 'next' is ambiguous
27 | if (next[i][26]!=-1) next[i][c] = next[next[i][26]][c];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:9:5: note: 'int next [500100][30]'
9 | int next[maxn][30],f[maxn][maxj],a[maxn],n,q;
| ^~~~
a.cc:27:47: error: reference to 'next' is ambiguous
27 | if (next[i][26]!=-1) next[i][c] = next[next[i][26]][c];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:9:5: note: 'int next [500100][30]'
9 | int next[maxn][30],f[maxn][maxj],a[maxn],n,q;
| ^~~~
a.cc:27:52: error: reference to 'next' is ambiguous
27 | if (next[i][26]!=-1) next[i][c] = next[next[i][26]][c];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:9:5: note: 'int next [500100][30]'
9 | int next[maxn][30],f[maxn][maxj],a[maxn],n,q;
| ^~~~
a.cc:34:38: error: reference to 'next' is ambiguous
34 | for (int i=0;i<=n;i++) f[i][0] = next[i][26];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:9:5: note: 'int next [500100][30]'
9 | int next[maxn][30],f[maxn][maxj],a[maxn],n,q;
| ^~~~
|
s323161877 | p03793 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,itit ) for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define mp make_pair
#define pb push_back
#define all(s) s.begin(),s.end()
#define sz(s) (int)s.size()
#define present(c,x) ((c).find(x) != (c).end())
const double EPS = 1e-8;
const int mod = 1e9+7;
const int N = 5e5+10;
const ll INF = 1e18;
ll power(ll x,ll y){
ll t=1;
while(y>0){
if(y%2) y-=1,t=t*x%mod;
else y/=2,x=x*x%mod;
}
return t;
}
char s[N];
int next[N][27];
int ans[N][19];
void make(){
FILL(next,-1);
FILL(ans,-1);
int n=strlen(s),x;
for(int i=n-1;i>=0;i--){
x=s[i]-'a';
next[i][x]=i+1;
REPP(c,x+1,27)
if (next[i][c-1]!=-1) next[i][c]=next[next[i][c-1]][c-1];
if (next[i][26]!=-1){
REP(c,x) next[i][c]=next[next[i][26]][c];
ans[i][0]=next[i][26];
REPP(lvl,1,19) if (ans[i][lvl-1]!=-1) ans[i][lvl]=ans[ans[i][lvl-1]][lvl-1];
}
}
}
bool find(int l, int r){
for(int i=18;i>=0;i--)
if (ans[l][i]!=-1&&ans[l][i]<=r+1) l=ans[l][i];
return l==r+1;
}
int main(){
scanf("%s",s);
make();
int q,l,r;
scanf("%d",&q);
REP(i,q){
scanf("%d%d",&l,&r);
l--,r--;
if (find(l,r)) printf("Yes\n");
else printf("No\n");
}
return 0;
} | a.cc: In function 'void make()':
a.cc:37:14: error: reference to 'next' is ambiguous
37 | FILL(next,-1);
| ^~~~
a.cc:11:26: note: in definition of macro 'FILL'
11 | #define FILL(a,x) memset(a,x,sizeof(a))
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:33:5: note: 'int next [500010][27]'
33 | int next[N][27];
| ^~~~
a.cc:37:14: error: reference to 'next' is ambiguous
37 | FILL(next,-1);
| ^~~~
a.cc:11:37: note: in definition of macro 'FILL'
11 | #define FILL(a,x) memset(a,x,sizeof(a))
| ^
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:33:5: note: 'int next [500010][27]'
33 | int next[N][27];
| ^~~~
a.cc:42:17: error: reference to 'next' is ambiguous
42 | next[i][x]=i+1;
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:33:5: note: 'int next [500010][27]'
33 | int next[N][27];
| ^~~~
a.cc:44:29: error: reference to 'next' is ambiguous
44 | if (next[i][c-1]!=-1) next[i][c]=next[next[i][c-1]][c-1];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:33:5: note: 'int next [500010][27]'
33 | int next[N][27];
| ^~~~
a.cc:44:47: error: reference to 'next' is ambiguous
44 | if (next[i][c-1]!=-1) next[i][c]=next[next[i][c-1]][c-1];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:33:5: note: 'int next [500010][27]'
33 | int next[N][27];
| ^~~~
a.cc:44:58: error: reference to 'next' is ambiguous
44 | if (next[i][c-1]!=-1) next[i][c]=next[next[i][c-1]][c-1];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:33:5: note: 'int next [500010][27]'
33 | int next[N][27];
| ^~~~
a.cc:44:63: error: reference to 'next' is ambiguous
44 | if (next[i][c-1]!=-1) next[i][c]=next[next[i][c-1]][c-1];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:33:5: note: 'int next [500010][27]'
33 | int next[N][27];
| ^~~~
a.cc:45:21: error: reference to 'next' is ambiguous
45 | if (next[i][26]!=-1){
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:33:5: note: 'int next [500010][27]'
33 | int next[N][27];
| ^~~~
a.cc:46:34: error: reference to 'next' is ambiguous
46 | REP(c,x) next[i][c]=next[next[i][26]][c];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:33:5: note: 'int next [500010][27]'
33 | int next[N][27];
| ^~~~
a.cc:46:45: error: reference to 'next' is ambiguous
46 | REP(c,x) next[i][c]=next[next[i][26]][c];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:33:5: note: 'int next [500010][27]'
33 | int next[N][27];
| ^~~~
a.cc:46:50: error: reference to 'next' is ambiguous
46 | REP(c,x) next[i][c]=next[next[i][26]][c];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:33:5: note: 'int next [500010][27]'
33 | int next[N][27];
| ^~~~
a.cc:47:35: error: reference to 'next' is ambiguous
47 | ans[i][0]=next[i][26];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:33:5: note: 'int next [500010][27]'
33 | int next[N][27];
| ^~~~
|
s407238129 | p03793 | C++ | #include <bits/stdc++.h>
#define X first
#define Y second
#define mp make_pair
using namespace std;
typedef pair<int,int> PII;
const int N = 500010;
char s[N];
int n,m,x,y,f[N][30],a[N];
bool ans[100010];
PII q[100010];
bool pd[N];
vector<int> v[N],Q[N];
void dfs(int x){
pd[x]=true;
for(int i=0;i<Q[x].size();i++) {
if(pd[q[Q[x][i]].Y]) ans[Q[x][i]]=true;
// printf("%d %d %d\n",x,Q[x][i],ans[Q[x][i]]);
}
for(int i=0;i<v[x].size();i++) dfs(v[x][i]);
pd[x]=false;
}
int main(){
gets(s+1);
//scanf("%s",s+1);
n = strlen(s+1);
for(int i=1;i<=n;i++) a[i]=s[i]-'a';
for(int i=0;i<=26;i++) f[n+2][i]=f[n+1][i]=n+1;
//cout<<n<<endl;
for(int i=n;i>0;i--){
f[i][a[i]]=i;
for(int j=a[i]+1;j<=26;j++) f[i][j]=f[f[i][j-1]+1][j-1];
for(int j=0;j<a[i];j++) f[i][j]=f[f[i][26]+1][j];
if(f[i][26]<=n)
v[f[f[i][26]+1][26]].push_back(f[i][26]);
}
// for(int i=1;i<=n;i++) printf("%d ",f[i][26]); puts("");
scanf("%d",&m);
for(int i=1;i<=m;i++){
scanf("%d%d",&x,&y);
q[i] = mp(x,y);
if(f[x][26]<=n) Q[f[x][26]].push_back(i);
}
dfs(n+1);
for(int i=1;i<=m;i++) if(ans[i]) puts("Yes"); else puts("No");
return 0;
}
/*
yzyyyzyzyyyz
8
1 6
7 12
1 12
6 11
1 1
1 3
4 9
3 8
*/ | a.cc: In function 'int main()':
a.cc:24:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
24 | gets(s+1);
| ^~~~
| getw
|
s307025866 | p03793 | C++ | #include<bits/stdc++.h>
#define idx(x) (x-'a')
using namespace std;
const int maxn=5e5+10;
const int inf=1061109567;
char s[maxn];
int n,q,next[maxn][27];
int main()
{
int i,j,k;
scanf("%s%d",s+1,&q);
memset(next,inf,sizeof(next));
for(n=0;s[n+1];n++);
for(i=1;i<=n;i++)
next[i][idx(s[i])]=i;
for(i=n;i;i--){
for(k=1;k<27;k++){
if(next[i][k-1]<inf){
j=next[i][k-1];
j=next[j+1][k-1];
if(j<inf)
next[i][k]=min(next[i][k],j);
}
}
if(next[i][26]<inf){
for(k=1;k<27;k++){
j=next[i][26];
j=next[j+1][k];
if(j<inf)
next[i][k]=min(next[i][k],j);
}
}
}
for(i=1;i<=n;i++) next[i][0]=next[i][26];
for(k=1;k<20;k++)
for(i=1;i<=n;i++)
if(next[i][k-1]==inf) next[i][k]=inf;
else next[i][k]=next[next[i][k-1]+1][k-1];
while(q--){
scanf("%d%d",&i,&j);
if(i==j) puts("No");
else{
for(k=19;k>=0;k--)
if(next[i][k]<=j)
i=next[i][k];
puts(i==j?"Yes":"No");
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:12:12: error: reference to 'next' is ambiguous
12 | memset(next,inf,sizeof(next));
| ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:7:9: note: 'int next [500010][27]'
7 | int n,q,next[maxn][27];
| ^~~~
a.cc:12:28: error: reference to 'next' is ambiguous
12 | memset(next,inf,sizeof(next));
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:7:9: note: 'int next [500010][27]'
7 | int n,q,next[maxn][27];
| ^~~~
a.cc:15:9: error: reference to 'next' is ambiguous
15 | next[i][idx(s[i])]=i;
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:7:9: note: 'int next [500010][27]'
7 | int n,q,next[maxn][27];
| ^~~~
a.cc:18:16: error: reference to 'next' is ambiguous
18 | if(next[i][k-1]<inf){
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:7:9: note: 'int next [500010][27]'
7 | int n,q,next[maxn][27];
| ^~~~
a.cc:19:19: error: reference to 'next' is ambiguous
19 | j=next[i][k-1];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:7:9: note: 'int next [500010][27]'
7 | int n,q,next[maxn][27];
| ^~~~
a.cc:20:19: error: reference to 'next' is ambiguous
20 | j=next[j+1][k-1];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:7:9: note: 'int next [500010][27]'
7 | int n,q,next[maxn][27];
| ^~~~
a.cc:22:21: error: reference to 'next' is ambiguous
22 | next[i][k]=min(next[i][k],j);
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:7:9: note: 'int next [500010][27]'
7 | int n,q,next[maxn][27];
| ^~~~
a.cc:22:36: error: reference to 'next' is ambiguous
22 | next[i][k]=min(next[i][k],j);
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:7:9: note: 'int next [500010][27]'
7 | int n,q,next[maxn][27];
| ^~~~
a.cc:25:12: error: reference to 'next' is ambiguous
25 | if(next[i][26]<inf){
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:7:9: note: 'int next [500010][27]'
7 | int n,q,next[maxn][27];
| ^~~~
a.cc:27:19: error: reference to 'next' is ambiguous
27 | j=next[i][26];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:7:9: note: 'int next [500010][27]'
7 | int n,q,next[maxn][27];
| ^~~~
a.cc:28:19: error: reference to 'next' is ambiguous
28 | j=next[j+1][k];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:7:9: note: 'int next [500010][27]'
7 | int n,q,next[maxn][27];
| ^~~~
a.cc:30:21: error: reference to 'next' is ambiguous
30 | next[i][k]=min(next[i][k],j);
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:7:9: note: 'int next [500010][27]'
7 | int n,q,next[maxn][27];
| ^~~~
a.cc:30:36: error: reference to 'next' is ambiguous
30 | next[i][k]=min(next[i][k],j);
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:7:9: note: 'int next [500010][27]'
7 | int n,q,next[maxn][27];
| ^~~~
a.cc:34:23: error: reference to 'next' is ambiguous
34 | for(i=1;i<=n;i++) next[i][0]=next[i][26];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:7:9: note: 'int next [500010][27]'
7 | int n,q,next[maxn][27];
| ^~~~
a.cc:34:34: error: reference to 'next' is ambiguous
34 | for(i=1;i<=n;i++) next[i][0]=next[i][26];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:7:9: note: 'int next [500010][27]'
7 | int n,q,next[maxn][27];
| ^~~~
a.cc:37:16: error: reference to 'next' is ambiguous
37 | if(next[i][k-1]==inf) next[i][k]=inf;
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:7:9: note: 'int next [500010][27]'
7 | int n,q,next[maxn][27];
| ^~~~
a.cc:37:35: error: reference to 'next' is ambiguous
37 | if(next[i][k-1]==inf) next[i][k]=inf;
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:7:9: note: 'int next [500010][27]'
7 | int n,q,next[maxn][27];
| ^~~~
a.cc:38:18: error: reference to 'next' is ambiguous
38 | else next[i][k]=next[next[i][k-1]+1][k-1];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:7:9: note: 'int next [500010][27]'
7 | int n,q,next[maxn][27];
| ^~~~
a.cc:38:29: error: reference to 'next' is ambiguous
38 | else next[i][k]=next[next[i][k-1]+1][k-1];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:7:9: note: 'int next [500010][27]'
7 | int n,q,next[maxn][27];
| ^~~~
a.cc:38:34: error: reference to 'next' is ambiguous
38 | |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.