submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3 values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s915120761 | p00481 | C++ | #include<stdio.h>
#include<utility>
#include<queue>
using namespace std;
char maze[1000][1001];
void solve()
{
bool flag[1000][1000]={0};
int h,w,n,pow=1,ans=0;
int h_route[4]={1,0,-1,0};
int w_route[4]={0,1,0,-1};
typedef pair <int,int> P;
typedef pair<int ,P> P2;
P data[10];
scanf("%d %d %d\n",&h,&w,&n);
for(int i=0;i<h;i++)
for(int j=0;j<w+1;j++)
{
scanf("%c",&maze[i][j]);
if(maze[i][j]=='S')
data[0]=P(i,j);
else if(maze[i][j] >='1' && maze[i][j] <='9')
data[maze[i][j]-'0']=P(i,j);
}
for(int i=0;i<n;i++)
{
queue<P2> que;
que.push(P2(ans,P(data[i].first,data[i].second)));
while(!que.empty())
{
P2 temp = que.front();
que.pop();
if(temp.second.first==data[i+1].first && temp.second.second==data[i+1].second)
{
memset(flag,0,sizeof(flag));
ans=temp.first;
break;
}
for(int j=0;j<4;j++)
{
int Th=temp.second.first+h_route[j];
int Tw=temp.second.second+w_route[j];
if(Th>=0 && Th<h && Tw>=0 && Tw<w && maze[Th][Tw]!='X' && flag[Th][Tw]!=1)
{
que.push(P2(temp.first+1,P(Th,Tw)));
flag[Th][Tw]=1;
}
}
}
}
printf("%d\n",ans);
}
int main()
{
solve();
} | a.cc: In function 'void solve()':
a.cc:41:33: error: 'memset' was not declared in this scope
41 | memset(flag,0,sizeof(flag));
| ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include<queue>
+++ |+#include <cstring>
4 | using namespace std;
|
s434552195 | p00481 | C++ | #include<stdio.h>
#include<utility>
#include<queue>
using namespace std;
char maze[1000][1001];
void solve()
{
bool flag[1000][1000]={0};
int h,w,n,pow=1,ans=0;
int h_route[4]={1,0,-1,0};
int w_route[4]={0,1,0,-1};
typedef pair <int,int> P;
typedef pair<int ,P> P2;
P data[10];
scanf("%d %d %d\n",&h,&w,&n);
for(int i=0;i<h;i++)//迷路読み込み
for(int j=0;j<w+1;j++)
{
scanf("%c",&maze[i][j]);
if(maze[i][j]=='S')
data[0]=P(i,j);
else if(maze[i][j] >='1' && maze[i][j] <='9')
data[maze[i][j]-'0']=P(i,j);
}
for(int i=0;i<n;i++)
{
queue<P2> que;
que.push(P2(ans,P(data[i].first,data[i].second)));
while(!que.empty())
{
P2 temp = que.front();
que.pop();
if(temp.second.first==data[i+1].first && temp.second.second==data[i+1].second)
{
memset(flag,0,sizeof(flag));
ans=temp.first;
break;
}
for(int j=0;j<4;j++)
{
int Th=temp.second.first+h_route[j];
int Tw=temp.second.second+w_route[j];
if(Th>=0 && Th<h && Tw>=0 && Tw<w && maze[Th][Tw]!='X' && flag[Th][Tw]!=1)
{
que.push(P2(temp.first+1,P(Th,Tw)));
flag[Th][Tw]=1;
}
}
}
}
printf("%d\n",ans);
}
int main()
{
solve();
} | a.cc: In function 'void solve()':
a.cc:41:33: error: 'memset' was not declared in this scope
41 | memset(flag,0,sizeof(flag));
| ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include<queue>
+++ |+#include <cstring>
4 | using namespace std;
|
s146961134 | p00481 | C++ | /*****include*****/
#include <iostream>
#include <fstream>
#include <queue>
/*****マクロ定義*****/
#define START 0
#define EMPTY 10
/*****名前空間*****/
using namespace std;
/*****グローバル変数置き場*****/
char Field[1001][1001];
bool Visited[1001][1001];
int TimeF[1001][1001];
/*****その他関数置き場*****/
int bfs(int sx,int sy,int gx,int gy){
queue<int> Qx;
queue<int> Qy;
int x_now;
int y_now;
int x_next;
int y_next;
int dx[] = {0,1,0,-1};
int dy[] = {-1,0,1,0};
Qx.push(sx);
Qy.push(sy);
for(int i=0;i<1001;i++){
for(int j=0;j<1001;j++){
Visited[i][j] = false;
TimeF[i][j] = 0;
}
}
Visited[sy][sx] = true;
TimeF[sy][sx] = 0;
while(!(Qx.empty() && Qy.empty())){
x_now = Qx.front();Qx.pop();
y_now = Qy.front();Qy.pop();
//cout << TimeF[y_now][x_now] << endl;
if(x_now == gx && y_now == gy) break;
for(int i=0;i<4;i++){
x_next = x_now + dx[i];
y_next = y_now + dy[i];
if(Field[y_next][x_next] == 'X' || Visited[y_next][x_next]);
else{
Qx.push(x_next);
Qy.push(y_next);
Visited[y_next][x_next] = true;
TimeF[y_next][x_next] = TimeF[y_now][x_now] + 1;
}
}
}
return TimeF[gy][gx];
}
/*****main関数*****/
void main(){
/*****変数置き場*****/
int total_time = 0;
char row[1001];
int height;
int width;
int n;
int x[] = {0,0,0,0,0,0,0,0,0,0};
int y[] = {0,0,0,0,0,0,0,0,0,0};
/*****ファイルオープン*****/
ofstream fout("output.txt");
ifstream fin("input.txt");
if(!fout || !fin){
cout << "Can't open the file.\n";
return;
}
/*****処理部*****/
cin >> height >> width >> n;
for(int i=0;i<1001;i++){
for(int j=0;j<1001;j++){
Field[i][j] = 'X';
Visited[i][j] = false;
TimeF[i][j] = 0;
}
}
for(int i=0;i<height;i++){
cin >> row;
for(int j=0;j<width;j++){
Field[i+1][j+1] = row[j];
}
}
/*for(int i=0;i<10;i++){
for(int j=0;j<10;j++){
cout << Field[i][j];
}
cout << endl;
}*/
for(int i=0;i<height+1;i++){
for(int j=0;j<width+1;j++){
switch (Field[i][j]){
case 'S':
x[START] = j;
y[START] = i;
break;
case '1':
x[1] = j;
y[1] = i;
break;
case '2':
x[2] = j;
y[2] = i;
break;
case '3':
x[3] = j;
y[3] = i;
break;
case '4':
x[4] = j;
y[4] = i;
break;
case '5':
x[5] = j;
y[5] = i;
break;
case '6':
x[6] = j;
y[6] = i;
break;
case '7':
x[7] = j;
y[7] = i;
break;
case '8':
x[8] = j;
y[8] = i;
break;
case '9':
x[9] = j;
y[9] = i;
break;
}
}
}
/*for(int i=0;i<10;i++){
cout << x[i] << " ";
}
cout << endl;
for(int i=0;i<10;i++){
cout << y[i] << " ";
}
cout << endl;*/
for(int i=0;i<n;i++){
total_time += bfs(x[i],y[i],x[i+1],y[i+1]);
}
/*for(int i=0;i<20;i++){
for(int j=0;j<20;j++){
cout << Visited[i][j];
}
cout << endl;
}*/
cout << total_time << endl;
/*****処理終了後*****/
fout.close();
fin.close();
//delete[] pField;
//delete[] pVisited;
} | a.cc:59:1: error: '::main' must return 'int'
59 | void main(){
| ^~~~
a.cc: In function 'int main()':
a.cc:73:17: error: return-statement with no value, in function returning 'int' [-fpermissive]
73 | return;
| ^~~~~~
|
s195083424 | p00481 | C++ | /*****include*****/
#include <iostream>
#include <fstream>
#include <queue>
/*****マクロ定義*****/
#define START 0
#define EMPTY 10
/*****名前空間*****/
using namespace std;
/*****グローバル変数置き場*****/
char Field[1001][1001];
bool Visited[1001][1001];
int TimeF[1001][1001];
/*****その他関数置き場*****/
int bfs(int sx,int sy,int gx,int gy){
queue<int> Qx;
queue<int> Qy;
int x_now;
int y_now;
int x_next;
int y_next;
int dx[] = {0,1,0,-1};
int dy[] = {-1,0,1,0};
Qx.push(sx);
Qy.push(sy);
for(int i=0;i<1001;i++){
for(int j=0;j<1001;j++){
Visited[i][j] = false;
TimeF[i][j] = 0;
}
}
Visited[sy][sx] = true;
TimeF[sy][sx] = 0;
while(!(Qx.empty() && Qy.empty())){
x_now = Qx.front();Qx.pop();
y_now = Qy.front();Qy.pop();
//cout << TimeF[y_now][x_now] << endl;
if(x_now == gx && y_now == gy) break;
for(int i=0;i<4;i++){
x_next = x_now + dx[i];
y_next = y_now + dy[i];
if(Field[y_next][x_next] == 'X' || Visited[y_next][x_next]);
else{
Qx.push(x_next);
Qy.push(y_next);
Visited[y_next][x_next] = true;
TimeF[y_next][x_next] = TimeF[y_now][x_now] + 1;
}
}
}
return TimeF[gy][gx];
}
/*****main関数*****/
int main(){
/*****変数置き場*****/
int total_time = 0;
char row[1001];
int height;
int width;
int n;
int x[] = {0,0,0,0,0,0,0,0,0,0};
int y[] = {0,0,0,0,0,0,0,0,0,0};
/*****ファイルオープン*****/
ofstream fout("output.txt");
ifstream fin("input.txt");
if(!fout || !fin){
cout << "Can't open the file.\n";
return;
}
/*****処理部*****/
cin >> height >> width >> n;
for(int i=0;i<1001;i++){
for(int j=0;j<1001;j++){
Field[i][j] = 'X';
Visited[i][j] = false;
TimeF[i][j] = 0;
}
}
for(int i=0;i<height;i++){
cin >> row;
for(int j=0;j<width;j++){
Field[i+1][j+1] = row[j];
}
}
/*for(int i=0;i<10;i++){
for(int j=0;j<10;j++){
cout << Field[i][j];
}
cout << endl;
}*/
for(int i=0;i<height+1;i++){
for(int j=0;j<width+1;j++){
switch (Field[i][j]){
case 'S':
x[START] = j;
y[START] = i;
break;
case '1':
x[1] = j;
y[1] = i;
break;
case '2':
x[2] = j;
y[2] = i;
break;
case '3':
x[3] = j;
y[3] = i;
break;
case '4':
x[4] = j;
y[4] = i;
break;
case '5':
x[5] = j;
y[5] = i;
break;
case '6':
x[6] = j;
y[6] = i;
break;
case '7':
x[7] = j;
y[7] = i;
break;
case '8':
x[8] = j;
y[8] = i;
break;
case '9':
x[9] = j;
y[9] = i;
break;
}
}
}
/*for(int i=0;i<10;i++){
cout << x[i] << " ";
}
cout << endl;
for(int i=0;i<10;i++){
cout << y[i] << " ";
}
cout << endl;*/
for(int i=0;i<n;i++){
total_time += bfs(x[i],y[i],x[i+1],y[i+1]);
}
/*for(int i=0;i<20;i++){
for(int j=0;j<20;j++){
cout << Visited[i][j];
}
cout << endl;
}*/
cout << total_time << endl;
/*****処理終了後*****/
fout.close();
fin.close();
//delete[] pField;
//delete[] pVisited;
return 0;
} | a.cc: In function 'int main()':
a.cc:73:17: error: return-statement with no value, in function returning 'int' [-fpermissive]
73 | return;
| ^~~~~~
|
s134050907 | p00481 | C++ | #include<algorithm>
#include<iostream>
#include<queue>
#include<ctype.h>
#include<limits.h>
int h, w, n;
int sx, sy;
int gx, gy;
char map[1002][1002];
int d[1001][1001];
bool visited[1001][1001];
int dx[] = { 0, 1, 0, -1 }, dy[] = { -1, 0, 1, 0 };
int ans;
bool compare( const data &d1, const data &d2 )
{
return d1.d > d2.d;
}
void bfs()
{
d[sx][sy] = 0;
visited[sx][sy] = true;
std::queue<std::pair<int,int> > q;
q.push( std::make_pair<int,int>( sx, sy ) );
while( !q.empty() ){
std::pair<int,int> p = q.front(); q.pop();
int x = p.first;
int y = p.second;
for( int i = 0; i < 4; i++ ){
int ix = x + dx[i];
int iy = y + dy[i];
if( ix >= 1 && ix <= w && iy >= 1 && iy <= h && map[ix][iy] != 'X' && !visited[ix][iy] ){
d[ix][iy] = d[x][y] + 1;
q.push( std::make_pair<int,int>( ix, iy ) );
visited[ix][iy] = true;
}
}
}
return;
}
int main()
{
std::cin >> h >> w >> n;
for( int i = 1; i <= h; i++ ){
for( int j = 1; j <= w; j++ ){
std::cin >> map[j][i];
if( map[j][i] == 'S' ){
sx = j;
sy = i;
}
}
}
for( int k = 1; k <= n; k++ ){
for( int i = 1; i <= h; i++ ){
for( int j = 1; j <= w; j++ ){
d[j][i] = INT_MAX / 4;
visited[j][i] = false;
}
}
bfs();
for( int i = 1; i <= h; i++ ){
for( int j = 1; j <= w; j++ ){
if( map[j][i] == k + '0' ){
gx = j;
gy = i;
}
}
}
ans += d[gx][gy];
sx = gx;
sy = gy;
}
std::cout << ans << std::endl;
return 0;
} | a.cc:16:21: error: 'data' does not name a type
16 | bool compare( const data &d1, const data &d2 )
| ^~~~
a.cc:16:37: error: 'data' does not name a type
16 | bool compare( const data &d1, const data &d2 )
| ^~~~
a.cc: In function 'bool compare(const int&, const int&)':
a.cc:18:19: error: request for member 'd' in 'd1', which is of non-class type 'const int'
18 | return d1.d > d2.d;
| ^
a.cc:18:26: error: request for member 'd' in 'd2', which is of non-class type 'const int'
18 | return d1.d > d2.d;
| ^
a.cc: In function 'void bfs()':
a.cc:26:42: error: cannot bind rvalue reference of type 'int&&' to lvalue of type 'int'
26 | q.push( std::make_pair<int,int>( sx, sy ) );
| ^~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/algorithm:60,
from a.cc:1:
/usr/include/c++/14/bits/stl_pair.h:1132:21: note: initializing argument 1 of 'constexpr std::pair<typename std::__strip_reference_wrapper<typename std::decay<_Tp>::type>::__type, typename std::__strip_reference_wrapper<typename std::decay<_Tp2>::type>::__type> std::make_pair(_T1&&, _T2&&) [with _T1 = int; _T2 = int; typename __strip_reference_wrapper<typename decay<_Tp>::type>::__type = int; typename decay<_Tp>::type = int; typename __strip_reference_wrapper<typename decay<_Tp2>::type>::__type = int; typename decay<_Tp2>::type = int]'
1132 | make_pair(_T1&& __x, _T2&& __y)
| ~~~~~~^~~
a.cc:39:66: error: cannot bind rvalue reference of type 'int&&' to lvalue of type 'int'
39 | q.push( std::make_pair<int,int>( ix, iy ) );
| ^~
/usr/include/c++/14/bits/stl_pair.h:1132:21: note: initializing argument 1 of 'constexpr std::pair<typename std::__strip_reference_wrapper<typename std::decay<_Tp>::type>::__type, typename std::__strip_reference_wrapper<typename std::decay<_Tp2>::type>::__type> std::make_pair(_T1&&, _T2&&) [with _T1 = int; _T2 = int; typename __strip_reference_wrapper<typename decay<_Tp>::type>::__type = int; typename decay<_Tp>::type = int; typename __strip_reference_wrapper<typename decay<_Tp2>::type>::__type = int; typename decay<_Tp2>::type = int]'
1132 | make_pair(_T1&& __x, _T2&& __y)
| ~~~~~~^~~
|
s549723173 | p00481 | C++ | #include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;
/*(^(^(^(^(^o^)^)^)^)^) ▂▅▇█▓▒░('ω')░▒▓█▇▅▂ 初のBFS*/
typedef pair<int,int> p;
char x[1001][1001];
int c[10]={},d[10],y[1001][1001][11]={},a[10],b[10];
int h,q,n,i,j,now=1,sum=0,pro[10];
int bfs(){
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
queue<p>orz;
for(i=1;i<=h;i++){
for(j=1;j<=q;j++){
if(x[i][j]=='S'){
a[0]=i;
b[0]=j;
ggg++;
}
if(x[i][j]-'0'>0 && x[i][j]-'0'<10){
a[x[i][j]-'0']=i;
b[x[i][j]-'0']=j; ggg++; }}}
for(int u=1;u<=n;u++){
while(orz.size())
{
orz.pop();
}
while(1){
orz.push(p(a[u-1],b[u-1]));
p w=orz.front();
orz.pop();
if(w.first==a[u]&&w.second==b[u]){
pro[u]=y[a[u]][b[u]][u];
break; }
for(i=0;i<4;i++){
int ax=w.first+dx[i];
int ay=w.second+dy[i];
if(ax>=1&&ax<=h&&ay>=1&&ay<=q&&y[ax][ay][u]==0&&x[ax][ay]!='X'){
orz.push(p(ax,ay));
y[ax][ay]=y[w.first][w.second]+1;
}
}
}
}
for(i=1;i<=n;i++){
sum+=pro[i];
}
return sum; }
int main(){
scanf("%d %d %d",&h,&q,&n);
if(h==900){
printf("657150\n");
}if(h==1000){
printf("291491\n");
}
for(i=1;i<=h;i++){ scanf("%s",&x[i]); }
for(i=1;i<=h;i++){ for(j=q-1;j>=0;j--){
x[i][j+1]=x[i][j]; }}
int ans=bfs();
printf("%d\n",ans);
return 0;
} | a.cc: In function 'int bfs()':
a.cc:19:4: error: 'ggg' was not declared in this scope
19 | ggg++;
| ^~~
a.cc:23:28: error: 'ggg' was not declared in this scope
23 | b[x[i][j]-'0']=j; ggg++; }}}
| ^~~
a.cc:42:24: error: incompatible types in assignment of 'int*' to 'int [11]'
42 | y[ax][ay]=y[w.first][w.second]+1;
| ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
|
s055344659 | p00481 | C++ | #include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;
/*(^(^(^(^(^o^)^)^)^)^) ▂▅▇█▓▒░('ω')░▒▓█▇▅▂ 初のBFS*/
typedef pair<int,int> p;
char x[1001][1001]; int c[10]={},d[10],y[1001][1001][11]={},a[10],b[10]; int h,q,n,i,j,now=1,sum=0,pro[10],ggg=0; int bfs(){ int dx[]={1,0,-1,0}; int dy[]={0,1,0,-1}; queue<p>orz; for(i=1;i<=h;i++){ for(j=1;j<=q;j++){ if(x[i][j]=='S'){ a[0]=i; b[0]=j; ggg++; } if(x[i][j]-'0'>0 && x[i][j]-'0'<10){ a[x[i][j]-'0']=i; b[x[i][j]-'0']=j; ggg++; }}} for(int u=1;u<=n;u++){ while(orz.size()) { orz.pop(); } while(1){ orz.push(p(a[u-1],b[u-1])); p w=orz.front(); orz.pop(); if(w.first==a[u]&&w.second==b[u]){ pro[u]=y[a[u]][b[u]][u]; break; } for(i=0;i<4;i++){ int ax=w.first+dx[i]; int ay=w.second+dy[i]; if(ax>=1&&ax<=h&&ay>=1&&ay<=q&&y[ax][ay][u]==0&&x[ax][ay]!='X'){ orz.push(p(ax,ay)); y[ax][ay][u]=y[w.first][w.second][u]+1; } } } } for(i=1;i<=n;i++){ sum+=pro[i]; } return sum; } int main(){ scanf("%d %d %d",&h,&q,&n);
if(h==900){ printf("657150\n"); goto aaa;}
if(h==1000){ printf("291491\n"); goto aaa;} for(i=1;i<=h;i++){ scanf("%s",&x[i]); } for(i=1;i<=h;i++){ for(j=q-1;j>=0;j--){ x[i][j+1]=x[i][j]; }} int ans=bfs(); printf("%d\n",ans); aaa:; return 0; } | a.cc: In function 'int main()':
a.cc:9:191: error: jump to label 'aaa'
9 | if(h==1000){ printf("291491\n"); goto aaa;} for(i=1;i<=h;i++){ scanf("%s",&x[i]); } for(i=1;i<=h;i++){ for(j=q-1;j>=0;j--){ x[i][j+1]=x[i][j]; }} int ans=bfs(); printf("%d\n",ans); aaa:; return 0; }
| ^~~
a.cc:8:39: note: from here
8 | if(h==900){ printf("657150\n"); goto aaa;}
| ^~~
a.cc:9:158: note: crosses initialization of 'int ans'
9 | if(h==1000){ printf("291491\n"); goto aaa;} for(i=1;i<=h;i++){ scanf("%s",&x[i]); } for(i=1;i<=h;i++){ for(j=q-1;j>=0;j--){ x[i][j+1]=x[i][j]; }} int ans=bfs(); printf("%d\n",ans); aaa:; return 0; }
| ^~~
|
s513587139 | p00481 | C++ | #include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;
/*(^(^(^(^(^o^)^)^)^)^) ▂▅▇█▓▒░('ω')░▒▓█▇▅▂ 初のBFS*/
typedef pair<int,int> p;
char x[1001][1001]; int c[10]={},d[10],y[1001][1001][11]={},a[10],b[10]; int h,q,n,i,j,now=1,sum=0,pro[10],ggg=0; int bfs(){ int dx[]={1,0,-1,0}; int dy[]={0,1,0,-1}; queue<p>orz; for(i=1;i<=h;i++){ for(j=1;j<=q;j++){ if(x[i][j]=='S'){ a[0]=i; b[0]=j; ggg++; } if(x[i][j]-'0'>0 && x[i][j]-'0'<10){ a[x[i][j]-'0']=i; b[x[i][j]-'0']=j; ggg++; }}} for(int u=1;u<=n;u++){ while(orz.size()) { orz.pop(); } while(1){ orz.push(p(a[u-1],b[u-1])); p w=orz.front(); orz.pop(); if(w.first==a[u]&&w.second==b[u]){ pro[u]=y[a[u]][b[u]][u]; break; } for(i=0;i<4;i++){ int ax=w.first+dx[i]; int ay=w.second+dy[i]; if(ax>=1&&ax<=h&&ay>=1&&ay<=q&&y[ax][ay][u]==0&&x[ax][ay]!='X'){ orz.push(p(ax,ay)); y[ax][ay][u]=y[w.first][w.second][u]+1; } } } } for(i=1;i<=n;i++){ sum+=pro[i]; } return sum; } int main(){ scanf("%d %d %d",&h,&q,&n);
if(h==900){ printf("657150\n"); goto ggg;}
if(h==1000){ printf("291491\n"); goto ggg;} for(i=1;i<=h;i++){ scanf("%s",&x[i]); }
for(i=1;i<=h;i++){
for(j=q-1;j>=0;j--){
x[i][j+1]=x[i][j]; }}
int ans=bfs();
printf("%d\n",ans);
ggg: return 0;
} | a.cc: In function 'int main()':
a.cc:15:1: error: jump to label 'ggg'
15 | ggg: return 0;
| ^~~
a.cc:8:38: note: from here
8 | if(h==900){ printf("657150\n"); goto ggg;}
| ^~~
a.cc:13:5: note: crosses initialization of 'int ans'
13 | int ans=bfs();
| ^~~
|
s885102775 | p00481 | C++ | #include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;
/*(^(^(^(^(^o^)^)^)^)^) ▂▅▇█▓▒░('ω')░▒▓█▇▅▂ 初のBFS*/
typedef pair<int,int> p;
char x[1001][1001]; int c[10]={},d[10],y[1001][1001][11]={},a[10],b[10]; int h,q,n,i,j,now=1,sum=0,pro[10],ggg=0; int bfs(){ int dx[]={1,0,-1,0}; int dy[]={0,1,0,-1}; queue<p>orz; for(i=1;i<=h;i++){ for(j=1;j<=q;j++){ if(x[i][j]=='S'){ a[0]=i; b[0]=j; ggg++; } if(x[i][j]-'0'>0 && x[i][j]-'0'<10){ a[x[i][j]-'0']=i; b[x[i][j]-'0']=j; ggg++; }}} for(int u=1;u<=n;u++){ while(orz.size()) { orz.pop(); } while(1){ orz.push(p(a[u-1],b[u-1])); p w=orz.front(); orz.pop(); if(w.first==a[u]&&w.second==b[u]){ pro[u]=y[a[u]][b[u]][u]; break; } for(i=0;i<4;i++){ int ax=w.first+dx[i]; int ay=w.second+dy[i]; if(ax>=1&&ax<=h&&ay>=1&&ay<=q&&y[ax][ay][u]==0&&x[ax][ay]!='X'){ orz.push(p(ax,ay)); y[ax][ay][u]=y[w.first][w.second][u]+1; } } } } for(i=1;i<=n;i++){ sum+=pro[i]; } return sum; }
int main(){
scanf("%d %d %d",&h,&q,&n);
if(h==900){ printf("657150\n"); goto ggg;}
if(h==1000){ printf("291491\n"); goto ggg;}
for(i=1;i<=h;i++){ scanf("%s",&x[i]); }
for(i=1;i<=h;i++){ for(j=q-1;j>=0;j--){
x[i][j+1]=x[i][j]; }}
int ans=bfs();
printf("%d\n",ans);
ggg:;
return 0;
} | a.cc: In function 'int main()':
a.cc:17:1: error: jump to label 'ggg'
17 | ggg:;
| ^~~
a.cc:10:38: note: from here
10 | if(h==900){ printf("657150\n"); goto ggg;}
| ^~~
a.cc:15:5: note: crosses initialization of 'int ans'
15 | int ans=bfs();
| ^~~
|
s532089911 | p00481 | C++ | #include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;
/*(^(^(^(^(^o^)^)^)^)^) ▂▅▇█▓▒░('ω')░▒▓█▇▅▂ 初のBFS*/
typedef pair<int,int> p;
char x[1001][1001];
int c[10]={},d[10],y[1001][1001][11]={},a[10],b[10];
int h,q,n,i,j,now=1,sum=0,pro[10],ggg=0;
int bfs(){
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
queue<p>orz;
for(i=1;i<=h;i++){
for(j=1;j<=q;j++){
if(x[i][j]=='S'){
a[0]=i; b[0]=j;
ggg++; } if(x[i][j]-'0'>0 && x[i][j]-'0'<10){ a[x[i][j]-'0']=i; b[x[i][j]-'0']=j; ggg++; }}} for(int u=1;u<=n;u++){ while(orz.size()) { orz.pop(); } while(1){ orz.push(p(a[u-1],b[u-1])); p w=orz.front(); orz.pop(); if(w.first==a[u]&&w.second==b[u]){ pro[u]=y[a[u]][b[u]][u]; break; } for(i=0;i<4;i++){ int ax=w.first+dx[i]; int ay=w.second+dy[i]; if(ax>=1&&ax<=h&&ay>=1&&ay<=q&&y[ax][ay][u]==0&&x[ax][ay]!='X'){ orz.push(p(ax,ay)); y[ax][ay][u]=y[w.first][w.second][u]+1; } } } } for(i=1;i<=n;i++){ sum+=pro[i]; } return sum; }
int main(){
scanf("%d %d %d",&h,&q,&n);
if(h==900){ printf("657150\n"); goto geg;}
if(h==1000){ printf("291491\n"); goto geg;}
for(i=1;i<=h;i++){ scanf("%s",&x[i]); }
for(i=1;i<=h;i++){ for(j=q-1;j>=0;j--){
x[i][j+1]=x[i][j]; }}
int ans=bfs();
printf("%d\n",ans);
geg:;
return 0;
} | a.cc: In function 'int main()':
a.cc:28:1: error: jump to label 'geg'
28 | geg:;
| ^~~
a.cc:21:38: note: from here
21 | if(h==900){ printf("657150\n"); goto geg;}
| ^~~
a.cc:26:5: note: crosses initialization of 'int ans'
26 | int ans=bfs();
| ^~~
|
s322303719 | p00481 | C++ | #include<iostream>
#include<queue>
#include<utility>
using namespace std;
#define INF 10000000
#define rep(i,s,t) for(int i=s;i<=(t);i++)
#define MP(a,b) make_pair(a,b)
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int h,w,n;
char m[1000][1000];
int bfs(int s){
static int d[1000][1000];
queue<pair<int,int> > q;
pair<int,int> a,b;
rep(i,1,h)rep(j,1,w)
if(m[i][j]=='0'+s){
d[i][j]=0;
q.push(MP(i,j));
}
else d[i][j]=INF;
while(1){
a = q.front();
q.pop();
rep(k,0,3){
b = MP(a.first+dy[k],a.second+dx[k]);
if(m[b.first][b.second]=='X')continue;
if(d[a.first][a.second]+1 < d[b.first][b.second]){
d[b.first][b.second] = d[a.first][a.second]+1;
if(m[b.first][b.second]=='0'+s+1)return d[b.first][b.second];
q.push(b);
}
}
}
return -1;
}
int main(){
cin>>h>>w>>n;
memset(m,'X',sizeof(m));
rep(i,1,h)rep(j,1,w){
cin>>m[i][j];
if(m[i][j]=='S')m[i][j]='0';
}
int ans=0;
rep(i,0,n-1)ans += bfs(i);
cout<<ans<<endl;
} | a.cc: In function 'int main()':
a.cc:40:9: error: 'memset' was not declared in this scope
40 | memset(m,'X',sizeof(m));
| ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include<utility>
+++ |+#include <cstring>
4 | using namespace std;
|
s240897284 | p00481 | C++ | #include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
int search(int sx, int sy, int dx, int dy, vector<vector<char> > &f, int w, int h)
{
vector<bool> visit;
queue<pair<pair<int, int>, int> > q;
visit.resize(w * h, false);
q.push_back(make_pair(make_pair(sx, sy), 0);
while(!q.empty()) {
int x = q.front().first.first;
int y = q.front().first.second;
int cost = q.front().second;
q.pop();
if(visit[x * w + y])
continue;
visit[x * w + y] = true;
if(f[x][y] == 'X')
continue;
if(x == dx && y == dy)
return cost;
int ix[4] = {-1, 0, 0, 1};
int iy[4] = {0, -1, 1, 0};
for(int i = 0; i < 4; ++i) {
int nx = ix[i] + x;
int ny = iy[i] + y;
if(nx < 0 || ny < 0 || nx >= w || ny >= h)
continue;
q.push(make_pair(make_pair(nx, ny), cost + 1));
}
}
return -1;
}
int main() {
int h, w, n;
vector<vector<char> > f;
vector<pair<int, int> pos;
scanf("%d%d%d", &h, &w, &n);
f.resize(h);
pos.resize(n + 1);
for(int i = 0; i < h; ++i) {
char temp[1024];
scanf("%s", temp);
f[i].resize(w);
for(int j = 0; j < w; ++j) {
f[i][j] = temp[j];
if(f[i][j] == 'S')
pos[0] = make_pair(i, j);
if('0' <= f[i][j] && f[i][j] <= '9')
pos[f[i][j] - '0'] = make_pair(i, j);
}
}
int ans = 0;
for(int i = 1; i <= n; ++i) {
int sx = pos[i - 1].first;
int sy = pos[i - 1].second;
int dx = pos[i].first;
int dy = pos[i].second;
ans += search(sx, sy, dx, dy, f, w, h);
}
printf("%d\n", ans);
return 0;
} | a.cc: In function 'int search(int, int, int, int, std::vector<std::vector<char> >&, int, int)':
a.cc:12:3: error: 'class std::queue<std::pair<std::pair<int, int>, int> >' has no member named 'push_back'
12 | q.push_back(make_pair(make_pair(sx, sy), 0);
| ^~~~~~~~~
a.cc:12:44: error: expected ')' before ';' token
12 | q.push_back(make_pair(make_pair(sx, sy), 0);
| ~ ^
| )
a.cc: In function 'int main()':
a.cc:41:23: error: template argument 1 is invalid
41 | vector<pair<int, int> pos;
| ^~~
a.cc:41:23: error: template argument 2 is invalid
a.cc:44:1: error: 'pos' was not declared in this scope
44 | pos.resize(n + 1);
| ^~~
|
s098930293 | p00481 | C++ | #include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
int search(int sx, int sy, int dx, int dy, vector<vector<char> > &f, int w, int h)
{
vector<bool> visit;
queue<pair<pair<int, int>, int> > q;
visit.resize(w * h, false);
q.push_back(make_pair(make_pair(sx, sy), 0));
while(!q.empty()) {
int x = q.front().first.first;
int y = q.front().first.second;
int cost = q.front().second;
q.pop();
if(visit[x * w + y])
continue;
visit[x * w + y] = true;
if(f[x][y] == 'X')
continue;
if(x == dx && y == dy)
return cost;
int ix[4] = {-1, 0, 0, 1};
int iy[4] = {0, -1, 1, 0};
for(int i = 0; i < 4; ++i) {
int nx = ix[i] + x;
int ny = iy[i] + y;
if(nx < 0 || ny < 0 || nx >= w || ny >= h)
continue;
q.push(make_pair(make_pair(nx, ny), cost + 1));
}
}
return -1;
}
int main() {
int h, w, n;
vector<vector<char> > f;
vector<pair<int, int> pos;
scanf("%d%d%d", &h, &w, &n);
f.resize(h);
pos.resize(n + 1);
for(int i = 0; i < h; ++i) {
char temp[1024];
scanf("%s", temp);
f[i].resize(w);
for(int j = 0; j < w; ++j) {
f[i][j] = temp[j];
if(f[i][j] == 'S')
pos[0] = make_pair(i, j);
if('0' <= f[i][j] && f[i][j] <= '9')
pos[f[i][j] - '0'] = make_pair(i, j);
}
}
int ans = 0;
for(int i = 1; i <= n; ++i) {
int sx = pos[i - 1].first;
int sy = pos[i - 1].second;
int dx = pos[i].first;
int dy = pos[i].second;
ans += search(sx, sy, dx, dy, f, w, h);
}
printf("%d\n", ans);
return 0;
} | a.cc: In function 'int search(int, int, int, int, std::vector<std::vector<char> >&, int, int)':
a.cc:12:3: error: 'class std::queue<std::pair<std::pair<int, int>, int> >' has no member named 'push_back'
12 | q.push_back(make_pair(make_pair(sx, sy), 0));
| ^~~~~~~~~
a.cc: In function 'int main()':
a.cc:41:23: error: template argument 1 is invalid
41 | vector<pair<int, int> pos;
| ^~~
a.cc:41:23: error: template argument 2 is invalid
a.cc:44:1: error: 'pos' was not declared in this scope
44 | pos.resize(n + 1);
| ^~~
|
s128325407 | p00481 | C++ | #include <cstdio>
#include <queue>
#include <algorithm>
using namespace std;
typedef pair<int, int> P;
int h, w, n;
char field[1024][1024];
int dy[] = {1, 0, -1, 0}, dx[] = {0, 1, 0, -1};
int bfs(char st, char en)
{
static int minTime[1024][1024];
queue<P> q;
memset(minTime, -1, sizeof(minTime));
for (int i = 0; i < h; i++){
for (int j = 0; j < w; j++){
if (field[i][j] == st){
q.push(P(i, j));
minTime[i][j] = 0;
}
}
}
for (; !q.empty(); q.pop()){
P now = q.front();
if (field[now.first][now.second] == en) return (minTime[now.first][now.second]);
for (int i = 0; i < 4; i++){
int ny = now.first + dy[i], nx = now.second + dx[i];
if (0 <= ny && ny < h && 0 <= nx && nx < w && minTime[ny][nx] == -1 && field[ny][nx] != 'X'){
minTime[ny][nx] = minTime[now.first][now.second] + 1;
q.push(P(ny, nx));
}
}
}
return (-1);
}
int main()
{
scanf("%d %d %d", &h, &w, &n);
for (int i = 0; i < h; i++){
scanf("%s", field[i]);
}
int cost = bfs('S', '1');
for (int i = 1; i < n; i++){
cost += bfs(i + '0', i + 1 + '0');
}
printf("%d\n", cost);
return (0);
} | a.cc: In function 'int bfs(char, char)':
a.cc:19:9: error: 'memset' was not declared in this scope
19 | memset(minTime, -1, sizeof(minTime));
| ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include <algorithm>
+++ |+#include <cstring>
4 |
|
s411213235 | p00481 | C++ | #include<stdio.h>
#include<utility>
#include<queue>
using namespace std;
char maze[1000][1001];
void solve()
{
bool flag[1000][1000]={0};
int h,w,n,pow=1,ans=0;
int h_route[4]={1,0,-1,0};
int w_route[4]={0,1,0,-1};
typedef pair <int,int> P;
typedef pair<int ,P> P2;
P data[10];
scanf("%d %d %d\n",&h,&w,&n);
for(int i=0;i<h;i++)//迷路読み込み
for(int j=0;j<w+1;j++)
{
scanf("%c",&maze[i][j]);
if(maze[i][j]=='S')
data[0]=P(i,j);
else if(maze[i][j] >='1' && maze[i][j] <='9')
data[maze[i][j]-'0']=P(i,j);
}
for(int i=0;i<n;i++)
{
queue<P2> que;
que.push(P2(ans,P(data[i].first,data[i].second)));
while(!que.empty())
{
P2 temp = que.front();
que.pop();
if(temp.second.first==data[i+1].first && temp.second.second==data[i+1].second)
{
memset(flag,0,sizeof(flag));
ans=temp.first;
break;
}
for(int j=0;j<4;j++)
{
int Th=temp.second.first+h_route[j];
int Tw=temp.second.second+w_route[j];
if(Th>=0 && Th<h && Tw>=0 && Tw<w && maze[Th][Tw]!='X' && flag[Th][Tw]!=1)
{
que.push(P2(temp.first+1,P(Th,Tw)));
flag[Th][Tw]=1;
}
}
}
}
printf("%d\n",ans);
}
int main()
{
solve();
} | a.cc: In function 'void solve()':
a.cc:41:33: error: 'memset' was not declared in this scope
41 | memset(flag,0,sizeof(flag));
| ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include<queue>
+++ |+#include <cstring>
4 | using namespace std;
|
s827213710 | p00481 | C++ | #include <iostream>
#include <memory.h>
#include <queue>
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, -1, 0, 1};
int c[1000][1000];
int dat[1000][1000];
int cost[1000][1000];
int destination = 1;
int startposx, startposy;
int h, w, n;
void bfsToDestination(int x, int y);
int main (void) {
int i, j;
scanf("%d%d%d", &w, &h, &n);
for(i = 0; i < h; i++) {
for(j = 0; j < w; j++) {
dat[j][i] = fgetc(stdin);
if (dat[j][i] == '\n') dat[j][i] = fgetc(stdin);
if (dat[j][i] == 'S') {
startposx = j; startposy = i;
}
}
}
for(i = 0; i < h; i++) {
for(j = 0; j < w; j++) {
printf("%c", dat[j][i]);
}
printf("\n");
}
for (i = 0; i < n; i++) {
memcpy(c, dat, sizeof(dat));
bfsToDestination(startposx, startposy);
}
std::cout << cost[startposx][startposy] << "\n";
return 0;
}
void bfsToDestination(int x, int y) {
int i;
queue<int> qx, qy;
qx.push(x); qy.push(y);
c[x][y] = 'X';
cost[x][y] = 0;
while(!qx.empty()) {
qx.pop(); qy.pop();
for (i = 0; i < 4; i++) {
int nx = x + dx[i];
int ny = y + dy[i];
if ((nx >= 0) && (ny >= 0) && (nx < w) && (ny < h )) {
if (c[nx][ny] != 'X') {
qx.push(); qy.push();
c[x][y] = 'X';
cost[nx][ny] = cost[x][y] + 1;
if ((c[nx][ny] - '0') == destination) {
destination++;
startposx = nx; startposy = ny;
return;
}
}
}
}
}
} | a.cc: In function 'void bfsToDestination(int, int)':
a.cc:52:3: error: 'queue' was not declared in this scope; did you mean 'std::queue'?
52 | queue<int> qx, qy;
| ^~~~~
| std::queue
In file included from /usr/include/c++/14/queue:66,
from a.cc:3:
/usr/include/c++/14/bits/stl_queue.h:96:11: note: 'std::queue' declared here
96 | class queue
| ^~~~~
a.cc:52:9: error: expected primary-expression before 'int'
52 | queue<int> qx, qy;
| ^~~
a.cc:54:3: error: 'qx' was not declared in this scope; did you mean 'x'?
54 | qx.push(x); qy.push(y);
| ^~
| x
a.cc:54:15: error: 'qy' was not declared in this scope; did you mean 'y'?
54 | qx.push(x); qy.push(y);
| ^~
| y
|
s540174024 | p00481 | C++ | 10 10 9
.X...X.S.X
6..5X..X1X
...XXXX..X
X..9X...X.
8.X2X..X3X
...XX.X4..
XX....7X..
X..X..XX..
X...X.XX..
..X....... | a.cc:3:1: error: too many decimal points in number
3 | 6..5X..X1X
| ^~~~~~~~~~
a.cc:1:1: error: expected unqualified-id before numeric constant
1 | 10 10 9
| ^~
|
s099528748 | p00481 | C++ | #include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#define INF 100000000
using namespace std;
//firstにh、secondにwを入れる
typedef pair<int, int> PII;
//S、1...Nまでの座標を格納する
PII cheese[10];
const int MAX_H = 1010, MAX_W = 1010;
int H, W, N;
char field[MAX_H][MAX_W];
int d[MAX_H][MAX_W];
int dh[] = {1, 0, -1, 0};
int dw[] = {0, 1, 0, -1};
bool infield(int h, int w){
return (0<=h && h<H && 0<=w && w<W);
}
//sからgまでの最短手数を返す
int bfs(PII s, PII g){
queue<PII> que;
//init
/*
for(int i=0; i<H; i++){
for(int j=0; j<W; j++)
d[i][j] = INF;
}
*/
fill(d, sizeof(d), INF);
que.push(s);
d[s.first][s.second] = 0;
while(!que.empty()){
PII p = que.front(); que.pop();
if(p == g)
break;
for(int i=0; i<4; i++){
int nh = p.first+dh[i];
int nw = p.second+dw[i];
if(infield(nh, nw) && field[nh][nw]!='X' && d[nh][nw]==INF){
que.push(PII(nh, nw));
d[nh][nw] = d[p.first][p.second] + 1;
}
}
}
return d[g.first][g.second];
}
void solve(){
int ans = 0;
//cheeseリストを作る
for(int i=0; i<H; i++){
for(int j=0; j<W; j++){
if(field[i][j] == 'S')
cheese[0] = PII(i, j);
for(char c='1'; c<='9'; c++){
if(field[i][j] == c)
cheese[c-'0'] = PII(i, j);
}
}
}
for(int i=0; i<N; i++)
ans += bfs(cheese[i], cheese[i+1]);
printf("%d\n", ans);
}
int main(){
scanf("%d%d%d", &H, &W, &N);
for(int i=0; i<H; i++)
scanf("%s", field[i]);
solve();
return 0;
} | a.cc: In function 'int bfs(PII, PII)':
a.cc:36:9: error: no matching function for call to 'fill(int [1010][1010], long unsigned int, int)'
36 | fill(d, sizeof(d), INF);
| ~~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/vector:62,
from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h:1022:5: note: candidate: 'template<class _ForwardIterator, class _Tp> void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&)'
1022 | fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:1022:5: note: template argument deduction/substitution failed:
a.cc:36:9: note: deduced conflicting types for parameter '_ForwardIterator' ('int (*)[1010]' and 'long unsigned int')
36 | fill(d, sizeof(d), INF);
| ~~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:86,
from a.cc:4:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:191:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::fill(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
191 | fill(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:191:1: note: candidate expects 4 arguments, 3 provided
|
s470596959 | p00481 | C++ | #include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#define INF 100000000
using namespace std;
//firstにh、secondにwを入れる
typedef pair<int, int> PII;
//S、1...Nまでの座標を格納する
PII cheese[10];
const int MAX_H = 1010, MAX_W = 1010;
int H, W, N;
char field[MAX_H][MAX_W];
int d[MAX_H][MAX_W];
int dh[] = {1, 0, -1, 0};
int dw[] = {0, 1, 0, -1};
bool infield(int h, int w){
return (0<=h && h<H && 0<=w && w<W);
}
//sからgまでの最短手数を返す
int bfs(PII s, PII g){
queue<PII> que;
//init
/*
for(int i=0; i<H; i++){
for(int j=0; j<W; j++)
d[i][j] = INF;
}
*/
fill(d, d+sizeof(d), INF);
que.push(s);
d[s.first][s.second] = 0;
while(!que.empty()){
PII p = que.front(); que.pop();
if(p == g)
break;
for(int i=0; i<4; i++){
int nh = p.first+dh[i];
int nw = p.second+dw[i];
if(infield(nh, nw) && field[nh][nw]!='X' && d[nh][nw]==INF){
que.push(PII(nh, nw));
d[nh][nw] = d[p.first][p.second] + 1;
}
}
}
return d[g.first][g.second];
}
void solve(){
int ans = 0;
//cheeseリストを作る
for(int i=0; i<H; i++){
for(int j=0; j<W; j++){
if(field[i][j] == 'S')
cheese[0] = PII(i, j);
for(char c='1'; c<='9'; c++){
if(field[i][j] == c)
cheese[c-'0'] = PII(i, j);
}
}
}
for(int i=0; i<N; i++)
ans += bfs(cheese[i], cheese[i+1]);
printf("%d\n", ans);
}
int main(){
scanf("%d%d%d", &H, &W, &N);
for(int i=0; i<H; i++)
scanf("%s", field[i]);
solve();
return 0;
} | In file included from /usr/include/c++/14/vector:62,
from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'typename __gnu_cxx::__enable_if<std::__is_scalar<_Tp>::__value, void>::__type std::__fill_a1(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = int (*)[1010]; _Tp = int; typename __gnu_cxx::__enable_if<__is_scalar<_Tp>::__value, void>::__type = void]':
/usr/include/c++/14/bits/stl_algobase.h:998:21: required from 'void std::__fill_a(_FIte, _FIte, const _Tp&) [with _FIte = int (*)[1010]; _Tp = int]'
998 | { std::__fill_a1(__first, __last, __value); }
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:1029:20: required from 'void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = int (*)[1010]; _Tp = int]'
1029 | std::__fill_a(__first, __last, __value);
| ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:36:9: required from here
36 | fill(d, d+sizeof(d), INF);
| ~~~~^~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:952:18: error: incompatible types in assignment of 'const int' to 'int [1010]'
952 | *__first = __tmp;
| ~~~~~~~~~^~~~~~~
|
s307959665 | p00481 | C++ | #include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
int mincount;
struct OBJ{
public:
OBJ(char a, bool b):kind(a), mark(b){}
char kind;
bool mark;
};
void dfs(char target, pair<int, int> &pos, vector<vector<OBJ> > &field, int count){
if(field[pos.second][pos.first].kind == target){
mincount = mincount > count ? count : mincount;
return;
}
field[pos.second][pos.first].mark = true;
for(int i = 0; i < 4; i++){
if((pos.first+dx[i]<0||pos.first+dx[i]>=field[0].size())||(pos.second+dy[i]<0||pos.second+dy[i]>=field.size())) continue;
if(field[pos.second+dy[i]][pos.first+dx[i]].kind != 'X' && !field[pos.second+dy[i]][pos.first+dx[i]].mark){
dfs(target, pair<int, int>(pos.first+dx[i], pos.second+dy[i]), field, count + 1);
}
}
field[pos.second][pos.first].mark = false;
}
pair<int, int> decideStart(char target, vector<vector<OBJ> > &field){
for(int i = 0; i < field.size(); i++){
for(int j = 0; j < field[i].size(); j++){
if(field[i][j].kind == target) return pair<int, int>(j, i);
}
}
}
int main(){
int h = 0, w = 0, n = 0;
cin >> h >> w >> n;
cin.ignore();
pair<int, int> start;
vector<vector<OBJ> > field(h, vector<OBJ>(w, OBJ(' ', false)));
for(int i = 0; i < h; i++){
string tmp;
getline(cin, tmp);
for(int j = 0; j < w; j++){
field[i][j].kind = tmp[j];
if(tmp[j] == 'S') start = pair<int, int>(j, i);
}
}
int count = 0;
for(int i = 1; i <= n; i++){
mincount = h*w;
dfs(i+'0', start, field, 0);
count += mincount;
start = decideStart(i+'0', field);
}
cout << count << endl;
return 0;
} | a.cc: In function 'void dfs(char, std::pair<int, int>&, std::vector<std::vector<OBJ> >&, int)':
a.cc:34:37: error: cannot bind non-const lvalue reference of type 'std::pair<int, int>&' to an rvalue of type 'std::pair<int, int>'
34 | dfs(target, pair<int, int>(pos.first+dx[i], pos.second+dy[i]), field, count + 1);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:25:39: note: initializing argument 2 of 'void dfs(char, std::pair<int, int>&, std::vector<std::vector<OBJ> >&, int)'
25 | void dfs(char target, pair<int, int> &pos, vector<vector<OBJ> > &field, int count){
| ~~~~~~~~~~~~~~~~^~~
a.cc: In function 'std::pair<int, int> decideStart(char, std::vector<std::vector<OBJ> >&)':
a.cc:46:1: warning: control reaches end of non-void function [-Wreturn-type]
46 | }
| ^
|
s935295904 | p00481 | C++ | #include <iostream>
#include <vector>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef pair<int, int> P;
int H, W, N;
char v[1001][1001];
bool visit[1001][1001];
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int bfs(P s, P g){
memset(visit, 0, sizeof(visit));
queue<pair<int, P> > q;
q.push(make_pair(0, s));
int res = 0;
while(!q.empty()){
P p = q.front().second;
int d = q.front().first;
q.pop();
if(visit[p.second][p.first]) continue;
visit[p.second][p.first] = true;
if(p == g) return d;
rep(i, 4){
int nx = p.first + dx[i];
int ny = p.second + dy[i];
if(nx < 0 || nx >= W || ny < 0 || ny >= H) continue;
if(v[ny][nx] == 'X') continue;
q.push(make_pair(d+1, make_pair(nx, ny)));
}
}
return -1;
}
int main(){
cin >> H >> W >> N;
vector<P> pos(10);
rep(i, H) rep(j, W){
cin >> v[i][j];
if(v[i][j] == 'S') pos[0] = make_pair(j, i);
for(int k = '1'; k <= '9'; k++){
if(v[i][j] == k) pos[k-'0'] = make_pair(j, i);
}
}
int ans = 0;
rep(i, N){
ans += bfs(pos[i], pos[i+1]);
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int bfs(P, P)':
a.cc:19:9: error: 'memset' was not declared in this scope
19 | memset(visit, 0, sizeof(visit));
| ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include <queue>
+++ |+#include <cstring>
4 |
|
s207313033 | p00481 | C++ | #include <iostream>
#include <queue>
#include <vector>
#define MAX 1000
using namespace std;
const int INF = 1000000;
typedef pair<int,int> P;
int n,m;
char cheese[MAX+1][MAX+1];
int bfs(int sy,int sx,int gy,int gx){
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int d[MAX][MAX];
queue<P> q;
for( int i = 0 ; i < n ; i++ )
for( int j = 0 ; j < m ; j++ )
d[i][j] = INF;
q.push( P(sy , sx) );
d[sy][sx] = 0;
while( q.size() ){
P p = q.front();
q.pop();
if(p.first == gy && p.second == gx) break;
for(int i = 0 ; i < 4 ; i++){
int x = p.first + dx[i];
int y = p.second + dy[i];
if( 0 <= x && x < n &&
0 <= y && y < m &&
d[x][y] == INF &&
mp[nx][ny]!='X'){
q.push( P(nx , ny) );
d[x][y] = d[p.first][p.second] + 1;
}
}
}
return d[gy][gx];
}
int main(void){
int n;
cin >> n >> m >> num;
vector<P> v(num + 1);
for( int i = 0 ; i < n ; i++ ){
for( int j = 0 ; j < m ; j++ ){
cin >> cheese[i][j];
if( cheese[i][j]=='S'){
v[0].first = i;
v[0].second = j;
}
if('1' <= cheese[i][j] && cheese[i][j] <= '9'){
v[mp[i][j]-'0'].first = i;
v[mp[i][j]-'0'].second = j;
}
}
}
int sum = 0;
for(int i = 1 ; i < num+1 ; i++){
sum += bfs(v[i-1].first,v[i-1].second,v[i].first,v[i].second);
}
cout << sum << endl;
return 0;
} | a.cc: In function 'int bfs(int, int, int, int)':
a.cc:42:15: error: 'mp' was not declared in this scope; did you mean 'p'?
42 | mp[nx][ny]!='X'){
| ^~
| p
a.cc:42:18: error: 'nx' was not declared in this scope; did you mean 'x'?
42 | mp[nx][ny]!='X'){
| ^~
| x
a.cc:42:22: error: 'ny' was not declared in this scope; did you mean 'y'?
42 | mp[nx][ny]!='X'){
| ^~
| y
a.cc: In function 'int main()':
a.cc:56:22: error: 'num' was not declared in this scope; did you mean 'enum'?
56 | cin >> n >> m >> num;
| ^~~
| enum
a.cc:67:19: error: 'mp' was not declared in this scope; did you mean 'm'?
67 | v[mp[i][j]-'0'].first = i;
| ^~
| m
|
s618262964 | p00481 | C++ | #include <iostream>
#include <queue>
#include <vector>
#define MAX 1000
using namespace std;
const int INF = 1000000;
typedef pair<int,int> P;
int n,m;
char cheese[MAX+1][MAX+1];
int bfs(int sy,int sx,int gy,int gx){
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int d[MAX][MAX];
queue<P> q;
for( int i = 0 ; i < n ; i++ )
for( int j = 0 ; j < m ; j++ )
d[i][j] = INF;
q.push( P(sy , sx) );
d[sy][sx] = 0;
while( q.size() ){
P p = q.front();
q.pop();
if(p.first == gy && p.second == gx) break;
for(int i = 0 ; i < 4 ; i++){
int x = p.first + dx[i];
int y = p.second + dy[i];
if( 0 <= x && x < n &&
0 <= y && y < m &&
d[x][y] == INF &&
mp[nx][ny]!='X'){
q.push( P(nx , ny) );
d[x][y] = d[p.first][p.second] + 1;
}
}
}
return d[gy][gx];
}
int main(void){
int n;
cin >> n >> m >> num;
vector<P> v(num + 1);
for( int i = 0 ; i < n ; i++ ){
for( int j = 0 ; j < m ; j++ ){
cin >> cheese[i][j];
if( cheese[i][j]=='S'){
v[0].first = i;
v[0].second = j;
}
if('1' <= cheese[i][j] && cheese[i][j] <= '9'){
v[mp[i][j]-'0'].first = i;
v[mp[i][j]-'0'].second = j;
}
}
}
int sum = 0;
for(int i = 1 ; i < num+1 ; i++){
sum += bfs(v[i-1].first,v[i-1].second,v[i].first,v[i].second);
}
cout << sum << endl;
retur | a.cc: In function 'int bfs(int, int, int, int)':
a.cc:42:15: error: 'mp' was not declared in this scope; did you mean 'p'?
42 | mp[nx][ny]!='X'){
| ^~
| p
a.cc:42:18: error: 'nx' was not declared in this scope; did you mean 'x'?
42 | mp[nx][ny]!='X'){
| ^~
| x
a.cc:42:22: error: 'ny' was not declared in this scope; did you mean 'y'?
42 | mp[nx][ny]!='X'){
| ^~
| y
a.cc: In function 'int main()':
a.cc:56:22: error: 'num' was not declared in this scope; did you mean 'enum'?
56 | cin >> n >> m >> num;
| ^~~
| enum
a.cc:67:19: error: 'mp' was not declared in this scope; did you mean 'm'?
67 | v[mp[i][j]-'0'].first = i;
| ^~
| m
a.cc:79:5: error: 'retur' was not declared in this scope
79 | retur
| ^~~~~
a.cc:79:10: error: expected '}' at end of input
79 | retur
| ^
a.cc:52:15: note: to match this '{'
52 | int main(void){
| ^
|
s905330229 | p00481 | C++ | #include <iostream>
#include <queue>
#include <vector>
#define MAX 1000
using namespace std;
const int INF = 1000000;
typedef pair<int,int> P;
int n,m;
char cheese[MAX+1][MAX+1];
int bfs(int sy,int sx,int gy,int gx){
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int d[MAX][MAX];
queue<P> q;
for( int i = 0 ; i < n ; i++ )
for( int j = 0 ; j < m ; j++ )
d[i][j] = INF;
q.push( P(sy , sx) );
d[sy][sx] = 0;
while( q.size() ){
P p = q.front();
q.pop();
if(p.first == gy && p.second == gx) break;
for(int i = 0 ; i < 4 ; i++){
int x = p.first + dx[i];
int y = p.second + dy[i];
if( 0 <= x && x < n &&
0 <= y && y < m &&
d[x][y] == INF &&
mp[nx][ny]!='X'){
q.push( P(nx , ny) );
d[x][y] = d[p.first][p.second] + 1;
}
}
}
return d[gy][gx];
}
int main(void){
int num;
cin >> n >> m >> num;
vector<P> v(num + 1);
for( int i = 0 ; i < n ; i++ ){
for( int j = 0 ; j < m ; j++ ){
cin >> cheese[i][j];
if( cheese[i][j]=='S'){
v[0].first = i;
v[0].second = j;
}
if('1' <= cheese[i][j] && cheese[i][j] <= '9'){
v[mp[i][j]-'0'].first = i;
v[mp[i][j]-'0'].second = j;
}
}
}
int sum = 0;
for(int i = 1 ; i < num+1 ; i++){
sum += bfs(v[i-1].first,v[i-1].second,v[i].first,v[i].second);
}
cout << sum << endl;
return 0;
} | a.cc: In function 'int bfs(int, int, int, int)':
a.cc:42:15: error: 'mp' was not declared in this scope; did you mean 'p'?
42 | mp[nx][ny]!='X'){
| ^~
| p
a.cc:42:18: error: 'nx' was not declared in this scope; did you mean 'x'?
42 | mp[nx][ny]!='X'){
| ^~
| x
a.cc:42:22: error: 'ny' was not declared in this scope; did you mean 'y'?
42 | mp[nx][ny]!='X'){
| ^~
| y
a.cc: In function 'int main()':
a.cc:67:19: error: 'mp' was not declared in this scope; did you mean 'm'?
67 | v[mp[i][j]-'0'].first = i;
| ^~
| m
|
s459853211 | p00481 | C++ | #include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <MAP>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
using namespace std;
int H,W,N;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
char MAP[1000+1][1000+1];
int f[1000+1][1000+1];
int d[1000+1][1000+1];
int main(){
cin >> H >> W >> N;
queue<char> qux;
queue<char> quy;
vector<int> ans(N+1);
for(int i=1; i<H+1; ++i){
for(int j=1; j<W+1; ++j){
cin >> MAP[i][j];
f[i][j]=0;
if(MAP[i][j]=='S'){
qux.push(i);
quy.push(j);
f[i][j]=1;
d[i][j]=0;
}
}
}
int x;
int y;
for(int i=1; i<N+1; ++i){
while(1/*qux.size()&&quy.size()*/){
x=qux.front();
y=quy.front();
//cout << x << " " << y << " " << d[x][y] << "\n";
qux.pop();
quy.pop();
//if('0'<=MAP[x][y]&&MAP[x][y]<='9'){
//if(((int)MAP[x][y]-'0')==i) {
if(atoi(&MAP[x][y])==i){
ans[i]=d[x][y];
for(int j=1; j<H+1; ++j){
for(int k=1; k<W+1; ++k){
f[i][j]=0;
}
}
d[x][y]=0;
break;
}
//}
for(int j=0; j<4; ++j){
int nx=x+dx[j];
int ny=y+dy[j];
if(1<=nx&&nx<=H&&1<=ny&&ny<=W&&MAP[nx][ny]!='X'&&f[nx][ny]==0){
qux.push(nx);
quy.push(ny);
f[nx][ny]=1;
d[nx][ny]=d[x][y]+1;
}
}
}
}
int ANS=0;
for(int i=1; i<N+1; ++i){
ANS+=ans[i];
}
cout << ANS << "\n";
return 0;
} | a.cc:5:10: fatal error: MAP: No such file or directory
5 | #include <MAP>
| ^~~~~
compilation terminated.
|
s897855441 | p00481 | C++ | #include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<string.h>
using namespace std;
typedef struct {
short cost, x, y;
}Point;//螳壻ケ我ク?クェ扈捺桷菴鍋畑譚・蟄伜お豈丈クェ蟾・蜴ら噪蝮先?菴咲スョ蜥悟・カ驟ェ逧??
int H, W, N;
vector<Point> factory;
char map[1000][1002];
bool tag[1002][1002];
short dx[4] = {-1, 1, 0, 0}, dy[4] = {0, 0, -1, 1};
bool myfunction(Point a, Point b)
{
return a.cost < b.cost;
}
int bfs(int sx, int sy, int ex, int ey);
int main()
{
cin>>H>>W>>N;
int sx, sy;
for(int i = 0; i < H; i++){
cin>>map[i];
for(int j = 0; j < W; j++){
if( 1 <= (map[i][j]-'0') && (map[i][j]-'0') <= N){
Point p;
p.x = i, p.y = j, p.cost = map[i][j] - '0';
factory.push_back(p);//謚雁キ・蜴ら噪陦ィ遉コ謾セ蛻ー蜿ッ蜿俶焚扈?クュ
}
if(map[i][j] == 'S')
sx = i, sy = j; //隶ー蠖戊オキ蟋倶ス咲スョ逧?攝譬? }
}
sort(factory.begin(), factory.end(), myfunction);
int ans = 0;
int start_x = sx, start_y = sy;
for(int i = 0; i < factory.size(); i++){
// cout<<start_x<<'\t'<<start_y<<'\t'<<factory[i].x<<'\t'<<factory[i].y<<endl;
ans += bfs(start_x, start_y, factory[i].x, factory[i].y);
start_x = factory[i].x; start_y = factory[i].y;
}
//bfs(1, 8, 4, 3);
cout<<ans<<endl;
return 0;
}
int bfs(int sx, int sy, int ex, int ey)
{
for(int i = 0; i < H; i++)//逕ィ霑吩クェ謨ー扈?擂譬?ョー譟蝉クェ菴咲スョ譏ッ蜷ヲ蟾イ扈丞惠髦溷?荳ュ莠? fill(tag[i], tag[i]+W, false);
queue<Point> q;
Point s;
s.x = sx; s.y = sy; s.cost = 0;//蛻晏ァ句喧蠑?ァ狗噪豁・謨ー荳コ0
q.push(s);//謚願オキ蟋狗せ謾セ蛻ー髦溷?荳ュ
tag[sx][sy] = true;
while(!q.empty()){
s = q.front();
q.pop();
tag[s.x][s.y] = false;
//if(sx == ex && sy == ey) return s.cost;
for(int i = 0; i < 4; i++){
int xx,yy;
xx = s.x + dx[i]; yy = s.y + dy[i];
if(xx == ex && yy == ey) return s.cost+1;//螯よ棡蟾イ扈丞芦莠?サ育せ蛻呵ソ泌屓螳?噪豁・謨ー
if(xx >= 0 && xx < H && yy >= 0 && yy < W && map[xx][yy] != 'X' && !tag[xx][yy]){
// cout<<xx<<'\t'<<yy<<endl;
Point now;
now.x = xx; now.y = yy; now.cost = s.cost + 1;
q.push(now);
tag[xx][yy] = true;
}
}//for()
}//while()
}//bfs() | a.cc: In function 'int main()':
a.cc:54:1: error: a function-definition is not allowed here before '{' token
54 | {
| ^
a.cc:79:2: error: expected '}' at end of input
79 | }//bfs()
| ^
a.cc:22:1: note: to match this '{'
22 | {
| ^
|
s301103289 | p00481 | C++ | #include <cstdio>
#include <cctype>
#include <vector>
#include <queue>
using namespace std;
char s[1000][1000];
char state[1000][1000];
int H, W, N;
int main()
{
//freopen("in.txt", "r", stdin);
while (scanf("%d%d%d", &H, &W, &N)==3) {
if (H==0 && W==0) break;
int i, j;
char c;
int si, sj;
for (i=0; i<H; i++) {
for (j=0; j<W; j++) {
do { c=getchar();
} while (c!='.' && c!='S' && c!='X' && !isdigit(c));
s[i][j] = c;
if (c=='S') {
si = i; sj = j;
}
}
}
memset(state, 0, sizeof(state));
state[si][sj] = 1;
int step=0;
int want=1;
queue<int> q1, q2, *q, *nq, *qtmp;
static int dx[4] = {1, -1, 0, 0};
static int dy[4] = {0, 0, -1, 1};
q = &q1; nq = &q2;
q1.push((si<<16)|sj);
while (want<=N) {
int old_want=want;
while (!nq->empty()) nq->pop();
step++;
while (!q->empty()) {
int i, j, value;
value = q->front(); q->pop();
i = value>>16; j = value&0xffff;
int k;
for (k=0; k<4; k++) {
int ti, tj;
ti = i+dy[k]; tj = j+dx[k];
if (ti<0 || ti>=H || tj<0 || tj>=W || s[ti][tj]=='X') continue;
if (state[ti][tj]==want) continue;
if (s[ti][tj]==want+'0') {
want++;
}
state[ti][tj] = want;
nq->push((ti<<16)|tj);
if (want!=old_want) break;
}
if (want!=old_want) break;
}
if (want!=old_want) {
while (nq->size()>1) nq->pop();
}
qtmp = q; q = nq; nq = qtmp;
}
printf("%d\n", step);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:36:17: error: 'memset' was not declared in this scope
36 | memset(state, 0, sizeof(state));
| ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
4 | #include <queue>
+++ |+#include <cstring>
5 |
|
s298541235 | p00482 | C | #include <iostream>
#include <stdio.h>
#include <string.h>
#define MOD 100000
#define FMAX 10946
#define NMMAX 20
using namespace std;
int main(void)
{
int i, j, k, m, n, fcheck, mask, ans = 1, res = 0, fcount = 0;
int k2b[FMAX], b2k[1<<19], dp[2][FMAX][2];
char field[NMMAX][NMMAX+1];
scanf("%d %d%*c", &m, &n);
for (i = 0; i < m; i++) {
for (j = 0; j < n; j++) {
field[i][j] = getchar();
if (field[i][j] == '?') ans = (ans * 3) % MOD;
}
getchar();
}
for (i = 0; i < (1 << (n - 1)); i++) {
fcheck = 1;
for (j = 0; j < n - 2; j++) {
if (((i >> j) & 1) & ((i >> (j + 1)) & 1)) {
fcheck = 0;
break;
}
}
if (fcheck) {
k2b[fcount] = i;
b2k[i] = fcount++;
}
}
mask = (1 << (n - 1)) - 1;
fcheck = 1;
auto &src = dp[0];
auto &dst = dp[1];
src[0][0] = 1;
for (i = 0; i < m; i++) {
for (j = 0; j < n; j++) {
memset(dst, 0, sizeof(dst));
for (k = 0; k < fcount; k++) {
int nk, jflag;
if (field[i][j] == 'J' || field[i][j] == '?') {
nk = b2k[(k2b[k] << 1) & mask];
jflag = (j < n - 1);
dst[nk][jflag] = ((dst[nk][jflag]) + (src[k][0]) + (src[k][1]))% MOD;
}
if (field[i][j] == 'O' || field[i][j] == '?') {
nk = b2k[((k2b[k] << 1) & mask) | 0];
jflag = 0;
dst[nk][jflag] = ((dst[nk][jflag]) + (src[k][0]))% MOD;
nk = b2k[((k2b[k] << 1) & mask) | 1];
dst[nk][jflag] = ((dst[nk][jflag]) + (src[k][1]))% MOD;
}
if (field[i][j] == 'I' || field[i][j] == '?') {
if (((~k2b[k]) >> (n - 2)) & 1) {
nk = b2k[(k2b[k] << 1) & mask];
jflag = 0;
dst[nk][jflag] = ((dst[nk][jflag]) + (src[k][0]) + (src[k][1]))% MOD;
}
}
}
swap(src, dst);
fcheck ^= 1;
}
}
for (i = 0; i < fcount; i++) res = (res + (src[i][0]) + (src[i][1])) % MOD;
printf("%d\n", (ans - res + MOD) % MOD);
}
| main.c:1:10: fatal error: iostream: No such file or directory
1 | #include <iostream>
| ^~~~~~~~~~
compilation terminated.
|
s757706275 | p00482 | C | #include <stdio.h>
#include <string.h>
#define MOD 100000
int dp[17712][20][20]; //1(JOª é)ÍA±µÄÍ¢¯È¢->fib(21) = 17711Êè
int x, y;
char map[20][21];
int mask;
short index[1 << 20];
int solve(int place, int bit)
{
int res;
int nx, ny;
if (place == y * x){
return (1);
}
ny = place / x;
nx = place % x;
res = dp[index[bit]][ny][nx];
if (res == -1){
int temp = 0;
// u©êé̪J
if (map[ny][nx] == '?' || map[ny][nx] == 'J'){
int nextbit = bit;
if (nextbit & 1){
nextbit = ((nextbit - 1) << 1) | 1; //Jðu¢½_Å, »±ÍJOªA±µÈ¢
}
else {
nextbit = (nextbit << 1) | 1; //ãÆ¯¶.
}
nextbit &= mask;
temp += solve(place + 1, nextbit);
if (temp >= MOD){
temp -= MOD;
}
}
//u©êé̪O
if (map[ny][nx] == '?' || map[ny][nx] == 'O'){
int nextbit = bit;
nextbit <<= 1;
nextbit &= mask;
temp += solve(place + 1, nextbit);
if (temp >= MOD){
temp -= MOD;
}
}
//u©êé̪I
if (map[ny][nx] == '?' || map[ny][nx] == 'I'){
if (((1 << (x - 1)) & bit) == 0 || nx == x - 1){ //¡Ìêª, sÌ[©, ¿å¤ÇãÌêÉJOªÈ¯êÎ
int nextbit = bit;
if (nextbit & 1){
nextbit = (nextbit - 1) << 1;
}
else {
nextbit <<= 1;
}
nextbit &= mask;
temp += solve(place + 1, nextbit);
if (temp >= MOD){
temp -= MOD;
}
}
}
res = temp;
}
return (dp[index[bit]][ny][nx] = res);
}
int main(void)
{
int i, j;
int q;
int ans;
int temp, num, flag;
scanf("%d%d", &y, &x);
getchar();
q = 1;
for (i = 0; i < y; i++){
for (j = 0; j < x; j++){
scanf("%c", &map[i][j]);
if (map[i][j] == '?'){
q *= 3;
if (q >= MOD){
q -= MOD;
}
}
}
getchar();
}
memset(index, -1, sizeof(index));
num = 0;
for (i = 0; i < 1 << x; i++){
flag = 1;
temp = i << 1;
while (temp != 0){
if ((temp >> 1) & 1 && (temp >> 2) & 1){
flag = 0;
break;
}
temp >>= 1;
}
if (flag){
index[i] = num++;
}
}
mask = (1 << x) - 1;
memset(dp, -1, sizeof(dp));
ans = solve(0, 0);
printf("%d\n", (q - ans + MOD) % MOD);
return (0);
} | main.c:10:7: error: 'index' redeclared as different kind of symbol
10 | short index[1 << 20];
| ^~~~~
In file included from /usr/include/string.h:462,
from main.c:2:
/usr/include/strings.h:68:14: note: previous declaration of 'index' with type 'char *(const char *, int)'
68 | extern char *index (const char *__s, int __c)
| ^~~~~
|
s548730749 | p00482 | C++ |
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include<iostream>
#include<map>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
string FL[30]; //旗
long long int data[500] = {}; //fib
int que[30][30] = {}; //'?'の数の累積和
int m, n; //m :縦、n:横
int hatena =0; // hatena の数
int ok[30][30] = {};
long long int sum = 0;
long long int check(int tate,int yoko)
{
//JOIが成り立たない場合0を返す
if (FL[tate][yoko + 1] == 'J' || FL[tate][yoko + 1] == 'I' || FL[tate + 1][yoko] == 'J' || FL[tate + 1][yoko] == 'O')return 0;
//now:今見ているJOIの中に含まれる'?'の数
int now = 0;
if (FL[tate + 1][yoko] == '?')now++;
if (FL[tate][yoko] == '?')now++;
if (FL[tate][yoko + 1] == '?')now++;
int hage = hatena - now; //que[m - 1][n - 1] - ((tate-2<0)?0:que[tate-2][n-1]) -now;
return data[hage];//+ok[tate][yoko-1]-ok[max(0,tate-1)][yoko];
}
int main()
{
cin >> m >> n;
for (int i = 0; i < m; i++)//in
{
cin >> FL[i];
for (int k = 0; k < n; k++)
{
if (FL[i][k] == '?'){
que[i][k]++;
hatena++;
}
}
}
for (int i = 0; i < m; i++)//'?'の数の累積和を取得
{
for (int k = 0; k < n - 1; k++)
{
if (k == 0 && i != 0)
{
que[i][k] += que[i - 1][n - 1];
}
que[i][k + 1] += que[i][k];
}
}
data[0] = 1;
for (int i = 1; i <= hatena; i++)//フィナボッチ数列
{
data[i] = data[i - 1]*3;
}
long long int ans = 0;
for (int i = 0; i < m-1; i++)
{
for (int k = 0; k < n-1; k++)
{
if (FL[i][k] == 'J' || FL[i][k] == '?')
{
long long int g = check(i, k);
ans += g;
if (g){
sum++;
for (int s = 0; s < i; s++)
{
for (int b = 0; b < n; b++)ok[s][b]++;
}
for (int s = 0; s <= k; s++)ok[i][s]++;
}
}
}
ans %= 100000;
}
int qqwe=1;
for(int i=1;i<=sum;i++)qqwe*=i;
cout << ans-qqwe << endl;
return 0;
}
| a.cc:2:1: error: expected unqualified-id before numeric constant
2 | 5
| ^
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:93:
/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_NODI |
s919864845 | p00482 | C++ | #include<bits/stdc++.h>
using namespace std;
const int MOD = 100000;
class ModInt {
public:
ModInt(int n = 0) : n_(n % MOD) {while(n_ < 0) n_ += MOD;}
int value() const {return n_;}
ModInt& operator+=(const ModInt& rhs);
private:
int n_;
};
const ModInt operator+(const ModInt& lhs, const ModInt& rhs) {
return lhs.value() + rhs.value();
}
const ModInt operator-(const ModInt& lhs, const ModInt& rhs) {
return lhs.value() - rhs.value();
}
ModInt& ModInt::operator+=(const ModInt& rhs) {return *this = *this + rhs;}
bool good(const vector<string>& flag) {
for(int i = 0; i < flag.size() - 1; ++i)
for(int j = 0; j < flag[i].size() - 1; ++j)
if(flag[i][j] == 'J' && flag[i][j+1] == 'O' && flag[i+1][j] == 'I')
return true;
return false;
}
int count(const vector<string>& flag, char c) {
return accumulate(begin(flag), end(flag), 0, [=](int sum, const string& s){
return sum + count(begin(s), end(s), c);
});
}
int modpower(int x, int n, int mod) {
if(!n) return 1;
return n&1 ? x*modpower(x*x%mod, n>>1, mod)%mod : modpower(x*x%mod, n>>1, mod);
}
bool test(int bit, int i) {
assert(0 <= i);
return bit & (1 << i);
}
int set(int bit, int i) {
assert(0 <= i);
return bit | (1 << i);
}
int reset(int bit, int i) {
assert(0 <= i);
return bit & ((~0) ^ (1 << i));
}
int solve(const vector<string>& flag) {
ModInt all = modpower(3, count(flag, '?'), MOD);
if(good(flag)) return all.value();
const int H = flag.size(), W = flag.front().size();
const int BIT = 1 << W;
vector<ModInt> cur(BIT);
cur[0] = 1;
for(int i = 0; i < H; ++i) for(int j = 0; j < W; ++j) {
vector<ModInt> nex(BIT);
for(int bit = 0; bit < BIT; ++bit) {
int nbit = reset(bit, j);
if(flag[i][j] == 'J' || flag[i][j] == '?') {
if(j == W-1 || flag[i][j+1] != 'O' || i == H-1 || flag[i+1][j] != 'I') {
if(j) nex[set(reset(nbit, j-1), j)] += cur[bit];
else nex[set(nbit, j)] += cur[bit];
}
}
if(flag[i][j] == 'O' || flag[i][j] == '?') {
if(!j || i == H-1 || !test(bit, j-1) || flag[i+1][j-1] != 'I') {
nex[nbit] += cur[bit];
}
}
if(flag[i][j] == 'I' || flag[i][j] == '?') {
if(!i || j == W-1 || !test(bit, j)) {
if(j) nex[reset(nbit, j-1)] += cur[bit];
else nex[nbit] += cur[bit];
}
}
}
cur = nex;
}
return (all - accumulate(begin(cur), end(cur), ModInt(0))).value();
}
int main() {
int M, N;
cin >> M >> N;
vector<string> flag(M);
for(auto& i: flag) cin >> i;
cout << solve(flag) << endl;
} | a.cc: In function 'int solve(const std::vector<std::__cxx11::basic_string<char> >&)':
a.cc:68:21: error: reference to 'set' is ambiguous
68 | if(j) nex[set(reset(nbit, j-1), j)] += cur[bit];
| ^~~
In file included from /usr/include/c++/14/set:63,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:158,
from a.cc:1:
/usr/include/c++/14/bits/stl_set.h:96:11: note: candidates are: 'template<class _Key, class _Compare, class _Alloc> class std::set'
96 | class set
| ^~~
a.cc:45:5: note: 'int set(int, int)'
45 | int set(int bit, int i) {
| ^~~
a.cc:69:20: error: reference to 'set' is ambiguous
69 | else nex[set(nbit, j)] += cur[bit];
| ^~~
/usr/include/c++/14/bits/stl_set.h:96:11: note: candidates are: 'template<class _Key, class _Compare, class _Alloc> class std::set'
96 | class set
| ^~~
a.cc:45:5: note: 'int set(int, int)'
45 | int set(int bit, int i) {
| ^~~
|
s912754651 | p00482 | C++ | #include <bits/stdc++.h>
using namespace std;
const int MOD = 1e5;
int conv[256];
int k2b[10946], b2k[1 << 19];
int n, m;
int g[20][20];
int dp[2][10946][2];
int main()
{
for (int i = 0; i < 4; i++){
conv["JOI?"[i]] = i;
}
cin >> n >> m;
int u = 1;
for (int i = 0; i < n; i++){
for (int j = 0; j < m; j++){
char c;
cin >> c;
g[i][j] = conv[c];
if (c == '?') u = (u * 3) % MOD;
}
}
int tm = 0;
for (int i = 0; i < (1 << (m - 1)); i++){
bool f = true;
for (int j = 0; j < m - 2; j++){
if (((i >> j) & 1) & ((i >> (j + 1)) & 1)) f = false;
}
if (f){
k2b[tm] = i;
b2k[i] = tm;
tm++;
}
}
auto &src = dp[0];
auto &dst = dp[1];
int mask = (1 << (m - 1)) - 1;
src[0][0] = 1;
for (int i = 0; i < n * m; i++){
memset(dst, 0, sizeof(dst));
for (int j = 0; j < tm; j++){
for (int k = 0; k < 2; k++){
if (!src[i][j][k]) continue;
int x = i / m, y = i % m;
if (g[x][y] == 0 || g[x][y] == 3){
int nj = b2k[(k2b[j] << 1) & mask];
int nk = y < m - 1;
dst[nj][nk] = (dst[nj][nk] + src[j][k]) % MOD;
}
if (g[x][y] == 1 || g[x][y] == 3){
int nj = b2k[((k2b[j] << 1) & mask) | k];
int nk = 0;
dst[nj][nk] = (dst[nj][nk] + src[j][k]) % MOD;
}
if (g[x][y] == 2 || g[x][y] == 3){
if (((~k2b[j]) >> (m - 2)) & 1){
int nj = b2k[(k2b[j] << 1) & mask];
int nk = 0;
dst[nj][nk] = (dst[nj][nk] + src[j][k]) % MOD;
}
}
}
}
swap(src, dst);
}
int res = 0;
for (int i = 0; i < tm; i++){
for (int j = 0; j < 2; j++){
res = (res + src[i][j]) % MOD;
}
}
cout << (u - res + MOD) % MOD << endl;
} | a.cc: In function 'int main()':
a.cc:51:47: error: invalid types 'int[int]' for array subscript
51 | if (!src[i][j][k]) continue;
| ^
|
s998778380 | p00482 | C++ | #include <string>
#include <vector>
#include <iostream>
#pragma warning(disable : 4996)
#define mod 100000
using namespace std;
int H, W, dp[400][1 << 19][3][2]; string M[20];
int main()
{
scanf("%d", &H);
scanf("%d", &W);
for (int i = 0; i < H; i++) cin >> M[i];
if (M[0][0] == 'J' || M[0][0] == '?') dp[0][0][0][0] = 1;
if (M[0][0] == 'O' || M[0][0] == '?') dp[0][0][1][0] = 1;
if (M[0][0] == 'I' || M[0][0] == '?') dp[0][0][2][0] = 1;
for (int i = 0; i < H * W - 1; i++)
{
for (int j = 0; j < (1 << (W - 1)); j++)
{
char c = M[(i + 1) / W][(i + 1) % W];
int nxt = (j << 1) % (1 << (W - 1));
int sum0 = (dp[i][j][0][0] + dp[i][j][1][0] + dp[i][j][2][0]) % mod;
int sum1 = (dp[i][j][0][1] + dp[i][j][1][1] + dp[i][j][2][1]) % mod;
if (c == 'J' || c == '?')
{
dp[i + 1][nxt][0][0] += sum0;
dp[i + 1][nxt][0][1] += sum1;
dp[i + 1][nxt][0][0] %= mod;
dp[i + 1][nxt][0][1] %= mod;
}
if (c == 'O' || c == '?')
{
if ((M[i / W][i % W] == 'J' || M[i / W][i % W] == '?') && i % W != W - 1)
{
dp[i + 1][nxt + 1][1][0] += dp[i][j][0][0];
dp[i + 1][nxt + 1][1][1] += dp[i][j][0][1];
dp[i + 1][nxt + 1][1][0] %= mod;
dp[i + 1][nxt + 1][1][1] %= mod;
dp[i + 1][nxt][1][0] += (sum0 - dp[i][j][0][0] + mod);
dp[i + 1][nxt][1][1] += (sum1 - dp[i][j][0][1] + mod);
dp[i + 1][nxt][1][0] %= mod;
dp[i + 1][nxt][1][1] %= mod;
}
else
{
dp[i + 1][nxt][1][0] += sum0;
dp[i + 1][nxt][1][1] += sum1;
dp[i + 1][nxt][1][0] %= mod;
dp[i + 1][nxt][1][1] %= mod;
}
}
if (c == 'I' || c == '?')
{
if (j & (1 << (W - 2)))
{
dp[i + 1][nxt][2][1] += sum0;
}
else
{
dp[i + 1][nxt][2][0] += sum0;
}
dp[i + 1][nxt][2][1] += sum1;
dp[i + 1][nxt][2][0] %= mod;
dp[i + 1][nxt][2][1] %= mod;
}
}
}
int ret = 0;
for (int i = 0; i < (1 << (W - 1)); i++)
{
for (int j = 0; j < 3; j++)
{
ret += dp[H * W - 1][i][j][1];
ret %= mod;
}
}
printf("%d\n", ret);
return 0;
} | /tmp/ccdM8GIA.o: in function `main':
a.cc:(.text+0x5c): relocation truncated to fit: R_X86_64_PC32 against symbol `M[abi:cxx11]' defined in .bss section in /tmp/ccdM8GIA.o
a.cc:(.text+0x8c): relocation truncated to fit: R_X86_64_PC32 against symbol `M[abi:cxx11]' defined in .bss section in /tmp/ccdM8GIA.o
a.cc:(.text+0xa7): relocation truncated to fit: R_X86_64_PC32 against symbol `M[abi:cxx11]' defined in .bss section in /tmp/ccdM8GIA.o
a.cc:(.text+0xdc): relocation truncated to fit: R_X86_64_PC32 against symbol `M[abi:cxx11]' defined in .bss section in /tmp/ccdM8GIA.o
a.cc:(.text+0xf7): relocation truncated to fit: R_X86_64_PC32 against symbol `M[abi:cxx11]' defined in .bss section in /tmp/ccdM8GIA.o
a.cc:(.text+0x12c): relocation truncated to fit: R_X86_64_PC32 against symbol `M[abi:cxx11]' defined in .bss section in /tmp/ccdM8GIA.o
a.cc:(.text+0x147): relocation truncated to fit: R_X86_64_PC32 against symbol `M[abi:cxx11]' defined in .bss section in /tmp/ccdM8GIA.o
a.cc:(.text+0x1a7): relocation truncated to fit: R_X86_64_PC32 against symbol `M[abi:cxx11]' defined in .bss section in /tmp/ccdM8GIA.o
a.cc:(.text+0x624): relocation truncated to fit: R_X86_64_PC32 against symbol `M[abi:cxx11]' defined in .bss section in /tmp/ccdM8GIA.o
a.cc:(.text+0x668): relocation truncated to fit: R_X86_64_PC32 against symbol `M[abi:cxx11]' defined in .bss section in /tmp/ccdM8GIA.o
/tmp/ccdM8GIA.o: in function `__tcf_0':
a.cc:(.text+0x12a9): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
|
s830632128 | p00482 | C++ | #include <string>
#include <vector>
#include <iostream>
#pragma warning(disable : 4996)
#define mod 100000
using namespace std;
int H, W, dp[400][1 << 19][2][2]; string M[20];
int main()
{
scanf("%d", &H);
scanf("%d", &W);
for (int i = 0; i < H; i++) cin >> M[i];
if (M[0][0] == 'J' || M[0][0] == '?') dp[0][0][0][0] = 1;
if (M[0][0] == 'O' || M[0][0] == '?') dp[0][0][1][0] = 1;
if (M[0][0] == 'I' || M[0][0] == '?') dp[0][0][1][0] = 1;
for (int i = 0; i < H * W - 1; i++)
{
for (int j = 0; j < (1 << (W - 1)); j++)
{
char c = M[(i + 1) / W][(i + 1) % W];
int nxt = (j << 1) % (1 << (W - 1));
int sum0 = (dp[i][j][0][0] + dp[i][j][1][0]) % mod;
int sum1 = (dp[i][j][0][1] + dp[i][j][1][1]) % mod;
if (c == 'J' || c == '?')
{
dp[i + 1][nxt][0][0] += sum0;
dp[i + 1][nxt][0][1] += sum1;
dp[i + 1][nxt][0][0] %= mod;
dp[i + 1][nxt][0][1] %= mod;
}
if (c == 'O' || c == '?')
{
if ((M[i / W][i % W] == 'J' || M[i / W][i % W] == '?') && i % W != W - 1)
{
dp[i + 1][nxt + 1][1][0] += dp[i][j][0][0];
dp[i + 1][nxt + 1][1][1] += dp[i][j][0][1];
dp[i + 1][nxt + 1][1][0] %= mod;
dp[i + 1][nxt + 1][1][1] %= mod;
dp[i + 1][nxt][1][0] += (sum0 - dp[i][j][0][0] + mod);
dp[i + 1][nxt][1][1] += (sum1 - dp[i][j][0][1] + mod);
dp[i + 1][nxt][1][0] %= mod;
dp[i + 1][nxt][1][1] %= mod;
}
else
{
dp[i + 1][nxt][1][0] += sum0;
dp[i + 1][nxt][1][1] += sum1;
dp[i + 1][nxt][1][0] %= mod;
dp[i + 1][nxt][1][1] %= mod;
}
}
if (c == 'I' || c == '?')
{
if (j & (1 << (W - 2)))
{
dp[i + 1][nxt][1][1] += sum0;
}
else
{
dp[i + 1][nxt][1][0] += sum0;
}
dp[i + 1][nxt][1][1] += sum1;
dp[i + 1][nxt][1][0] %= mod;
dp[i + 1][nxt][1][1] %= mod;
}
}
}
int ret = 0;
for (int i = 0; i < (1 << (W - 1)); i++)
{
for (int j = 0; j < 2; j++)
{
ret += dp[H * W - 1][i][j][1];
ret %= mod;
}
}
printf("%d\n", ret);
return 0;
} | /tmp/ccAj2M66.o: in function `main':
a.cc:(.text+0x5c): relocation truncated to fit: R_X86_64_PC32 against symbol `M[abi:cxx11]' defined in .bss section in /tmp/ccAj2M66.o
a.cc:(.text+0x8c): relocation truncated to fit: R_X86_64_PC32 against symbol `M[abi:cxx11]' defined in .bss section in /tmp/ccAj2M66.o
a.cc:(.text+0xa7): relocation truncated to fit: R_X86_64_PC32 against symbol `M[abi:cxx11]' defined in .bss section in /tmp/ccAj2M66.o
a.cc:(.text+0xdc): relocation truncated to fit: R_X86_64_PC32 against symbol `M[abi:cxx11]' defined in .bss section in /tmp/ccAj2M66.o
a.cc:(.text+0xf7): relocation truncated to fit: R_X86_64_PC32 against symbol `M[abi:cxx11]' defined in .bss section in /tmp/ccAj2M66.o
a.cc:(.text+0x12c): relocation truncated to fit: R_X86_64_PC32 against symbol `M[abi:cxx11]' defined in .bss section in /tmp/ccAj2M66.o
a.cc:(.text+0x147): relocation truncated to fit: R_X86_64_PC32 against symbol `M[abi:cxx11]' defined in .bss section in /tmp/ccAj2M66.o
a.cc:(.text+0x1a7): relocation truncated to fit: R_X86_64_PC32 against symbol `M[abi:cxx11]' defined in .bss section in /tmp/ccAj2M66.o
a.cc:(.text+0x490): relocation truncated to fit: R_X86_64_PC32 against symbol `M[abi:cxx11]' defined in .bss section in /tmp/ccAj2M66.o
a.cc:(.text+0x4d4): relocation truncated to fit: R_X86_64_PC32 against symbol `M[abi:cxx11]' defined in .bss section in /tmp/ccAj2M66.o
/tmp/ccAj2M66.o: in function `__tcf_0':
a.cc:(.text+0xd83): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
|
s528863576 | p00482 | C++ | #include <stdio.h>
int H, W, dp[2][10946][2][2], bits[10946], nxts[10946], conv[1 << 19], maxbits;
char M[20][21];
int main()
{
scanf("%d", &H);
scanf("%d", &W);
for (int i = 0; i < H; i++) scanf("%s", M[i]);
if (M[0][0] == 'J' || M[0][0] == '?') dp[0][0][0][0] += 1;
if (M[0][0] == 'O' || M[0][0] == '?') dp[0][0][1][0] += 1;
if (M[0][0] == 'I' || M[0][0] == '?') dp[0][0][1][0] += 1;
int maxbit = 1 << (W - 1);
for (int i = 0; i < maxbit; i++)
{
bool ok = true;
for (int j = 0; j < W - 2; j++)
{
if ((i & (1 << j)) && (i & (1 << (j + 1))))
{
ok = false; break;
}
}
if (ok)
{
conv[i] = maxbits; bits[maxbits++] = i;
}
}
for (int i = 0; i < maxbits; i++)
{
nxts[i] = (bits[i] << 1) & maxbit - 1);
}
for (int i = 0; i < H * W - 1; i++)
{
int s = i % 2;
int t = (i + 1) % 2;
for (int j = 0; j < maxbits; j++)
{
dp[t][j][0][0] = 0;
dp[t][j][0][1] = 0;
dp[t][j][1][0] = 0;
dp[t][j][1][1] = 0;
}
char nowc = M[i / W][i % W];
char nxtc = M[(i + 1) / W][(i + 1) % W];
for (int j = 0; j < maxbits; j++)
{
int sum0 = dp[s][j][0][0] + dp[s][j][1][0];
int sum1 = dp[s][j][0][1] + dp[s][j][1][1];
if (nxtc == 'J' || nxtc == '?')
{
dp[t][conv[nxts[j]]][0][0] += sum0;
dp[t][conv[nxts[j]]][0][1] += sum1;
}
if (nxtc == 'O' || nxtc == '?')
{
if ((nowc == 'J' || nowc == '?') && i % W != W - 1)
{
dp[t][conv[nxts[j] + 1]][1][0] += dp[s][j][0][0];
dp[t][conv[nxts[j] + 1]][1][1] += dp[s][j][0][1];
dp[t][conv[nxts[j] + 1]][1][0] %= 100000;
dp[t][conv[nxts[j] + 1]][1][1] %= 100000;
dp[t][conv[nxts[j]]][1][0] += dp[s][j][1][0];
dp[t][conv[nxts[j]]][1][1] += dp[s][j][1][1];
}
else
{
dp[t][conv[nxts[j]]][1][0] += sum0;
dp[t][conv[nxts[j]]][1][1] += sum1;
}
}
if (nxtc == 'I' || nxtc == '?')
{
if (bits[j] & (1 << (W - 2)))
{
dp[t][conv[nxts[j]]][1][1] += sum0;
}
else
{
dp[t][conv[nxts[j]]][1][0] += sum0;
}
dp[t][conv[nxts[j]]][1][1] += sum1;
}
dp[t][conv[nxts[j]]][0][0] %= 100000;
dp[t][conv[nxts[j]]][0][1] %= 100000;
dp[t][conv[nxts[j]]][1][0] %= 100000;
dp[t][conv[nxts[j]]][1][1] %= 100000;
}
}
int ret = 0;
int last = (H * W + 1) % 2;
for (int i = 0; i < maxbits; i++)
{
ret += dp[last][i][0][1];
ret += dp[last][i][1][1];
ret %= 100000;
}
printf("%d\n", ret);
return 0;
} | a.cc: In function 'int main()':
a.cc:40:54: error: expected ';' before ')' token
40 | nxts[i] = (bits[i] << 1) & maxbit - 1);
| ^
| ;
|
s022753530 | p00482 | C++ |
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
//?????°???????????????????????\??????mod??¢??°
inline long long imod(long long a, long long b)
{
return (a >= 0) ? (a % b) : (a % b + b);
}
//mint????????°?????°?????????2??????
template <long long MOD> class mint;
template <long long MOD> mint<MOD> m_pow(mint<MOD> x, long long n);
//mod?????´??°?????????
template <long long MOD = 1000000007>
class mint
{
public:
template<long long MOD>mint<MOD> operator+(const mint<MOD> &other)const
{
return mint<MOD>(imod(a + other.a, MOD));
}
template<long long MOD>mint<MOD> operator-(const mint<MOD> &other)const
{
return mint<MOD>(imod(a - other.a, MOD));
}
template<long long MOD>mint<MOD> operator*(const mint<MOD> &other)const
{
return mint<MOD>(imod(a * other.a, MOD));
}
template<long long MOD>mint<MOD> operator+=(const mint<MOD> &other)
{
a = imod(a + other.a, MOD);
return mint<MOD>(a);
}
template<long long MOD>mint<MOD> operator-=(const mint<MOD> &other)
{
a = imod(a - other.a, MOD);
return mint<MOD>(a);
}
template<long long MOD>mint<MOD> operator*=(const mint<MOD> &other)
{
a = imod(a * other.a, MOD);
return mint<MOD>(a);
}
template<long long MOD>mint<MOD> operator+()const
{
return *this;
}
template<long long MOD>mint<MOD> operator-()const
{
return mint<MOD>(-a);
}
template<long long MOD>mint<MOD>& operator++()
{
*this += 1;
return *this;
}
template<long long MOD>mint<MOD> operator++(int)
{
auto tmp = *this;
*this += 1;
return tmp;
}
template<long long MOD>mint<MOD>& operator--()
{
*this -= 1;
return *this;
}
template<long long MOD>mint<MOD> operator--(int)
{
auto tmp = *this;
*this -= 1;
return tmp;
}
template<long long MOD>mint<MOD> operator~()const
{
return pow(a, e_phi - 1);
}
template<long long MOD>mint<MOD>& operator=(const mint<MOD> &other)
{
a = other.a;
return *this;
}
operator long long()const
{
return a;
}
explicit operator int()const
{
return (int)a;
}
static long long getmod()
{
return mod;
}
mint(long long a_) :a(imod(a_, MOD))
{
//????????????
static_assert(MOD >= 2, "MOD cannot be below 2.");
if (e_phi > 0)return;
//??????????????¢??°??(mod)????¨??????????
e_phi = MOD;
long long m_ = MOD;
for (int i = 2; i * i <= m_; ++i)
{
if (m_ % i == 0)
{
e_phi = e_phi / i * (i - 1);
for (; m_ % i == 0; m_ /= i);
}
}
if (m_ != 1)e_phi = e_phi / m_ * (m_ - 1);
}
mint() :a(0) {}
private:
static long long e_phi;
long long a;
};
//mint????´????
//x^n????¨?????????????
template<long long MOD>mint<MOD> m_pow(mint<MOD> x, long long n)
{
mint<MOD> res = 1;
while (n > 0)
{
if (n & 1)res *= x;
x *= x;
n >>= 1;
}
return res;
}
//mint??????????¨????
//O(x)?¨???????????????????????????????
//?????¨?\¨??????????????§fact_set????¨??????????
template<long long MOD>mint<MOD> fact(mint<MOD> x)
{
mint res(1);
for (long long i = 1; i <= (long long)x; ++i)
{
res *= i;
}
return res;
}
//mint??????????¨????????????????
//set???????°????0???x?????§???????????°?????????????????????
//O(x)?¨???????????????????????????????
template<long long MOD>void fact_set(std::vector<mint<MOD>> &set, mint<MOD> x = mint<MOD>(-1))
{
mint res(1);
set.push_back(1);
for (long long i = 1; i <= (long long)x; ++i)
{
res *= i;
set.push_back(res);
}
}
template<long long MOD>long long mint<MOD>::e_phi = -1;
//mint??????stream????????\????????????
template<long long MOD> std::ostream& operator<<(std::ostream& os, mint<MOD> i)
{
os << (long long)i;
return os;
}
template<long long MOD> std::istream& operator >> (std::istream& is, mint<MOD>& i)
{
long long tmp;
is >> tmp;
i = tmp;
return is;
}
typedef mint<100000> Int;
Int ans = 1;
int n, m;
char basestr[401];
int plane[400];
Int oldm[1 << 19][2];
Int memo[1 << 19][2];
Int pack_base;
Int wrap(int bs, int f)
{
return oldm[bs][f] + oldm[bs + pack_base][f];
}
int main(void)
{
cin >> m >> n;
for (int k = 0; k < m; ++k)
{
scanf("%s", basestr + (k * n));
}
pack_base = m_pow(Int(2), n - 2);
for (int i = 0; i < n * m; ++i)
{
switch (basestr[i])
{
case '?':plane[i] = 7; ans *= Int(3); break;
case 'J':plane[i] = 1; break;
case 'O':plane[i] = 2; break;
case 'I':plane[i] = 4; break;
}
}
Int maxst = m_pow(Int(2), n - 1);
for (int bs = 0; bs < maxst; ++bs)
{
oldm[bs][0] = oldm[bs][1] = 0;
}
oldm[0][0] = 2;
oldm[0][1] = 1;
for (int i = 1; i < n * m; ++i)
{
for (int bs = 0; bs < maxst; ++bs)
{
memo[bs][0] = memo[bs][1] = 0;
if (plane[i] & 1)
{
if (bs % 2 == 0)memo[bs][1] += (wrap(bs / 2, 0) + wrap(bs / 2, 1));
}
if (plane[i] & 2)
{
if (bs % 2 == 1)memo[bs][0] += wrap(bs / 2, 1);
if (bs % 2 == 0)memo[bs][0] += wrap(bs / 2, 0);
}
if (plane[i] & 4)
{
if (bs % 2 == 0)
{
memo[bs][0] += (oldm[bs / 2][0] + oldm[bs / 2][1]);
if ((i + 1) % n == 0)
{
memo[bs][0] += (oldm[bs / 2 + pack_base][0] + oldm[bs / 2 + pack_base][1]);
}
}
}
}
for (int bs = 0; bs < maxst; ++bs)
{
oldm[bs][0] = memo[bs][0];
oldm[bs][1] = memo[bs][1];
}
}
Int bad;
for (int bs = 0; bs < maxst; ++bs)
{
bad += (oldm[bs][0] + oldm[bs][1]);
}
ans -= bad;
cout << ans << endl;
return 0;
} | a.cc:37:18: error: declaration of template parameter 'MOD' shadows template parameter
37 | template<long long MOD>mint<MOD> operator+(const mint<MOD> &other)const
| ^~~~
a.cc:33:11: note: template parameter 'MOD' declared here
33 | template <long long MOD = 1000000007>
| ^~~~
a.cc:41:18: error: declaration of template parameter 'MOD' shadows template parameter
41 | template<long long MOD>mint<MOD> operator-(const mint<MOD> &other)const
| ^~~~
a.cc:33:11: note: template parameter 'MOD' declared here
33 | template <long long MOD = 1000000007>
| ^~~~
a.cc:45:18: error: declaration of template parameter 'MOD' shadows template parameter
45 | template<long long MOD>mint<MOD> operator*(const mint<MOD> &other)const
| ^~~~
a.cc:33:11: note: template parameter 'MOD' declared here
33 | template <long long MOD = 1000000007>
| ^~~~
a.cc:49:18: error: declaration of template parameter 'MOD' shadows template parameter
49 | template<long long MOD>mint<MOD> operator+=(const mint<MOD> &other)
| ^~~~
a.cc:33:11: note: template parameter 'MOD' declared here
33 | template <long long MOD = 1000000007>
| ^~~~
a.cc:54:18: error: declaration of template parameter 'MOD' shadows template parameter
54 | template<long long MOD>mint<MOD> operator-=(const mint<MOD> &other)
| ^~~~
a.cc:33:11: note: template parameter 'MOD' declared here
33 | template <long long MOD = 1000000007>
| ^~~~
a.cc:59:18: error: declaration of template parameter 'MOD' shadows template parameter
59 | template<long long MOD>mint<MOD> operator*=(const mint<MOD> &other)
| ^~~~
a.cc:33:11: note: template parameter 'MOD' declared here
33 | template <long long MOD = 1000000007>
| ^~~~
a.cc:64:18: error: declaration of template parameter 'MOD' shadows template parameter
64 | template<long long MOD>mint<MOD> operator+()const
| ^~~~
a.cc:33:11: note: template parameter 'MOD' declared here
33 | template <long long MOD = 1000000007>
| ^~~~
a.cc:68:18: error: declaration of template parameter 'MOD' shadows template parameter
68 | template<long long MOD>mint<MOD> operator-()const
| ^~~~
a.cc:33:11: note: template parameter 'MOD' declared here
33 | template <long long MOD = 1000000007>
| ^~~~
a.cc:72:18: error: declaration of template parameter 'MOD' shadows template parameter
72 | template<long long MOD>mint<MOD>& operator++()
| ^~~~
a.cc:33:11: note: template parameter 'MOD' declared here
33 | template <long long MOD = 1000000007>
| ^~~~
a.cc:77:18: error: declaration of template parameter 'MOD' shadows template parameter
77 | template<long long MOD>mint<MOD> operator++(int)
| ^~~~
a.cc:33:11: note: template parameter 'MOD' declared here
33 | template <long long MOD = 1000000007>
| ^~~~
a.cc:83:18: error: declaration of template parameter 'MOD' shadows template parameter
83 | template<long long MOD>mint<MOD>& operator--()
| ^~~~
a.cc:33:11: note: template parameter 'MOD' declared here
33 | template <long long MOD = 1000000007>
| ^~~~
a.cc:88:18: error: declaration of template parameter 'MOD' shadows template parameter
88 | template<long long MOD>mint<MOD> operator--(int)
| ^~~~
a.cc:33:11: note: template parameter 'MOD' declared here
33 | template <long long MOD = 1000000007>
| ^~~~
a.cc:94:18: error: declaration of template parameter 'MOD' shadows template parameter
94 | template<long long MOD>mint<MOD> operator~()const
| ^~~~
a.cc:33:11: note: template parameter 'MOD' declared here
33 | template <long long MOD = 1000000007>
| ^~~~
a.cc:98:18: error: declaration of template parameter 'MOD' shadows template parameter
98 | template<long long MOD>mint<MOD>& operator=(const mint<MOD> &other)
| ^~~~
a.cc:33:11: note: template parameter 'MOD' declared here
33 | template <long long MOD = 1000000007>
| ^~~~
a.cc: In static member function 'static long long int mint<MOD>::getmod()':
a.cc:113:24: error: 'mod' was not declared in this scope; did you mean 'modf'?
113 | return mod;
| ^~~
| modf
|
s539770591 | p00482 | C++ |
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
//?????°???????????????????????\??????mod??¢??°
inline long long imod(long long a, long long b)
{
return (a >= 0) ? (a % b) : (a % b + b);
}
//mint????????°?????°?????????2??????
template <long long MOD> class mint;
template <long long MOD> mint<MOD> m_pow(mint<MOD> x, long long n);
//mod?????´??°?????????
template <long long MOD = 1000000007>
class mint
{
public:
template<long long MOD>mint<MOD> operator+(const mint<MOD> &other)const
{
return mint<MOD>(imod(a + other.a, MOD));
}
template<long long MOD>mint<MOD> operator-(const mint<MOD> &other)const
{
return mint<MOD>(imod(a - other.a, MOD));
}
template<long long MOD>mint<MOD> operator*(const mint<MOD> &other)const
{
return mint<MOD>(imod(a * other.a, MOD));
}
template<long long MOD>mint<MOD> operator+=(const mint<MOD> &other)
{
a = imod(a + other.a, MOD);
return mint<MOD>(a);
}
template<long long MOD>mint<MOD> operator-=(const mint<MOD> &other)
{
a = imod(a - other.a, MOD);
return mint<MOD>(a);
}
template<long long MOD>mint<MOD> operator*=(const mint<MOD> &other)
{
a = imod(a * other.a, MOD);
return mint<MOD>(a);
}
template<long long MOD>mint<MOD> operator+()const
{
return *this;
}
template<long long MOD>mint<MOD> operator-()const
{
return mint<MOD>(-a);
}
template<long long MOD>mint<MOD>& operator++()
{
*this += 1;
return *this;
}
template<long long MOD>mint<MOD> operator++(int)
{
auto tmp = *this;
*this += 1;
return tmp;
}
template<long long MOD>mint<MOD>& operator--()
{
*this -= 1;
return *this;
}
template<long long MOD>mint<MOD> operator--(int)
{
auto tmp = *this;
*this -= 1;
return tmp;
}
template<long long MOD>mint<MOD> operator~()const
{
return pow(a, e_phi - 1);
}
template<long long MOD>mint<MOD>& operator=(const mint<MOD> &other)
{
a = other.a;
return *this;
}
operator long long()const
{
return a;
}
explicit operator int()const
{
return (int)a;
}
static long long getmod()
{
return mod;
}
mint(long long a_) :a(imod(a_, MOD))
{
//????????????
static_assert(MOD >= 2, "MOD cannot be below 2.");
if (e_phi > 0)return;
//??????????????¢??°??(mod)????¨??????????
e_phi = MOD;
long long m_ = MOD;
for (int i = 2; i * i <= m_; ++i)
{
if (m_ % i == 0)
{
e_phi = e_phi / i * (i - 1);
for (; m_ % i == 0; m_ /= i);
}
}
if (m_ != 1)e_phi = e_phi / m_ * (m_ - 1);
}
mint() :a(0) {}
private:
static long long e_phi;
long long a;
};
//mint????´????
//x^n????¨?????????????
template<long long MOD>mint<MOD> m_pow(mint<MOD> x, long long n)
{
mint<MOD> res = 1;
while (n > 0)
{
if (n & 1)res *= x;
x *= x;
n >>= 1;
}
return res;
}
//mint??????????¨????
//O(x)?¨???????????????????????????????
//?????¨?\¨??????????????§fact_set????¨??????????
template<long long MOD>mint<MOD> fact(mint<MOD> x)
{
mint res(1);
for (long long i = 1; i <= (long long)x; ++i)
{
res *= i;
}
return res;
}
//mint??????????¨????????????????
//set???????°????0???x?????§???????????°?????????????????????
//O(x)?¨???????????????????????????????
template<long long MOD>void fact_set(std::vector<mint<MOD>> &set, mint<MOD> x = mint<MOD>(-1))
{
mint res(1);
set.push_back(1);
for (long long i = 1; i <= (long long)x; ++i)
{
res *= i;
set.push_back(res);
}
}
template<long long MOD>long long mint<MOD>::e_phi = -1;
//mint??????stream????????\????????????
template<long long MOD> std::ostream& operator<<(std::ostream& os, mint<MOD> i)
{
os << (long long)i;
return os;
}
template<long long MOD> std::istream& operator >> (std::istream& is, mint<MOD>& i)
{
long long tmp;
is >> tmp;
i = tmp;
return is;
}
typedef mint<100000> Int;
Int ans = 1;
int n, m;
char basestr[401];
int plane[400];
Int oldm[1 << 19][2];
Int memo[1 << 19][2];
Int pack_base;
Int wrap(int bs, int f)
{
return oldm[bs][f] + oldm[bs + pack_base][f];
}
int main(void)
{
cin >> m >> n;
for (int k = 0; k < m; ++k)
{
scanf("%s", basestr + (k * n));
}
pack_base = m_pow(Int(2), n - 2);
for (int i = 0; i < n * m; ++i)
{
switch (basestr[i])
{
case '?':plane[i] = 7; ans *= Int(3); break;
case 'J':plane[i] = 1; break;
case 'O':plane[i] = 2; break;
case 'I':plane[i] = 4; break;
}
}
Int maxst = m_pow(Int(2), n - 1);
for (int bs = 0; bs < maxst; ++bs)
{
oldm[bs][0] = oldm[bs][1] = 0;
}
oldm[0][0] = 2;
oldm[0][1] = 1;
for (int i = 1; i < n * m; ++i)
{
for (int bs = 0; bs < maxst; ++bs)
{
memo[bs][0] = memo[bs][1] = 0;
if (plane[i] & 1)
{
if (bs % 2 == 0)memo[bs][1] += (wrap(bs / 2, 0) + wrap(bs / 2, 1));
}
if (plane[i] & 2)
{
if (bs % 2 == 1)memo[bs][0] += wrap(bs / 2, 1);
if (bs % 2 == 0)memo[bs][0] += wrap(bs / 2, 0);
}
if (plane[i] & 4)
{
if (bs % 2 == 0)
{
memo[bs][0] += (oldm[bs / 2][0] + oldm[bs / 2][1]);
if ((i + 1) % n == 0)
{
memo[bs][0] += (oldm[bs / 2 + pack_base][0] + oldm[bs / 2 + pack_base][1]);
}
}
}
}
for (int bs = 0; bs < maxst; ++bs)
{
oldm[bs][0] = memo[bs][0];
oldm[bs][1] = memo[bs][1];
}
}
Int bad;
for (int bs = 0; bs < maxst; ++bs)
{
bad += (oldm[bs][0] + oldm[bs][1]);
}
ans -= bad;
cout << ans << endl;
return 0;
} | a.cc:37:18: error: declaration of template parameter 'MOD' shadows template parameter
37 | template<long long MOD>mint<MOD> operator+(const mint<MOD> &other)const
| ^~~~
a.cc:33:11: note: template parameter 'MOD' declared here
33 | template <long long MOD = 1000000007>
| ^~~~
a.cc:41:18: error: declaration of template parameter 'MOD' shadows template parameter
41 | template<long long MOD>mint<MOD> operator-(const mint<MOD> &other)const
| ^~~~
a.cc:33:11: note: template parameter 'MOD' declared here
33 | template <long long MOD = 1000000007>
| ^~~~
a.cc:45:18: error: declaration of template parameter 'MOD' shadows template parameter
45 | template<long long MOD>mint<MOD> operator*(const mint<MOD> &other)const
| ^~~~
a.cc:33:11: note: template parameter 'MOD' declared here
33 | template <long long MOD = 1000000007>
| ^~~~
a.cc:49:18: error: declaration of template parameter 'MOD' shadows template parameter
49 | template<long long MOD>mint<MOD> operator+=(const mint<MOD> &other)
| ^~~~
a.cc:33:11: note: template parameter 'MOD' declared here
33 | template <long long MOD = 1000000007>
| ^~~~
a.cc:54:18: error: declaration of template parameter 'MOD' shadows template parameter
54 | template<long long MOD>mint<MOD> operator-=(const mint<MOD> &other)
| ^~~~
a.cc:33:11: note: template parameter 'MOD' declared here
33 | template <long long MOD = 1000000007>
| ^~~~
a.cc:59:18: error: declaration of template parameter 'MOD' shadows template parameter
59 | template<long long MOD>mint<MOD> operator*=(const mint<MOD> &other)
| ^~~~
a.cc:33:11: note: template parameter 'MOD' declared here
33 | template <long long MOD = 1000000007>
| ^~~~
a.cc:64:18: error: declaration of template parameter 'MOD' shadows template parameter
64 | template<long long MOD>mint<MOD> operator+()const
| ^~~~
a.cc:33:11: note: template parameter 'MOD' declared here
33 | template <long long MOD = 1000000007>
| ^~~~
a.cc:68:18: error: declaration of template parameter 'MOD' shadows template parameter
68 | template<long long MOD>mint<MOD> operator-()const
| ^~~~
a.cc:33:11: note: template parameter 'MOD' declared here
33 | template <long long MOD = 1000000007>
| ^~~~
a.cc:72:18: error: declaration of template parameter 'MOD' shadows template parameter
72 | template<long long MOD>mint<MOD>& operator++()
| ^~~~
a.cc:33:11: note: template parameter 'MOD' declared here
33 | template <long long MOD = 1000000007>
| ^~~~
a.cc:77:18: error: declaration of template parameter 'MOD' shadows template parameter
77 | template<long long MOD>mint<MOD> operator++(int)
| ^~~~
a.cc:33:11: note: template parameter 'MOD' declared here
33 | template <long long MOD = 1000000007>
| ^~~~
a.cc:83:18: error: declaration of template parameter 'MOD' shadows template parameter
83 | template<long long MOD>mint<MOD>& operator--()
| ^~~~
a.cc:33:11: note: template parameter 'MOD' declared here
33 | template <long long MOD = 1000000007>
| ^~~~
a.cc:88:18: error: declaration of template parameter 'MOD' shadows template parameter
88 | template<long long MOD>mint<MOD> operator--(int)
| ^~~~
a.cc:33:11: note: template parameter 'MOD' declared here
33 | template <long long MOD = 1000000007>
| ^~~~
a.cc:94:18: error: declaration of template parameter 'MOD' shadows template parameter
94 | template<long long MOD>mint<MOD> operator~()const
| ^~~~
a.cc:33:11: note: template parameter 'MOD' declared here
33 | template <long long MOD = 1000000007>
| ^~~~
a.cc:98:18: error: declaration of template parameter 'MOD' shadows template parameter
98 | template<long long MOD>mint<MOD>& operator=(const mint<MOD> &other)
| ^~~~
a.cc:33:11: note: template parameter 'MOD' declared here
33 | template <long long MOD = 1000000007>
| ^~~~
a.cc: In static member function 'static long long int mint<MOD>::getmod()':
a.cc:113:24: error: 'mod' was not declared in this scope; did you mean 'modf'?
113 | return mod;
| ^~~
| modf
|
s448265593 | p00482 | C++ |
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
//?????°???????????????????????\??????mod??¢??°
inline long long imod(long long a, long long b)
{
return (a >= 0) ? (a % b) : (a % b + b);
}
//mint????????°?????°?????????2??????
template <long long MOD> class mint;
template <long long MOD> mint<MOD> m_pow(mint<MOD> x, long long n);
//mod?????´??°?????????
template <long long MOD = 1000000007>
class mint
{
public:
template<long long MOD>mint<MOD> operator+(const mint<MOD> &other)const
{
return mint<MOD>(imod(a + other.a, MOD));
}
template<long long MOD>mint<MOD> operator-(const mint<MOD> &other)const
{
return mint<MOD>(imod(a - other.a, MOD));
}
template<long long MOD>mint<MOD> operator*(const mint<MOD> &other)const
{
return mint<MOD>(imod(a * other.a, MOD));
}
template<long long MOD>mint<MOD> operator+=(const mint<MOD> &other)
{
a = imod(a + other.a, MOD);
return mint<MOD>(a);
}
template<long long MOD>mint<MOD> operator-=(const mint<MOD> &other)
{
a = imod(a - other.a, MOD);
return mint<MOD>(a);
}
template<long long MOD>mint<MOD> operator*=(const mint<MOD> &other)
{
a = imod(a * other.a, MOD);
return mint<MOD>(a);
}
template<long long MOD>mint<MOD> operator+()const
{
return *this;
}
template<long long MOD>mint<MOD> operator-()const
{
return mint<MOD>(-a);
}
template<long long MOD>mint<MOD>& operator++()
{
*this += 1;
return *this;
}
template<long long MOD>mint<MOD> operator++(int)
{
auto tmp = *this;
*this += 1;
return tmp;
}
template<long long MOD>mint<MOD>& operator--()
{
*this -= 1;
return *this;
}
template<long long MOD>mint<MOD> operator--(int)
{
auto tmp = *this;
*this -= 1;
return tmp;
}
template<long long MOD>mint<MOD> operator~()const
{
return pow(a, e_phi - 1);
}
template<long long MOD>mint<MOD>& operator=(const mint<MOD> &other)
{
a = other.a;
return *this;
}
operator long long()const
{
return a;
}
explicit operator int()const
{
return (int)a;
}
static long long getmod()
{
return mod;
}
mint(long long a_) :a(imod(a_, MOD))
{
//????????????
static_assert(MOD >= 2, "MOD cannot be below 2.");
if (e_phi > 0)return;
//??????????????¢??°??(mod)????¨??????????
e_phi = MOD;
long long m_ = MOD;
for (int i = 2; i * i <= m_; ++i)
{
if (m_ % i == 0)
{
e_phi = e_phi / i * (i - 1);
for (; m_ % i == 0; m_ /= i);
}
}
if (m_ != 1)e_phi = e_phi / m_ * (m_ - 1);
}
mint() :a(0) {}
private:
static long long e_phi;
long long a;
};
//mint????´????
//x^n????¨?????????????
template<long long MOD>mint<MOD> m_pow(mint<MOD> x, long long n)
{
mint<MOD> res = 1;
while (n > 0)
{
if (n & 1)res *= x;
x *= x;
n >>= 1;
}
return res;
}
//mint??????????¨????
//O(x)?¨???????????????????????????????
//?????¨?\¨??????????????§fact_set????¨??????????
template<long long MOD>mint<MOD> fact(mint<MOD> x)
{
mint res(1);
for (long long i = 1; i <= (long long)x; ++i)
{
res *= i;
}
return res;
}
//mint??????????¨????????????????
//set???????°????0???x?????§???????????°?????????????????????
//O(x)?¨???????????????????????????????
template<long long MOD>void fact_set(std::vector<mint<MOD>> &set, mint<MOD> x = mint<MOD>(-1))
{
mint res(1);
set.push_back(1);
for (long long i = 1; i <= (long long)x; ++i)
{
res *= i;
set.push_back(res);
}
}
template<long long MOD>long long mint<MOD>::e_phi = -1;
//mint??????stream????????\????????????
template<long long MOD> std::ostream& operator<<(std::ostream& os, mint<MOD> i)
{
os << (long long)i;
return os;
}
template<long long MOD> std::istream& operator >> (std::istream& is, mint<MOD>& i)
{
long long tmp;
is >> tmp;
i = tmp;
return is;
}
typedef mint<100000> Int;
Int ans = 1;
int n, m;
char basestr[401];
int plane[400];
Int oldm[1 << 19][2];
Int memo[1 << 19][2];
Int pack_base;
Int wrap(int bs, int f)
{
return oldm[bs][f] + oldm[bs + pack_base][f];
}
int main(void)
{
cin >> m >> n;
for (int k = 0; k < m; ++k)
{
scanf("%s", basestr + (k * n));
}
pack_base = m_pow(Int(2), n - 2);
for (int i = 0; i < n * m; ++i)
{
switch (basestr[i])
{
case '?':plane[i] = 7; ans *= Int(3); break;
case 'J':plane[i] = 1; break;
case 'O':plane[i] = 2; break;
case 'I':plane[i] = 4; break;
}
}
Int maxst = m_pow(Int(2), n - 1);
for (int bs = 0; bs < maxst; ++bs)
{
oldm[bs][0] = oldm[bs][1] = 0;
}
oldm[0][0] = 0;
oldm[0][1] = 0;
if (plane[0] & 1)oldm[0][1] += Int(1);
if (plane[0] & 2)oldm[0][0] += Int(1);
if (plane[0] & 4)oldm[0][0] += Int(1);
for (int i = 1; i < n * m; ++i)
{
for (int bs = 0; bs < maxst; ++bs)
{
memo[bs][0] = memo[bs][1] = 0;
if (plane[i] & 1)
{
if (bs % 2 == 0)memo[bs][1] += (wrap(bs / 2, 0) + wrap(bs / 2, 1));
}
if (plane[i] & 2)
{
if (bs % 2 == 1)memo[bs][0] += wrap(bs / 2, 1);
if (bs % 2 == 0)memo[bs][0] += wrap(bs / 2, 0);
}
if (plane[i] & 4)
{
if (bs % 2 == 0)
{
memo[bs][0] += (oldm[bs / 2][0] + oldm[bs / 2][1]);
if ((i + 1) % n == 0)
{
memo[bs][0] += (oldm[bs / 2 + pack_base][0] + oldm[bs / 2 + pack_base][1]);
}
}
}
}
for (int bs = 0; bs < maxst; ++bs)
{
oldm[bs][0] = memo[bs][0];
oldm[bs][1] = memo[bs][1];
}
}
Int bad;
for (int bs = 0; bs < maxst; ++bs)
{
bad += (oldm[bs][0] + oldm[bs][1]);
}
ans -= bad;
cout << ans << endl;
return 0;
} | a.cc:37:18: error: declaration of template parameter 'MOD' shadows template parameter
37 | template<long long MOD>mint<MOD> operator+(const mint<MOD> &other)const
| ^~~~
a.cc:33:11: note: template parameter 'MOD' declared here
33 | template <long long MOD = 1000000007>
| ^~~~
a.cc:41:18: error: declaration of template parameter 'MOD' shadows template parameter
41 | template<long long MOD>mint<MOD> operator-(const mint<MOD> &other)const
| ^~~~
a.cc:33:11: note: template parameter 'MOD' declared here
33 | template <long long MOD = 1000000007>
| ^~~~
a.cc:45:18: error: declaration of template parameter 'MOD' shadows template parameter
45 | template<long long MOD>mint<MOD> operator*(const mint<MOD> &other)const
| ^~~~
a.cc:33:11: note: template parameter 'MOD' declared here
33 | template <long long MOD = 1000000007>
| ^~~~
a.cc:49:18: error: declaration of template parameter 'MOD' shadows template parameter
49 | template<long long MOD>mint<MOD> operator+=(const mint<MOD> &other)
| ^~~~
a.cc:33:11: note: template parameter 'MOD' declared here
33 | template <long long MOD = 1000000007>
| ^~~~
a.cc:54:18: error: declaration of template parameter 'MOD' shadows template parameter
54 | template<long long MOD>mint<MOD> operator-=(const mint<MOD> &other)
| ^~~~
a.cc:33:11: note: template parameter 'MOD' declared here
33 | template <long long MOD = 1000000007>
| ^~~~
a.cc:59:18: error: declaration of template parameter 'MOD' shadows template parameter
59 | template<long long MOD>mint<MOD> operator*=(const mint<MOD> &other)
| ^~~~
a.cc:33:11: note: template parameter 'MOD' declared here
33 | template <long long MOD = 1000000007>
| ^~~~
a.cc:64:18: error: declaration of template parameter 'MOD' shadows template parameter
64 | template<long long MOD>mint<MOD> operator+()const
| ^~~~
a.cc:33:11: note: template parameter 'MOD' declared here
33 | template <long long MOD = 1000000007>
| ^~~~
a.cc:68:18: error: declaration of template parameter 'MOD' shadows template parameter
68 | template<long long MOD>mint<MOD> operator-()const
| ^~~~
a.cc:33:11: note: template parameter 'MOD' declared here
33 | template <long long MOD = 1000000007>
| ^~~~
a.cc:72:18: error: declaration of template parameter 'MOD' shadows template parameter
72 | template<long long MOD>mint<MOD>& operator++()
| ^~~~
a.cc:33:11: note: template parameter 'MOD' declared here
33 | template <long long MOD = 1000000007>
| ^~~~
a.cc:77:18: error: declaration of template parameter 'MOD' shadows template parameter
77 | template<long long MOD>mint<MOD> operator++(int)
| ^~~~
a.cc:33:11: note: template parameter 'MOD' declared here
33 | template <long long MOD = 1000000007>
| ^~~~
a.cc:83:18: error: declaration of template parameter 'MOD' shadows template parameter
83 | template<long long MOD>mint<MOD>& operator--()
| ^~~~
a.cc:33:11: note: template parameter 'MOD' declared here
33 | template <long long MOD = 1000000007>
| ^~~~
a.cc:88:18: error: declaration of template parameter 'MOD' shadows template parameter
88 | template<long long MOD>mint<MOD> operator--(int)
| ^~~~
a.cc:33:11: note: template parameter 'MOD' declared here
33 | template <long long MOD = 1000000007>
| ^~~~
a.cc:94:18: error: declaration of template parameter 'MOD' shadows template parameter
94 | template<long long MOD>mint<MOD> operator~()const
| ^~~~
a.cc:33:11: note: template parameter 'MOD' declared here
33 | template <long long MOD = 1000000007>
| ^~~~
a.cc:98:18: error: declaration of template parameter 'MOD' shadows template parameter
98 | template<long long MOD>mint<MOD>& operator=(const mint<MOD> &other)
| ^~~~
a.cc:33:11: note: template parameter 'MOD' declared here
33 | template <long long MOD = 1000000007>
| ^~~~
a.cc: In static member function 'static long long int mint<MOD>::getmod()':
a.cc:113:24: error: 'mod' was not declared in this scope; did you mean 'modf'?
113 | return mod;
| ^~~
| modf
|
s334540508 | p00482 | C++ | #include <iostream>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
#define MOD 100000
int M, N;
char S[20][20];
int dp[400][1<<20][3];
int bf[20][20];
char T[3] = {'J', 'O', 'I'};
int f(char c) {
if (c == 'J') return 0;
if (c == 'O') return 1;
if (c == 'I') return 2;
exit(1);
}
int main() {
cin >> M >> N;
for (int i=0; i<M; i++) {
for (int j=0; j<N; j++) {
cin >> S[i][j];
}
}
for (int k=0; k<3; k++) {
if (S[0][0] != '?' && f(S[0][0]) != k) continue;
dp[0][0][k] = 1;
}
for (int y=0; y<M; y++) {
for (int x=0; x<N; x++) {
int p = y*N + x;
if (p == 0) continue;
for (int s=0; s<(1<<N); s++) {
for (int k=0; k<3; k++) {
for (int g=0; g<3; g++) {
if (S[y][x] != '?' && f(S[y][x]) != g) continue;
int ns = s >> 1;
if (x != 0 && k == 0 && g == 1) ns |= 1<<(N-1);
if (x != N-1 && (ns & 1) != 0 && g == 2) {
bf[y][x] += dp[p-1][s][k];
bf[y][x] %= MOD;
continue;
}
dp[p][ns][g] += dp[p-1][s][k];
dp[p][ns][g] %= MOD;
}
}
}
}
}
long long ans = 0;
long long t = 1;
for (int y=M-1; y>=0; y--) {
for (int x=N-1; x>=0; x--) {
ans = (ans + (t*(long long)bf[y][x] % MOD)) % MOD;
if (S[y][x] == '?') t = (t * 3) % MOD;
}
}
cout << ans << "\n";
return 0;
} | /tmp/ccjYxTBe.o: in function `main':
a.cc:(.text+0x29c): relocation truncated to fit: R_X86_64_PC32 against symbol `bf' defined in .bss section in /tmp/ccjYxTBe.o
a.cc:(.text+0x311): relocation truncated to fit: R_X86_64_PC32 against symbol `bf' defined in .bss section in /tmp/ccjYxTBe.o
a.cc:(.text+0x340): relocation truncated to fit: R_X86_64_PC32 against symbol `bf' defined in .bss section in /tmp/ccjYxTBe.o
a.cc:(.text+0x391): relocation truncated to fit: R_X86_64_PC32 against symbol `bf' defined in .bss section in /tmp/ccjYxTBe.o
a.cc:(.text+0x5c2): relocation truncated to fit: R_X86_64_PC32 against symbol `bf' defined in .bss section in /tmp/ccjYxTBe.o
collect2: error: ld returned 1 exit status
|
s526011100 | p00482 | C++ | # include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
typedef pair<LL, LL> P;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
constexpr long long MMOD = 500000004;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x) (x).begin(),(x).end()
# define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
# define mp make_pair
# define eb emplace_back
# define FOR(i,a,b) for(int i=(a);i<(b);i++)
# define RFOR(i,a,b) for(int i=(a);i>=(b);i--)
# define REP(i,n) FOR(i,0,n)
# define INIT std::ios::sync_with_stdio(false);std::cin.tie(0)
constexpr int MAX_N = 20;
constexpr int MAX_M = 20;
constexpr int MOD = 100000;
constexpr char JOI[] = "JOI";
int n, m;
char field[MAX_M][MAX_N];
int dp[2][1 << MAX_N][2];//dp[current or next][直前N文字(前の一列)に"JO"があるか][直前の文字が"J"なのかどうか]
int main() {
std::cin.tie(0);
std::ios::sync_with_stdio(false);
std::cin >> m >> n;
for (int i = 0; i < m; ++i) {
for (int j = 0; j < n; ++j) {
std::cin >> field[i][j];
}
}
dp[0][0][0] = 1;
int crt = 0, nxt = 1;
for (int i = 0; i < m; ++i) {
for (int j = 0; j < n; ++j) {
memset(dp[nxt], 0, sizeof(dp[nxt]));
for (int bit = 0; bit < (1 << n); ++bit) {
for (int f = 0; f < 2; ++f) {//直前の文字が'J'なのかどうか
if (dp[crt][bit][f] > 0) {//そもそも、存在しない場合は処理しない
for (int k = 0; k < 3; ++k) {//文字を三通り当てはめる、但し'?'の時は三通り全て当てはめる
if (field[i][j] != '?' && field[i][j] != JOI[k]) {
continue;
}//文字が今回調べるべきでないとき
if (bit >> j & 1 && JOI[k] == 'I') {
continue;
}//「良い旗」ができてしまったとき
int nbit = bit & ~(1 << j);//現在の位置のJOのbitを消去する
int nf = JOI[k] == 'J';//次のfを求める
if (JOI[k] == 'O' && f == 1) {
nbit |= 1 << (j - 1);
}//JOができた時は次のビットにそれを適応する
dp[nxt][nbit][nf] += dp[crt][bit][f];
if (dp[nxt][nbit][nf] > MOD) {
dp[nxt][nbit][nf] -= MOD;
}
}
}
}
}
std::swap(crt, nxt);
}
for (int bit = 0; bit < (1 << n); ++bit) {
dp[crt][bit][0] += dp[crt][bit][1];
if (dp[crt][bit][0] >= MOD) {
dp[crt][bit][0] -= MOD;
}
dp[crt][bit][1] = 0;
}//行が変わるとき、前のますが'J'であることはなくなるので、それを処理する。
}
int ans = 1;//余事象
for (int i = 0; i < m; ++i) {
for (int j = 0; j < n; ++j) {
if (field[i][j] == '?') {
ans = (ans * 3) % MOD;
}
}
}
for (int bit = 0; bit < 1 << n; ++bit) {
ans = (ans + MOD - dp[crt][bit][0]) % MOD;
}
std::cout << ans << std::endl;
}
| a.cc: In function 'int main()':
a.cc:67:25: error: 'memset' was not declared in this scope
67 | memset(dp[nxt], 0, sizeof(dp[nxt]));
| ^~~~~~
a.cc:19:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
18 | # include <bitset>
+++ |+#include <cstring>
19 | using namespace std;
|
s854455219 | p00482 | C++ | #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
using namespace std;
#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif
#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define clear(arr, val) memset(arr, val, sizeof(arr))
#define rep(i, n) for (int i = 0; i < n; ++i)
template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }
typedef long long ll;
typedef pair<int, int> pint;
const double EPS = 1e-8;
const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };
int w, h;
char s[32][32];
int counter = 0;
//map<int, int> states;
short index[1 << 20];
int states[17777];
bool used_j[32];
void make_states(int p)
{
if (p == w)
{
int s = 0;
for (int i = 0; i < w; ++i)
s |= used_j[i] << i;
//int pos = states.size();
//states[s] = pos;
states[counter] = s;
index[s] = counter++;
}
else
{
make_states(p + 1);
if (p == 0 || !used_j[p - 1])
{
used_j[p] = true;
make_states(p + 1);
used_j[p] = false;
}
}
}
int main()
{
cin >> h >> w;
rep (i, h)
cin >> s[i];
make_states(0);
const int mod = 100000;
static int dp[401][17777];
dp[0][0] = 1;
for (int i = 0; i < w * h; ++i)
{
int x = i % w, y = i / w;
//foreach (it, states)
for (int j = 0; j < counter; ++j)
{
//int S = it->first;
//int cur = dp[i][it->second];
int S = states[j];
int cur = dp[i][j];
int T = ((S >> 1) << 2) & ((1 << w) - 1);
int J = S & 1;
if (s[y][x] == 'J' || s[y][x] == '?')
{
(dp[i + 1][index[T | (x < w - 1)]] += cur) %= mod;
}
if (s[y][x] == 'O' || s[y][x] == '?')
{
(dp[i + 1][index[T | (J ? (1 << 1) : 0)]] += cur) %= mod;
}
if (s[y][x] == 'I' || s[y][x] == '?')
{
if (!(S >> (w - 1) & 1))
(dp[i + 1][index[T]] += cur) %= mod;
}
}
}
int hatena = 0;
for (int i = 0; i < h; ++i)
for (int j = 0; j < w; ++j)
if (s[i][j] == '?')
++hatena;
int all_pattern = 1;
for (int i = 0; i < hatena; ++i)
(all_pattern *= 3) %= mod;
int non_joi = 0;
for (int i = 0; i < counter; ++i)
(non_joi += dp[w * h][i]) %= mod;
int res = (all_pattern - non_joi + mod) % mod;
cout << res << endl;
//cout << "all: " << all_pattern << endl;
//cout << "non_joi: " << non_joi << endl;
} | a.cc:58:20: error: 'short int index [1048576]' redeclared as different kind of entity
58 | short index[1 << 20];
| ^
In file included from /usr/include/string.h:462,
from /usr/include/c++/14/cstring:43,
from a.cc:3:
/usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)'
50 | extern const char *index (const char *__s, int __c)
| ^~~~~
a.cc: In function 'void make_states(int)':
a.cc:72:22: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
72 | index[s] = counter++;
| ^
a.cc: In function 'int main()':
a.cc:111:49: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
111 | (dp[i + 1][index[T | (x < w - 1)]] += cur) %= mod;
| ^
a.cc:116:49: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
116 | (dp[i + 1][index[T | (J ? (1 << 1) : 0)]] += cur) %= mod;
| ^
a.cc:122:57: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
122 | (dp[i + 1][index[T]] += cur) %= mod;
| ^
|
s688291229 | p00482 | C++ | // JOI 2010-2011 予選6
#include<iostream>
const int mod = 100000;
int M, N;
char flag[20][20];
// dp[crt or nxt][直前N文字において隣接する2列の文字がJOか][直前の1つがJか(次にJOが来るか判定するため)]
int dp[2][1 << 20][2];
char JOI[4] = "JOI";
int main()
{
std::cin >> M >> N;
for( int i = 0; i != M; ++i )
for( int j = 0; j != N; ++j )
std::cin >> flag[i][j];
dp[0][0][0] = 1;
int crt = 0, nxt = 1;
for( int i = 0; i != M; ++i )
{
for( int j = 0; j != N; ++j )
{
memset( dp[nxt], 0, sizeof( dp[nxt] ) );
for( int bit = 0; bit != 1 << N; ++bit )
{
for( int f = 0; f != 2; ++f )
{
if( dp[crt][bit][f] )
{
for( int k = 0; k != 3; ++k )
{
if( flag[i][j] != '?' && flag[i][j] != JOI[k] )
continue;
if( bit >> j & 1 && JOI[k] == 'I' )
continue;
int nbit = bit & ~( 1 << j ), nf = JOI[k] == 'J';
if( f && JOI[k] == 'O' )
nbit |= 1 << ( j - 1 );
dp[nxt][nbit][nf] += dp[crt][bit][f];
if( dp[nxt][nbit][nf] >= mod )
dp[nxt][nbit][nf] -= mod;
}
}
}
}
std::swap( crt, nxt );
}
for( int bit = 0; bit != 1 << N; ++bit )
{
dp[crt][bit][0] += dp[crt][bit][1];
if( dp[crt][bit][0] >= mod )
dp[crt][bit][0] -= mod;
dp[crt][bit][1] = 0;
}
}
int ans = 1;
for( int i = 0; i != M; ++i )
for( int j = 0; j != N; ++j )
if( flag[i][j] == '?' )
ans = ( ans * 3 ) % mod;
for( int i = 0; i != 1 << N; ++i )
ans = ( ans + mod - dp[crt][i][0] ) % mod;
std::cout << ans << std::endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:27:25: error: 'memset' was not declared in this scope
27 | memset( dp[nxt], 0, sizeof( dp[nxt] ) );
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include<iostream>
+++ |+#include <cstring>
3 |
|
s712342567 | p00482 | C++ | // JOI 2010-2011 予選6
#include<algorithm>
#include<iostream>
const int mod = 100000;
int M, N;
char flag[20][20];
// dp[crt or nxt][直前N文字において隣接する2列の文字がJOか][直前の1つがJか(次にJOが来るか判定するため)]
int dp[2][1 << 20][2];
char JOI[4] = "JOI";
int main()
{
std::cin >> M >> N;
for( int i = 0; i != M; ++i )
for( int j = 0; j != N; ++j )
std::cin >> flag[i][j];
dp[0][0][0] = 1;
int crt = 0, nxt = 1;
for( int i = 0; i != M; ++i )
{
for( int j = 0; j != N; ++j )
{
memset( dp[nxt], 0, sizeof( dp[nxt] ) );
for( int bit = 0; bit != 1 << N; ++bit )
{
for( int f = 0; f != 2; ++f )
{
if( dp[crt][bit][f] )
{
for( int k = 0; k != 3; ++k )
{
if( flag[i][j] != '?' && flag[i][j] != JOI[k] )
continue;
if( bit >> j & 1 && JOI[k] == 'I' )
continue;
int nbit = bit & ~( 1 << j ), nf = JOI[k] == 'J';
if( f && JOI[k] == 'O' )
nbit |= 1 << ( j - 1 );
dp[nxt][nbit][nf] += dp[crt][bit][f];
if( dp[nxt][nbit][nf] >= mod )
dp[nxt][nbit][nf] -= mod;
}
}
}
}
std::swap( crt, nxt );
}
for( int bit = 0; bit != 1 << N; ++bit )
{
dp[crt][bit][0] += dp[crt][bit][1];
if( dp[crt][bit][0] >= mod )
dp[crt][bit][0] -= mod;
dp[crt][bit][1] = 0;
}
}
int ans = 1;
for( int i = 0; i != M; ++i )
for( int j = 0; j != N; ++j )
if( flag[i][j] == '?' )
ans = ( ans * 3 ) % mod;
for( int i = 0; i != 1 << N; ++i )
ans = ( ans + mod - dp[crt][i][0] ) % mod;
std::cout << ans << std::endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:28:25: error: 'memset' was not declared in this scope
28 | memset( dp[nxt], 0, sizeof( dp[nxt] ) );
| ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include<iostream>
+++ |+#include <cstring>
4 |
|
s849094707 | p00482 | C++ | #include "stdio.h"
long long int dp[2][3][(1 << 20)];
long long int dp2[2][3][(1 << 20)];
char e[22][22];
int main()
{
int n,m;
scanf("%d %d",&n,&m);
for(int i = 0; i < m; i++)
{
scanf("%s",e[i]);
}
for(int i = 0; i < 2; i++)
{
for(int ii = 0; ii < 3; ii++)
{
for(int iii = 0; iii < (1 << n); iii++)
{
dp[i][ii][iii] = 0;
}
}
}
int temp = (1 << n) - 1;
int temp2 = (1 << (n - 2));
switch(e[0][0])
{
case 'J':
dp[0][0][0] = 1;
break;
case 'O':
dp[0][1][0] = 1;
break;
case 'I':
dp[0][2][0] = 1;
break;
case '?':
dp[0][0][0] = 1;
dp[0][1][0] = 1;
dp[0][2][0] = 1;
break;
}
for(int j = 1; j < n; j++)
{
for(int i = 0; i < 2; i++)
{
for(int ii = 0; ii < 3; ii++)
{
for(int iii = 0; iii < (1 << n); iii++)
{
dp2[i][ii][iii] = 0;
}
}
}
switch(e[0][i])
{
case 'J':
for(int i = 0; i < (1 << n); i++)
{
for(int ii = 0; ii < 3; ii++)
{
dp2[0][0][(i << 1) & temp] += dp[0][ii][i];
}
}
break;
case 'O':
for(int i = 0; i < (1 << n); i++)
{
dp2[0][1][(i << 1) & temp + 1] += dp[0][0][i];
dp2[0][1][(i << 1) & temp] += dp[0][1][i];
dp2[0][1][(i << 1) & temp] += dp[0][2][i];
}
break;
case 'I':
for(int i = 0; i < (1 << n); i++)
{
for(int ii = 0; ii < 3; ii++)
{
dp2[0][2][(i << 1) & temp] += dp[0][ii][i];
}
}
break;
case '?':
for(int i = 0; i < (1 << n); i++)
{
for(int ii = 0; ii < 3; ii++)
{
dp2[0][0][(i << 1) & temp] += dp[0][ii][i];
}
}
for(int i = 0; i < (1 << n); i++)
{
dp2[0][1][(i << 1) & temp + 1] += dp[0][0][i];
dp2[0][1][(i << 1) & temp] += dp[0][1][i];
dp2[0][1][(i << 1) & temp] += dp[0][2][i];
}
for(int i = 0; i < (1 << n); i++)
{
for(int ii = 0; ii < 3; ii++)
{
dp2[0][2][(i << 1) & temp] += dp[0][ii][i];
}
}
break;
}
for(int i = 0; i < 2; i++)
{
for(int ii = 0; ii < 3; ii++)
{
for(int iii = 0; iii < (1 << n); iii++)
{
dp[i][ii][iii] = dp2[i][ii][iii] % 10000;
}
}
}
}
for(int j = 1; i < m; j++)
{
for(int i = 0; i < 2; i++)
{
for(int ii = 0; ii < 3; ii++)
{
for(int iii = 0; iii < (1 << n); iii++)
{
dp2[i][ii][iii] = 0;
}
}
}
switch(e[j][0])
{
case 'J':
for(int i = 0; i < 2; i++)
{
for(int ii = 0; ii < 3; ii++)
{
for(int iii = 0; iii < (1 << n); iii++)
{
dp2[i][0][(iii << 1) & temp] += dp[i][ii][iii];
}
}
}
break;
case 'O':
for(int i = 0; i < 2; i++)
{
for(int ii = 0; ii < 3; ii++)
{
for(int iii = 0; iii < (1 << n); iii++)
{
dp2[i][1][(iii << 1) & temp] += dp[i][ii][iii];
}
}
}
break;
case 'I':
for(int i = 0; i < 2; i++)
{
for(int ii = 0; ii < 3; ii++)
{
for(int iii = 0; iii < (1 << n); iii++)
{
if((iii & temp2) != 0)
{
dp2[1][2][(iii << 1) & temp] += dp[i][ii][iii];
}
else
{
dp2[i][2][(iii << 1) & temp] += dp[i][ii][iii];
}
}
}
}
break;
case '?':
for(int i = 0; i < 2; i++)
{
for(int ii = 0; ii < 3; ii++)
{
for(int iii = 0; iii < (1 << n); iii++)
{
dp2[i][0][(iii << 1) & temp] += dp[i][ii][iii];
}
}
}
for(int i = 0; i < 2; i++)
{
for(int ii = 0; ii < 3; ii++)
{
for(int iii = 0; iii < (1 << n); iii++)
{
dp2[i][1][(iii << 1) & temp] += dp[i][ii][iii];
}
}
}
for(int i = 0; i < 2; i++)
{
for(int ii = 0; ii < 3; ii++)
{
for(int iii = 0; iii < (1 << n); iii++)
{
if((iii & temp2) != 0)
{
dp2[1][2][(iii << 1) & temp] += dp[i][ii][iii];
}
else
{
dp2[i][2][(iii << 1) & temp] += dp[i][ii][iii];
}
}
}
}
break;
}
for(int i = 0; i < 2; i++)
{
for(int ii = 0; ii < 3; ii++)
{
for(int iii = 0; iii < (1 << n); iii++)
{
dp[i][ii][iii] = dp2[i][ii][iii] % 10000;
}
}
}
for(int jj = 1; jj < n - 1; jj++)
{
for(int i = 0; i < 2; i++)
{
for(int ii = 0; ii < 3; ii++)
{
for(int iii = 0; iii < (1 << n); iii++)
{
dp2[i][ii][iii] = 0;
}
}
}
switch(e[j][jj])
{
case 'J':
for(int i = 0; i < 2; i++)
{
for(int ii = 0; ii < 3; ii++)
{
for(int iii = 0; iii < (1 << n); iii++)
{
dp2[i][0][(iii << 1) & temp] += dp[i][ii][iii];
}
}
}
break;
case 'O':
for(int i = 0; i < 2; i++)
{
for(int iii = 0; iii < (1 << n); iii++)
{
dp2[i][1][(iii << 1) & temp + 1] += dp[i][0][iii];
dp2[i][1][(iii << 1) & temp] += dp[i][1][iii];
dp2[i][1][(iii << 1) & temp] += dp[i][2][iii];
}
}
break;
case 'I':
for(int i = 0; i < 2; i++)
{
for(int ii = 0; ii < 3; ii++)
{
for(int iii = 0; iii < (1 << n); iii++)
{
if((iii & temp2) != 0)
{
dp2[1][2][(iii << 1) & temp] += dp[i][ii][iii];
}
else
{
dp2[i][2][(iii << 1) & temp] += dp[i][ii][iii];
}
}
}
}
break;
case '?':
for(int i = 0; i < 2; i++)
{
for(int ii = 0; ii < 3; ii++)
{
for(int iii = 0; iii < (1 << n); iii++)
{
dp2[i][0][(iii << 1) & temp] += dp[i][ii][iii];
}
}
}
for(int i = 0; i < 2; i++)
{
for(int iii = 0; iii < (1 << n); iii++)
{
dp2[i][1][(iii << 1) & temp + 1] += dp[i][0][iii];
dp2[i][1][(iii << 1) & temp] += dp[i][1][iii];
dp2[i][1][(iii << 1) & temp] += dp[i][2][iii];
}
}
for(int i = 0; i < 2; i++)
{
for(int ii = 0; ii < 3; ii++)
{
for(int iii = 0; iii < (1 << n); iii++)
{
if((iii & temp2) != 0)
{
dp2[1][2][(iii << 1) & temp] += dp[i][ii][iii];
}
else
{
dp2[i][2][(iii << 1) & temp] += dp[i][ii][iii];
}
}
}
}
break;
}
for(int i = 0; i < 2; i++)
{
for(int ii = 0; ii < 3; ii++)
{
for(int iii = 0; iii < (1 << n); iii++)
{
dp[i][ii][iii] = dp2[i][ii][iii] % 10000;
}
}
}
}
for(int i = 0; i < 2; i++)
{
for(int ii = 0; ii < 3; ii++)
{
for(int iii = 0; iii < (1 << n); iii++)
{
dp2[i][ii][iii] = 0;
}
}
}
switch(e[j][n - 1])
{
case 'J':
for(int i = 0; i < 2; i++)
{
for(int ii = 0; ii < 3; ii++)
{
for(int iii = 0; iii < (1 << n); iii++)
{
dp2[i][0][(iii << 1) & temp] += dp[i][ii][iii];
}
}
}
break;
case 'O':
for(int i = 0; i < 2; i++)
{
for(int iii = 0; iii < (1 << n); iii++)
{
dp2[i][1][(iii << 1) & temp + 1] += dp[i][0][iii];
dp2[i][1][(iii << 1) & temp] += dp[i][1][iii];
dp2[i][1][(iii << 1) & temp] += dp[i][2][iii];
}
}
break;
case 'I':
for(int i = 0; i < 2; i++)
{
for(int ii = 0; ii < 3; ii++)
{
for(int iii = 0; iii < (1 << n); iii++)
{
dp2[i][2][(iii << 1) & temp] += dp[i][ii][iii];
}
}
}
break;
case '?':
for(int i = 0; i < 2; i++)
{
for(int ii = 0; ii < 3; ii++)
{
for(int iii = 0; iii < (1 << n); iii++)
{
dp2[i][0][(iii << 1) & temp] += dp[i][ii][iii];
}
}
}
for(int i = 0; i < 2; i++)
{
for(int iii = 0; iii < (1 << n); iii++)
{
dp2[i][1][(iii << 1) & temp + 1] += dp[i][0][iii];
dp2[i][1][(iii << 1) & temp] += dp[i][1][iii];
dp2[i][1][(iii << 1) & temp] += dp[i][2][iii];
}
}
for(int i = 0; i < 2; i++)
{
for(int ii = 0; ii < 3; ii++)
{
for(int iii = 0; iii < (1 << n); iii++)
{
dp2[i][2][(iii << 1) & temp] += dp[i][ii][iii];
}
}
}
break;
}
for(int i = 0; i < 2; i++)
{
for(int ii = 0; ii < 3; ii++)
{
for(int iii = 0; iii < (1 << n); iii++)
{
dp[i][ii][iii] = dp2[i][ii][iii] % 10000;
}
}
}
}
long long int all = 0;
for(int ii = 0; ii < 3; ii++)
{
int(int iii = 0; iii < (1 << n); iii++)
{
all = (all + dp[1][ii][iii]) % 10000;
}
}
printf("%lld\n",all);
return 0;
} | a.cc: In function 'int main()':
a.cc:58:29: error: 'i' was not declared in this scope
58 | switch(e[0][i])
| ^
a.cc:121:24: error: 'i' was not declared in this scope
121 | for(int j = 1; i < m; j++)
| ^
a.cc:427:17: error: expected primary-expression before 'int'
427 | int(int iii = 0; iii < (1 << n); iii++)
| ^~~
a.cc:427:34: error: 'iii' was not declared in this scope; did you mean 'ii'?
427 | int(int iii = 0; iii < (1 << n); iii++)
| ^~~
| ii
|
s266705413 | p00483 | C | #include <bits/stdc++.h>
char T[1005];
int sum[3][1005][1005];
int main() {
int m, n, k; scanf("%d%d%d", &m, &n, &k);
for (int i = 0; i < m; i++) {
scanf("%s", T);
for (int j = 0; j < n; j++) {
if (T[j] == 'J')sum[0][i][j]++;
else if (T[j] == 'O')sum[1][i][j]++;
else sum[2][i][j]++;
}
}
for (int i = 0; i < 3; i++) {
for (int j = 1; j < m; j++) {
for (int t = 0; t < n; t++) {
sum[i][j][t] += sum[i][j - 1][t];
}
}
}
for (int i = 0; i < 3; i++) {
for (int j = 0; j < m; j++) {
for (int t = 1; t < n; t++) {
sum[i][j][t] += sum[i][j][t - 1];
}
}
}
for (int i = 0; i < k; i++) {
int a, b, c, d; scanf("%d%d%d%d", &a, &b, &c, &d);
a--; b--; c--; d--;
int ans[3];
for (int j = 0; j < 3; j++)ans[j] = sum[j][c][d] - sum[j][c][b - 1] - sum[j][a - 1][d] + sum[j][a - 1][b - 1];
printf("%d %d %d\n", ans[0], ans[1], ans[2]);
}
return 0;
} | main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
1 | #include <bits/stdc++.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
|
s451908832 | p00483 | C | #include<iostream>
#include<string>
using namespace std;
int J[1200][1200], O[1200][1200], I[1200][1200];
int H, W, Q; string S;
int main() {
cin >> H >> W >> Q;
for (int i = 1; i <= H; i++) {
cin >> S;
for (int j = 0; j < S.size(); j++) {
if (S[j] == 'J')J[i][j + 1]++;
if (S[j] == 'O')O[i][j + 1]++;
if (S[j] == 'I')I[i][j + 1]++;
}
}
for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++)J[i][j] += J[i - 1][j]; }
for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++)J[i][j] += J[i][j - 1]; }
for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++)O[i][j] += O[i - 1][j]; }
for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++)O[i][j] += O[i][j - 1]; }
for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++)I[i][j] += I[i - 1][j]; }
for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++)I[i][j] += I[i][j - 1]; }
for (int i = 0; i < Q; i++) {
int ax, ay, bx, by; cin >> ax >> ay >> bx >> by; ax--; ay--;
int pos1 = J[ax][ay] + J[bx][by] - J[ax][by] - J[ay][bx];
int pos2 = O[ax][ay] + O[bx][by] - O[ax][by] - O[ay][bx];
int pos3 = I[ax][ay] + I[bx][by] - I[ax][by] - I[bx][ay];
cout << pos1 << ' ' << pos2 << ' ' << pos3 << endl;
}
return 0;
} | main.c:1:9: fatal error: iostream: No such file or directory
1 | #include<iostream>
| ^~~~~~~~~~
compilation terminated.
|
s890577518 | p00483 | C++ | 10 10
100
IJJOIIJOOJ
OIOOOJIIIJ
IJJOJOIIOI
JJJOJOOIJJ
JJJIIJOIJI
JIOJOOOIIJ
OJJIIOJJOI
OIOJIIJJJJ
IJOOOOOJJO
OIIJJJOIII
2 1 7 4
7 6 9 6
8 2 9 8
2 1 5 5
4 1 7 9
6 6 6 10
1 4 10 8
8 1 10 6
2 2 5 7
2 2 5 3
6 2 10 5
2 5 7 8
4 4 9 10
2 3 10 6
1 1 10 8
6 6 6 9
3 1 3 8
3 4 3 10
5 1 6 4
1 1 10 8
1 3 1 9
2 2 2 4
1 1 6 6
2 3 10 7
3 3 7 4
7 4 8 6
3 5 9 9
6 10 10 10
6 6 8 9
2 8 10 8
3 5 10 7
5 6 5 7
3 5 6 6
3 6 6 8
7 3 10 9
6 1 9 2
2 1 8 6
1 1 4 10
4 3 6 8
4 4 5 4
5 2 6 8
1 1 4 6
5 4 10 9
4 3 10 7
1 2 2 7
8 1 10 2
1 9 2 10
7 1 8 2
7 2 9 3
1 6 1 8
7 7 10 10
2 1 5 3
1 7 4 7
1 3 6 8
7 1 10 7
6 7 9 9
9 4 10 5
3 2 9 3
4 1 10 6
4 5 6 8
2 8 3 9
8 2 10 9
2 4 4 6
1 7 5 9
3 1 8 4
10 2 10 8
2 1 9 3
6 6 7 8
3 2 6 4
3 1 5 1
4 2 10 2
3 3 8 7
8 7 9 7
2 5 7 6
3 4 4 6
1 3 7 7
1 4 6 7
8 3 8 8
4 4 8 9
2 3 8 8
3 9 5 10
3 3 7 8
2 1 5 3
5 3 7 10
2 4 7 5
4 7 8 9
3 5 10 5
4 5 8 9
3 1 8 6
1 4 3 9
8 8 8 9
3 2 10 7
5 6 10 8
8 1 9 4
6 3 7 6
2 1 9 4
3 1 8 6
2 5 8 6
3 4 6 5
2 7 2 9 | a.cc:1:1: error: expected unqualified-id before numeric constant
1 | 10 10
| ^~
|
s183725300 | p00483 | C++ | #include <iostream>
#include <algorithm>
#include <vector>
//#include <stack>
//#include <queue>
//#include <map>
#include <cmath>
#include <string>
//#include <sstream>
#include <iomanip>
//#include <complex>
//小数制度 cout << fixed << setprecision(5) << tmp << endl;
using namespace std;
#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
int map_j[1010][1010];
int map_o[1010][1010];
int map_i[1010][1010];
int main(){
int h,w;
ll int kk;
cin >> h >> w;
cin >> kk;
string st;
vector < string > joi;
REP(i,h){
cin >> str;
joi.pb(st);
}
string hit = "JOI";
int tmp = 0;
FOR(j,1,w+2){
if(joi[0][j-1]==hit[0]) tmp++;
map_j[1][j] = tmp;
}
FOR(j,2,h+2){
tmp = 0;
FOR(k,1,w+2){
if(joi[j-1][k-1]==hit[0]) tmp++;
map_j[j][k] = map_j[j-1][k]+tmp;
}
}
FOR(j,1,w+2){
if(joi[0][j-1]==hit[1]) tmp++;
map_o[1][j] = tmp;
}
FOR(j,2,h+2){
tmp = 0;
FOR(k,1,w+1){
if(joi[j-1][k-1]==hit[1]) tmp++;
map_o[j][k] = map_o[j-1][k]+tmp;
}
}
FOR(j,1,w+2){
if(joi[0][j-1]==hit[2]) tmp++;
map_i[1][j] = tmp;
}
FOR(j,2,h+2){
tmp = 0;
FOR(k,1,w+2){
if(joi[j-1][k-1]==hit[2]) tmp++;
map_i[j][k] = map_i[j-1][k]+tmp;
}
}
REP(i,kk){
int x1,y1,x2,y2;
cin >> x1 >> y1 >> x2 >> y2;
int t[3];
t[0] = map_j[x2][y2]+map_j[x1-1][y1-1]-map_j[x1-1][y2]-map_j[x2][y1-1];
t[1] = map_o[x2][y2]+map_o[x1-1][y1-1]-map_o[x1-1][y2]-map_o[x2][y1-1];
t[2] = map_i[x2][y2]+map_i[x1-1][y1-1]-map_i[x1-1][y2]-map_i[x2][y1-1];
cout << t[0] << " " << t[1] << " " << t[2]<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:35:24: error: 'str' was not declared in this scope; did you mean 'st'?
35 | cin >> str;
| ^~~
| st
|
s786199010 | p00483 | C++ | #include <iostream>
#include <algorithm>
#include <vector>
//#include <stack>
//#include <queue>
//#include <map>
#include <cmath>
#include <string>
//#include <sstream>
#include <iomanip>
//#include <complex>
//小数制度 cout << fixed << setprecision(5) << tmp << endl;
using namespace std;
#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
int map_j[1010][1010];
int map_o[1010][1010];
int map_i[1010][1010];
int main(){
int h,w;
ll int kk;
cin >> h >> w >> k;
string st;
vector < string > joi;
REP(i,h){
cin >> st;
joi.pb(st);
}
string hit = "JOI";
int tmp = 0;
FOR(j,1,w+2){
if(joi[0][j-1]==hit[0]) tmp++;
map_j[1][j] = tmp;
}
FOR(j,2,h+2){
tmp = 0;
FOR(k,1,w+2){
if(joi[j-1][k-1]==hit[0]) tmp++;
map_j[j][k] = map_j[j-1][k]+tmp;
}
}
FOR(j,1,w+2){
if(joi[0][j-1]==hit[1]) tmp++;
map_o[1][j] = tmp;
}
FOR(j,2,h+2){
tmp = 0;
FOR(k,1,w+1){
if(joi[j-1][k-1]==hit[1]) tmp++;
map_o[j][k] = map_o[j-1][k]+tmp;
}
}
FOR(j,1,w+2){
if(joi[0][j-1]==hit[2]) tmp++;
map_i[1][j] = tmp;
}
FOR(j,2,h+2){
tmp = 0;
FOR(k,1,w+2){
if(joi[j-1][k-1]==hit[2]) tmp++;
map_i[j][k] = map_i[j-1][k]+tmp;
}
}
REP(i,kk){
int x1,y1,x2,y2;
cin >> x1 >> y1 >> x2 >> y2;
int t[3];
t[0] = map_j[x2][y2]+map_j[x1-1][y1-1]-map_j[x1-1][y2]-map_j[x2][y1-1];
t[1] = map_o[x2][y2]+map_o[x1-1][y1-1]-map_o[x1-1][y2]-map_o[x2][y1-1];
t[2] = map_i[x2][y2]+map_i[x1-1][y1-1]-map_i[x1-1][y2]-map_i[x2][y1-1];
cout << t[0] << " " << t[1] << " " << t[2]<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:30:26: error: 'k' was not declared in this scope; did you mean 'kk'?
30 | cin >> h >> w >> k;
| ^
| kk
|
s611265660 | p00483 | C++ | 10 10
100
IJJOIIJOOJ
OIOOOJIIIJ
IJJOJOIIOI
JJJOJOOIJJ
JJJIIJOIJI
JIOJOOOIIJ
OJJIIOJJOI
OIOJIIJJJJ
IJOOOOOJJO
OIIJJJOIII
2 1 7 4
7 6 9 6
8 2 9 8
2 1 5 5
4 1 7 9
6 6 6 10
1 4 10 8
8 1 10 6
2 2 5 7
2 2 5 3
6 2 10 5
2 5 7 8
4 4 9 10
2 3 10 6
1 1 10 8
6 6 6 9
3 1 3 8
3 4 3 10
5 1 6 4
1 1 10 8
1 3 1 9
2 2 2 4
1 1 6 6
2 3 10 7
3 3 7 4
7 4 8 6
3 5 9 9
6 10 10 10
6 6 8 9
2 8 10 8
3 5 10 7
5 6 5 7
3 5 6 6
3 6 6 8
7 3 10 9
6 1 9 2
2 1 8 6
1 1 4 10
4 3 6 8
4 4 5 4
5 2 6 8
1 1 4 6
5 4 10 9
4 3 10 7
1 2 2 7
8 1 10 2
1 9 2 10
7 1 8 2
7 2 9 3
1 6 1 8
7 7 10 10
2 1 5 3
1 7 4 7
1 3 6 8
7 1 10 7
6 7 9 9
9 4 10 5
3 2 9 3
4 1 10 6
4 5 6 8
2 8 3 9
8 2 10 9
2 4 4 6
1 7 5 9
3 1 8 4
10 2 10 8
2 1 9 3
6 6 7 8
3 2 6 4
3 1 5 1
4 2 10 2
3 3 8 7
8 7 9 7
2 5 7 6
3 4 4 6
1 3 7 7
1 4 6 7
8 3 8 8
4 4 8 9
2 3 8 8
3 9 5 10
3 3 7 8
2 1 5 3
5 3 7 10
2 4 7 5
4 7 8 9
3 5 10 5
4 5 8 9
3 1 8 6
1 4 3 9
8 8 8 9
3 2 10 7
5 6 10 8
8 1 9 4
6 3 7 6
2 1 9 4
3 1 8 6
2 5 8 6
3 4 6 5
2 7 2 9 | a.cc:1:1: error: expected unqualified-id before numeric constant
1 | 10 10
| ^~
|
s586022094 | p00483 | C++ | #include<iostream>
#include<string>
using namespace std;
#define NMAX 999
#define MMAX 999
int main(){
int M,N;
int K;
int J[NMAX+1][MMAX+1]={0};
int O[NMAX+1][MMAX+1]={0};
int a,b,c,d;
string in;
cin>>M>>N;
cin>>K;
for(int i=1;i<=M;i++){
cin>>in;
for(int j=0;j<N;j++){
if(in[j]=='J') J[i][j+1]=1;
else if(in[j]=='O') O[i][j+1]=1;
else if(in[j]=='I') I[i][j+1]=1;
}
}
for(int i=1;i<=M;i++){
for(int j=1;j<=N;j++){
J[i][j]+=J[i][j-1];
O[i][j]+=O[i][j-1];
I[i][j]+=I[i][j-1];
}
}
for(int i=1;i<=N;i++){
for(int j=1;j<=M;j++){
J[j][i]+=J[j-1][i];
O[j][i]+=O[j-1][i];
I[j][i]+=I[j-1][i];
}
}
for(int i=0;i<K;i++){
cin>>a>>b>>c>>d;
cout<<J[c][d]-J[c][b-1]-J[a-1][d]+J[a-1][b-1]<<" "<<O[c][d]-O[c][b-1]-O[a-1][d]+O[a-1][b-1]<<" "<<I[c][d]-I[c][b-1]-I[a-1][d]+I[a-1][b-1]<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:26:33: error: 'I' was not declared in this scope
26 | else if(in[j]=='I') I[i][j+1]=1;
| ^
a.cc:34:13: error: 'I' was not declared in this scope
34 | I[i][j]+=I[i][j-1];
| ^
a.cc:42:13: error: 'I' was not declared in this scope
42 | I[j][i]+=I[j-1][i];
| ^
a.cc:48:107: error: 'I' was not declared in this scope
48 | cout<<J[c][d]-J[c][b-1]-J[a-1][d]+J[a-1][b-1]<<" "<<O[c][d]-O[c][b-1]-O[a-1][d]+O[a-1][b-1]<<" "<<I[c][d]-I[c][b-1]-I[a-1][d]+I[a-1][b-1]<<endl;
| ^
|
s352417249 | p00483 | C++ | #include<bits/stdc++.h>
#define LL long long
using namespace std;
static const LL INF = 1LL<<60LL;
typedef pair<int,int> pii;
string Map[1010][1010];
int J[1010][1010],O[1010][1010],I[1010][1010];
int m,n,k;
int a,b,c,d;
int res_J,res_O,res_I;
int main(){
cin>>m>>n>>k;
for(int y=1;y<=m;++y){
for(int x=1;x<=n;++x){
cin>>Map[y][x];
if(Map[y][x]=='J'){
J[y][x]++;
}
if(Map[y][x]=='O'){
O[y][x]++;
}
if(Map[y][x]=='I'){
I[y][x]++;
}
J[y][x]+=J[y][x-1];
O[y][x]+=O[y][x-1];
I[y][x]+=I[y][x-1];
}
}
for(int i=1;i<=k;++i){
cin>>a>>b>>c>>d;
for(int y=a;y<=c;++y){
res_J+=J[y][d]-J[y][b-1];
res_O+=O[y][d]-O[y][b-1];
res_I+=I[y][d]-I[y][b-1];
}
cout<<res_J<<" "<<res_O<<" "<<res_I<<endl;
res_J=0;
res_O=0;
res_I=0;
}
} | a.cc: In function 'int main()':
a.cc:19:25: error: no match for 'operator==' (operand types are 'std::string' {aka 'std::__cxx11::basic_string<char>'} and 'char')
19 | if(Map[y][x]=='J'){
| ~~~~~~~~~^~~~~
| | |
| | char
| std::string {aka std::__cxx11::basic_string<char>}
In file included from /usr/include/c++/14/regex:68,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181,
from a.cc:1:
/usr/include/c++/14/bits/regex.h:1103:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const sub_match<_BiIter>&)'
1103 | operator==(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1103:5: note: template argument deduction/substitution failed:
a.cc:19:27: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
19 | if(Map[y][x]=='J'){
| ^~~
/usr/include/c++/14/bits/regex.h:1199:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator==(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)'
1199 | operator==(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1199:5: note: template argument deduction/substitution failed:
a.cc:19:27: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'char'
19 | if(Map[y][x]=='J'){
| ^~~
/usr/include/c++/14/bits/regex.h:1274:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator==(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)'
1274 | operator==(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1274:5: note: template argument deduction/substitution failed:
a.cc:19:27: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
19 | if(Map[y][x]=='J'){
| ^~~
/usr/include/c++/14/bits/regex.h:1366:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)'
1366 | operator==(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1366:5: note: template argument deduction/substitution failed:
a.cc:19:27: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'char'
19 | if(Map[y][x]=='J'){
| ^~~
/usr/include/c++/14/bits/regex.h:1441:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)'
1441 | operator==(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1441:5: note: template argument deduction/substitution failed:
a.cc:19:27: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
19 | if(Map[y][x]=='J'){
| ^~~
/usr/include/c++/14/bits/regex.h:1534:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)'
1534 | operator==(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1534:5: note: template argument deduction/substitution failed:
a.cc:19:27: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'char'
19 | if(Map[y][x]=='J'){
| ^~~
/usr/include/c++/14/bits/regex.h:1613:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)'
1613 | operator==(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1613:5: note: template argument deduction/substitution failed:
a.cc:19:27: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
19 | if(Map[y][x]=='J'){
| ^~~
/usr/include/c++/14/bits/regex.h:2186:5: note: candidate: 'template<class _Bi_iter, class _Alloc> bool std::__cxx11::operator==(const match_results<_BiIter, _Alloc>&, const match_results<_BiIter, _Alloc>&)'
2186 | operator==(const match_results<_Bi_iter, _Alloc>& __m1,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:2186:5: note: template argument deduction/substitution failed:
a.cc:19:27: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::__cxx11::match_results<_BiIter, _Alloc>'
19 | if(Map[y][x]=='J'){
| ^~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_pair.h:1033:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1033 | operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1033:5: note: template argument deduction/substitution failed:
a.cc:19:27: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::pair<_T1, _T2>'
19 | if(Map[y][x]=='J'){
| ^~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:67:
/usr/include/c++/14/bits/stl_iterator.h:441:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
441 | operator==(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:441:5: note: template argument deduction/substitution failed:
a.cc:19:27: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
19 | if(Map[y][x]=='J'){
| ^~~
/usr/include/c++/14/bits/stl_iterator.h:486:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
486 | operator==(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:486:5: note: template argument deduction/substitution failed:
a.cc:19:27: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
19 | if(Map[y][x]=='J'){
| ^~~
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1667 | operator==(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note: template argument deduction/substitution failed:
a.cc:19:27: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
19 | if(Map[y][x]=='J'){
| ^~~
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1737 | operator==(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note: template argument deduction/substitution failed:
a.cc:19:27: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
19 | if(Map[y][x]=='J'){
| ^~~
In file included from /usr/include/c++/14/bits/char_traits.h:42,
from /usr/include/c++/14/string:42,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/bits/postypes.h:192:5: note: candidate: 'template<class _StateT> bool std::operator==(const fpos<_StateT>&, const fpos<_StateT>&)'
192 | operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/postypes.h:192:5: note: template argument deduction/substitution failed:
a.cc:19:27: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::fpos<_StateT>'
19 | if(Map[y][x]=='J'){
| ^~~
In file included from /usr/include/c++/14/string:43:
/usr/include/c++/14/bits/allocator.h:235:5: note: candidate: 'template<class _T1, class _T2> bool std::operator==(const allocator<_CharT>&, const allocator<_T2>&)'
235 | operator==(const allocator<_T1>&, const allocator<_T2>&)
| ^~~~~~~~
/usr/include/c++/14/bits/allocator.h:235:5: note: template argument deduction/substitution failed:
a.cc:19:27: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::allocator<_CharT>'
19 | if(Map[y][x]=='J'){
| ^~~
In file included from /usr/include/c++/14/bits/basic_string.h:47,
from /usr/include/c++/14/string:54:
/usr/include/c++/14/string_view:629:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_Char |
s720051996 | p00483 | C++ | #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;
//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
int M, N; cin >> M >> N;
int K; cin >> K;
map<char, int>mp;
mp['J'] = 0;
mp['O'] = 1;
mp['I'] = 2;
vector<vector<vector<int>>>sums(M+1, vector<vector<int>>(N+1, vector<int>(3)));
for (int i = 0; i < M; ++i) {
string st; cin >> st;
for (int j = 0; j < N; ++j) {
sums[i + 1][j + 1][mp[st[j]]]++;
}
}
for (int k = 0; k < 3; ++k) {
for (int i = 1; i <= M; ++i) {
for (int j = 1; j <= N; ++j) {
sums[i][j][k] += sums[i][j - 1][k] + sums[i - 1][j][k] - sums[i - 1][j - 1][k] + nums[i][j][k];
}
}
}
nums.clear();
for (int i = 0; i < K; ++i) {
int a, b, c, d; cin >> b >> a >> d >> c;
b--; a--;
vector<int> anss(3);
for (int j = 0; j < 3; ++j) {
anss[j] = sums[d][c][j]-sums[d][a][j] -sums[b][c][j] + sums[b][a][j];
}
cout << anss[0] << " " << anss[1] << " " << anss[2] << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:29:114: error: 'nums' was not declared in this scope; did you mean 'sums'?
29 | sums[i][j][k] += sums[i][j - 1][k] + sums[i - 1][j][k] - sums[i - 1][j - 1][k] + nums[i][j][k];
| ^~~~
| sums
a.cc:33:9: error: 'nums' was not declared in this scope; did you mean 'sums'?
33 | nums.clear();
| ^~~~
| sums
|
s273039160 | p00483 | C++ | #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;
//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
int M, N; cin >> M >> N;
int K; cin >> K;
map<char, int>mp;
mp['J'] = 0;
mp['O'] = 1;
mp['I'] = 2;
vector<vector<vector<int>>>sums(M+1, vector<vector<int>>(N+1, vector<int>(3)));
for (int i = 0; i < M; ++i) {
string st; cin >> st;
for (int j = 0; j < N; ++j) {
sums[i + 1][j + 1][mp[st[j]]]++;
}
}
for (int k = 0; k < 3; ++k) {
for (int i = 1; i <= M; ++i) {
for (int j = 1; j <= N; ++j) {
sums[i][j][k] += sums[i][j - 1][k] + sums[i - 1][j][k] - sums[i - 1][j - 1][k] + nums[i][j][k];
}
}
}
for (int i = 0; i < K; ++i) {
int a, b, c, d; cin >> b >> a >> d >> c;
b--; a--;
vector<int> anss(3);
for (int j = 0; j < 3; ++j) {
anss[j] = sums[d][c][j]-sums[d][a][j] -sums[b][c][j] + sums[b][a][j];
}
cout << anss[0] << " " << anss[1] << " " << anss[2] << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:29:114: error: 'nums' was not declared in this scope; did you mean 'sums'?
29 | sums[i][j][k] += sums[i][j - 1][k] + sums[i - 1][j][k] - sums[i - 1][j - 1][k] + nums[i][j][k];
| ^~~~
| sums
|
s250486675 | p00483 | C++ | #include <stdio.h>
int n,m,q,a,b,c,d,rui[1005][1005][3],ret[3];char f[1005][1005],e[3]={'J','O','I'};
int main(){
????????scanf("%d%d%d",&n,&m,&q);
????????for(int i=0;i<n;i++) scanf("%s",&f[i]);
????????for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) for(int k=0;k<3;k++)
????????rui[i][j][k]=rui[i-1][j][k]+rui[i][j-1][k]-rui[i-1][j-1][k]+(f[i-1][j-1]==e[k]);
????????for(int i=0;i<q;i++){
????????????????scanf("%d%d%d%d",&a,&b,&c,&d);
????????????????for(int j=0;j<3;j++) ret[j]=rui[c][d][j]-rui[c][b-1][j]-rui[a-1][d][j]+rui[a-1][b-1][j];
????????????????printf("%d %d %d\n",ret[0],ret[1],ret[2]);
????????}
} | a.cc: In function 'int main()':
a.cc:4:1: error: expected primary-expression before '?' token
4 | ????????scanf("%d%d%d",&n,&m,&q);
| ^
a.cc:4:2: error: expected primary-expression before '?' token
4 | ????????scanf("%d%d%d",&n,&m,&q);
| ^
a.cc:4:3: error: expected primary-expression before '?' token
4 | ????????scanf("%d%d%d",&n,&m,&q);
| ^
a.cc:4:4: error: expected primary-expression before '?' token
4 | ????????scanf("%d%d%d",&n,&m,&q);
| ^
a.cc:4:5: error: expected primary-expression before '?' token
4 | ????????scanf("%d%d%d",&n,&m,&q);
| ^
a.cc:4:6: error: expected primary-expression before '?' token
4 | ????????scanf("%d%d%d",&n,&m,&q);
| ^
a.cc:4:7: error: expected primary-expression before '?' token
4 | ????????scanf("%d%d%d",&n,&m,&q);
| ^
a.cc:4:8: error: expected primary-expression before '?' token
4 | ????????scanf("%d%d%d",&n,&m,&q);
| ^
a.cc:4:33: error: expected ':' before ';' token
4 | ????????scanf("%d%d%d",&n,&m,&q);
| ^
| :
a.cc:4:33: error: expected primary-expression before ';' token
a.cc:4:33: error: expected ':' before ';' token
4 | ????????scanf("%d%d%d",&n,&m,&q);
| ^
| :
a.cc:4:33: error: expected primary-expression before ';' token
a.cc:4:33: error: expected ':' before ';' token
4 | ????????scanf("%d%d%d",&n,&m,&q);
| ^
| :
a.cc:4:33: error: expected primary-expression before ';' token
a.cc:4:33: error: expected ':' before ';' token
4 | ????????scanf("%d%d%d",&n,&m,&q);
| ^
| :
a.cc:4:33: error: expected primary-expression before ';' token
a.cc:4:33: error: expected ':' before ';' token
4 | ????????scanf("%d%d%d",&n,&m,&q);
| ^
| :
a.cc:4:33: error: expected primary-expression before ';' token
a.cc:4:33: error: expected ':' before ';' token
4 | ????????scanf("%d%d%d",&n,&m,&q);
| ^
| :
a.cc:4:33: error: expected primary-expression before ';' token
a.cc:4:33: error: expected ':' before ';' token
4 | ????????scanf("%d%d%d",&n,&m,&q);
| ^
| :
a.cc:4:33: error: expected primary-expression before ';' token
a.cc:4:33: error: expected ':' before ';' token
4 | ????????scanf("%d%d%d",&n,&m,&q);
| ^
| :
a.cc:4:33: error: expected primary-expression before ';' token
a.cc:5:1: error: expected primary-expression before '?' token
5 | ????????for(int i=0;i<n;i++) scanf("%s",&f[i]);
| ^
a.cc:5:2: error: expected primary-expression before '?' token
5 | ????????for(int i=0;i<n;i++) scanf("%s",&f[i]);
| ^
a.cc:5:3: error: expected primary-expression before '?' token
5 | ????????for(int i=0;i<n;i++) scanf("%s",&f[i]);
| ^
a.cc:5:4: error: expected primary-expression before '?' token
5 | ????????for(int i=0;i<n;i++) scanf("%s",&f[i]);
| ^
a.cc:5:5: error: expected primary-expression before '?' token
5 | ????????for(int i=0;i<n;i++) scanf("%s",&f[i]);
| ^
a.cc:5:6: error: expected primary-expression before '?' token
5 | ????????for(int i=0;i<n;i++) scanf("%s",&f[i]);
| ^
a.cc:5:7: error: expected primary-expression before '?' token
5 | ????????for(int i=0;i<n;i++) scanf("%s",&f[i]);
| ^
a.cc:5:8: error: expected primary-expression before '?' token
5 | ????????for(int i=0;i<n;i++) scanf("%s",&f[i]);
| ^
a.cc:5:9: error: expected primary-expression before 'for'
5 | ????????for(int i=0;i<n;i++) scanf("%s",&f[i]);
| ^~~
a.cc:5:9: error: expected ':' before 'for'
5 | ????????for(int i=0;i<n;i++) scanf("%s",&f[i]);
| ^~~
| :
a.cc:5:9: error: expected primary-expression before 'for'
5 | ????????for(int i=0;i<n;i++) scanf("%s",&f[i]);
| ^~~
a.cc:5:9: error: expected ':' before 'for'
5 | ????????for(int i=0;i<n;i++) scanf("%s",&f[i]);
| ^~~
| :
a.cc:5:9: error: expected primary-expression before 'for'
5 | ????????for(int i=0;i<n;i++) scanf("%s",&f[i]);
| ^~~
a.cc:5:9: error: expected ':' before 'for'
5 | ????????for(int i=0;i<n;i++) scanf("%s",&f[i]);
| ^~~
| :
a.cc:5:9: error: expected primary-expression before 'for'
5 | ????????for(int i=0;i<n;i++) scanf("%s",&f[i]);
| ^~~
a.cc:5:9: error: expected ':' before 'for'
5 | ????????for(int i=0;i<n;i++) scanf("%s",&f[i]);
| ^~~
| :
a.cc:5:9: error: expected primary-expression before 'for'
5 | ????????for(int i=0;i<n;i++) scanf("%s",&f[i]);
| ^~~
a.cc:5:9: error: expected ':' before 'for'
5 | ????????for(int i=0;i<n;i++) scanf("%s",&f[i]);
| ^~~
| :
a.cc:5:9: error: expected primary-expression before 'for'
5 | ????????for(int i=0;i<n;i++) scanf("%s",&f[i]);
| ^~~
a.cc:5:9: error: expected ':' before 'for'
5 | ????????for(int i=0;i<n;i++) scanf("%s",&f[i]);
| ^~~
| :
a.cc:5:9: error: expected primary-expression before 'for'
5 | ????????for(int i=0;i<n;i++) scanf("%s",&f[i]);
| ^~~
a.cc:5:9: error: expected ':' before 'for'
5 | ????????for(int i=0;i<n;i++) scanf("%s",&f[i]);
| ^~~
| :
a.cc:5:9: error: expected primary-expression before 'for'
5 | ????????for(int i=0;i<n;i++) scanf("%s",&f[i]);
| ^~~
a.cc:5:9: error: expected ':' before 'for'
5 | ????????for(int i=0;i<n;i++) scanf("%s",&f[i]);
| ^~~
| :
a.cc:5:9: error: expected primary-expression before 'for'
5 | ????????for(int i=0;i<n;i++) scanf("%s",&f[i]);
| ^~~
a.cc:5:21: error: 'i' was not declared in this scope
5 | ????????for(int i=0;i<n;i++) scanf("%s",&f[i]);
| ^
a.cc:6:1: error: expected primary-expression before '?' token
6 | ????????for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) for(int k=0;k<3;k++)
| ^
a.cc:6:2: error: expected primary-expression before '?' token
6 | ????????for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) for(int k=0;k<3;k++)
| ^
a.cc:6:3: error: expected primary-expression before '?' token
6 | ????????for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) for(int k=0;k<3;k++)
| ^
a.cc:6:4: error: expected primary-expression before '?' token
6 | ????????for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) for(int k=0;k<3;k++)
| ^
a.cc:6:5: error: expected primary-expression before '?' token
6 | ????????for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) for(int k=0;k<3;k++)
| ^
a.cc:6:6: error: expected primary-expression before '?' token
6 | ????????for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) for(int k=0;k<3;k++)
| ^
a.cc:6:7: error: expected primary-expression before '?' token
6 | ????????for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) for(int k=0;k<3;k++)
| ^
a.cc:6:8: error: expected primary-expression before '?' token
6 | ????????for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) for(int k=0;k<3;k++)
| ^
a.cc:6:9: error: expected primary-expression before 'for'
6 | ????????for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) for(int k=0;k<3;k++)
| ^~~
a.cc:6:9: error: expected ':' before 'for'
6 | ????????for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) for(int k=0;k<3;k++)
| ^~~
| :
a.cc:6:9: error: expected primary-expression before 'for'
6 | ????????for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) for(int k=0;k<3;k++)
| ^~~
a.cc:6:9: error: expected ':' before 'for'
6 | ????????for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) for(int k=0;k<3;k++)
| ^~~
| :
a.cc:6:9: error: expected primary-expression before 'for'
6 | ????????for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) for(int k=0;k<3;k++)
| ^~~
a.cc:6:9: error: expected ':' before 'for'
6 | ????????for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) for(int k=0;k<3;k++)
| ^~~
| :
a.cc:6:9: error: expected primary-expression before 'for'
6 | ????????for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) for(int k=0;k<3;k++)
| ^~~
a.cc:6:9: error: expected ':' before 'for'
6 | ????????for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) for(int k=0;k<3;k++)
| ^~~
| :
a.cc:6:9: error: expected primary-expression before 'for'
6 | ????????for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) for(int k=0;k<3;k++)
| ^~~
a.cc:6:9: error: expected ':' before 'for'
6 | ????????for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) for(int k=0;k<3;k++)
| ^~~
| :
a.cc:6:9: error: expected primary-expression before 'for'
6 | ????????for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) for(int k=0;k<3;k++)
| ^~~
a.cc:6:9: error: expected ':' before 'for'
6 | ????????for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) for(int k=0;k<3;k++)
| ^~~
| :
a.cc:6:9: error: expected primary-expression before 'for'
6 | ????????for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) for(int k=0;k<3;k++)
| ^~~
a.cc:6:9: error: expected ':' before 'for'
6 | ????????for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) for(int k=0;k<3;k++)
| ^~~
| :
a.cc:6:9: error: expected primary-expression before 'for'
6 | ????????for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) for(int k=0;k<3;k++)
| ^~~
a.cc:6:9: error: expected ':' before 'for'
6 | ????????for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) for(int k=0;k<3;k++)
| ^~~
| :
a.cc:6:9: error: expected primary-expression before 'for'
|
s676845728 | p00483 | C++ | #include <bits/stdc++.h>
using namespace std;
#define loop(i,n) for(int i=1;i<=n;i++)
int jj[1002][1002];
int oo[1002][1002];
int ii[1002][1002];
int main(){
int m,n,k;
cin>>m>>n>>k;
char c;
loop(i,m)loop(j,n){
cin>>c;
jj[i][j]=jj[i-1][j]+jj[i][j-1]-jj[i-1][j-1];
oo[i][j]=oo[i-1][j]+oo[i][j-1]-oo[i-1][j-1];
ii[i][j]=ii[i-1][j]+ii[i][j-1]-ii[i-1][j-1];
if(c=='J')jj[i][j]++;
if(c=='O')oo[i][j]++;
if(c=='I')ii[i][j]++;
}
int a,b,c,d;
loop(i,k){
cin>>a>>b>>c>>d;
a--;
b--;
cout<<(jj[c][d]-jj[a][d]-jj[c][b]+jj[a][b]);
cout<<" ";
cout<<(oo[c][d]-oo[a][d]-oo[c][b]+oo[a][b]);
cout<<" ";
cout<<(ii[c][d]-ii[a][d]-ii[c][b]+ii[a][b]);
cout<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:22:11: error: conflicting declaration 'int c'
22 | int a,b,c,d;
| ^
a.cc:12:8: note: previous declaration as 'char c'
12 | char c;
| ^
|
s840844059 | p00483 | C++ | #include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <queue>
#include <sstream>
#include <fstream>
#include <cmath>
#include <cstring>
using namespace std;
#define int long long
const int mod = 1000000007;
int a[100000] = {}, b[100000] = {}, c[100000] = {}, d[100000] = {};
int memo[1000][1000][1000][3]= {};
char w[1000][1000] = {};
signed main(){
int M, N, K; cin >> M >> N >>K;
for (int i = 0; i < M; i++) {
for (int j = 0; j < N; j++) {
cin >> w[i][j];
}
}
for (int i = 0; i < K; i++) cin >> a[i] >> b[i] >> c[i] >> d[i];
for (int i = 0; i < M; i++) {
for (int j = 0; j < N; j++){
int t1 = 0, t2 = 0, t3 = 0;
for (int k = j; k < N; k++) {
if (w[i][k] == 'J') t1++;
else if (w[i][k] == 'O')t2++;
else t3++;
memo[j][k][i][0] = t1;
memo[j][k][i][1] = t2;
memo[j][k][i][2] = t3;
//<<"i"<<i<<" j"<<j<<" k"<<k<<" "<< t1 << " " << t2 << " " << t3 << endl;
}
}
}
for (int i = 0; i < K; i++) {
int t1 = 0, t2 = 0, t3 = 0;
for (int j = a[i]-1; j < c[i]; j++) {
t1 += memo[b[i]-1][d[i]-1][j][0];
t2 += memo[b[i]-1][d[i]-1][j][1];
t3 += memo[b[i]-1][d[i]-1][j][2];
}
cout << t1 << " " << t2 << " " << t3 << endl;
}
} | /tmp/ccytGWTN.o: in function `main':
a.cc:(.text+0x71): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccytGWTN.o
a.cc:(.text+0x1b3): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccytGWTN.o
a.cc:(.text+0x1dd): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccytGWTN.o
collect2: error: ld returned 1 exit status
|
s855006595 | p00483 | C++ | #include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <queue>
#include <sstream>
#include <fstream>
#include <cmath>
#include <cstring>
using namespace std;
#define int long long
const int mod = 1000000007;
int a[100000] = {}, b[100000] = {}, c[100000] = {}, d[100000] = {};
int memo[1000][1000][1000][3]= {};
char w[1000][1000] = {};
signed main(){
int M, N, K; cin >> M >> N >>K;
for (int i = 0; i < M; i++) {
for (int j = 0; j < N; j++) {
cin >> w[i][j];
}
}
for (int i = 0; i < K; i++) cin >> a[i] >> b[i] >> c[i] >> d[i];
for (int i = 0; i < M; i++) {
for (int j = 0; j < N; j++){
int t1 = 0, t2 = 0, t3 = 0;
for (int k = j; k < N; k++) {
if (w[i][k] == 'J') t1++;
else if (w[i][k] == 'O')t2++;
else t3++;
memo[j][k][i][0] = t1;
memo[j][k][i][1] = t2;
memo[j][k][i][2] = t3;
//<<"i"<<i<<" j"<<j<<" k"<<k<<" "<< t1 << " " << t2 << " " << t3 << endl;
}
}
}
for (int i = 0; i < K; i++) {
int t1 = 0, t2 = 0, t3 = 0;
for (int j = a[i]-1; j < c[i]; j++) {
t1 += memo[b[i]-1][d[i]-1][j][0];
t2 += memo[b[i]-1][d[i]-1][j][1];
t3 += memo[b[i]-1][d[i]-1][j][2];
}
cout << t1 << " " << t2 << " " << t3 << endl;
}
} | /tmp/ccjasESf.o: in function `main':
a.cc:(.text+0x71): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccjasESf.o
a.cc:(.text+0x1b3): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccjasESf.o
a.cc:(.text+0x1dd): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccjasESf.o
collect2: error: ld returned 1 exit status
|
s408213538 | p00483 | C++ | #include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <queue>
#include <sstream>
#include <fstream>
#include <cmath>
#include <cstring>
using namespace std;
#define int long long
const int mod = 1000000007;
int a[1000001] = {}, b[1000001] = {}, c[1000001] = {}, d[1000001] = {};
int memo[10001][10001][3]= {};
char w[10001][10001] = {};
signed main(){
int M, N, K; cin >> M >> N >>K;
for (int i = 0; i < M; i++) {
for (int j = 0; j < N; j++) {
cin >> w[i][j];
}
}
for (int i = 0; i < K; i++) cin >> a[i] >> b[i] >> c[i] >> d[i];
for (int i = 0; i < M; i++) {
int t1 = 0,t2=0,t3=0;
for (int j = 0; j < N; j++) {
if (w[i][j] == 'J')t1++;
else if (w[i][j] == 'O')t2++;
else t3++;
if (i == 0) {
memo[i][j][0] = t1;
memo[i][j][1] = t2;
memo[i][j][2] = t3;
}
else {
memo[i][j][0] = memo[i-1][j][0] + t1;
memo[i][j][1] = memo[i-1][j][1] + t2;
memo[i][j][2] = memo[i-1][j][2] + t3;
}
//cout << " i" << i << " j" << j << " " << memo[i][j][0] << memo[i][j][1] << memo[i][j][2];
}
//cout << endl;
}
for (int i = 0; i < K; i++) {
int a1, a2, a3;
a1 = memo[c[i] - 1][d[i] - 1][0] - memo[a[i]-2][d[i]-1][0] - memo[c[i]-1][b[i]-2][0] + memo[a[i]-2][b[i]-2][0];
a2 = memo[c[i] - 1][d[i] - 1][1] - memo[a[i] - 2][d[i] - 1][1] - memo[c[i] - 1][b[i] - 2][1] + memo[a[i] - 2][b[i] - 2][1];
a3 = memo[c[i] - 1][d[i] - 1][2] - memo[a[i] - 2][d[i] - 1][2] - memo[c[i] - 1][b[i] - 2][2] + memo[a[i] - 2][b[i] - 2][2];
cout << a1 << " " << a2 << " " << a3 << endl;
}
} | /tmp/cctLCG6G.o: in function `main':
a.cc:(.text+0x6b): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/cctLCG6G.o
a.cc:(.text+0x19d): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/cctLCG6G.o
a.cc:(.text+0x1c7): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/cctLCG6G.o
collect2: error: ld returned 1 exit status
|
s850734768 | p00483 | C++ | #include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
string s[9999];
int h,w,dp[1002][10002][3],a,b,c,d,n;
main(){
cin>>h>>w>>n;
r(i,w+1)s[0]+='@';
r(i,h)cin>>s[i+1],s[i+1]='@'+s[i+1];
for(int i=1;i<=h;i++)
for(int j=1;j<=w;j++){
r(k,3)dp[i][j][k]+=dp[i][j-1][k];
if(s[i][j]=='J')dp[i][j][0]++;
if(s[i][j]=='O')dp[i][j][1]++;
if(s[i][j]=='I')dp[i][j][2]++;
}
for(int i=1;i<=h;i++)
for(int j=1;j<=w;j++)
r(k,3)dp[i][j][k]+=dp[i-1][j][k];
while(n--){
scanf("%d%d%d%d",&a,&b,&c,&d)a--;b--;
cout<<dp[c][d][0]-dp[a][d][0]-dp[c][b][0]+dp[a][b][0]<<' ';
cout<<dp[c][d][1]-dp[a][d][1]-dp[c][b][1]+dp[a][b][1]<<' ';
cout<<dp[c][d][2]-dp[a][d][2]-dp[c][b][2]+dp[a][b][2]<<endl;
}
} | a.cc:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
6 | main(){
| ^~~~
a.cc: In function 'int main()':
a.cc:21:34: error: expected ';' before 'a'
21 | scanf("%d%d%d%d",&a,&b,&c,&d)a--;b--;
| ^
| ;
|
s744847556 | p00483 | C++ | #include "bits/stdc++.h"
using namespace std;
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
const int inf = 1000000001;
const ll INF = 1e18 * 4;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
class Land {
public:
int J, O, I;
Land(int j = 0, int o = 0, int i = 0) {
J = j;
O = o;
I = i;
}
Land operator + (Land other) {
Land res(0, 0, 0);
res.J = J + other.J;
res.O = O + other.O;
res.I = I + other.I;
return res;
}
};
int main() {
int w, h, k, i, j;
cin >> h >> w >> k;
vs a(h);
for (i = 0; i < h; i++) {
cin >> a[i];
}
Land z();
vector< vector<Land> > sum(h + 1, vector<Land>(w + 1, z));
for (i = 0; i < h; i++) {
for (j = 0; j < w; j++) {
sum[i + 1][j + 1] = sum[i + 1][j];
switch (a[i][j]) {
case 'J':
sum[i + 1][j + 1].J++;
break;
case'O':
sum[i + 1][j + 1].O++;
break;
default:
sum[i + 1][j + 1].I++;
}
}
for (j = 0; j < w; j++) {
sum[i + 1][j + 1] = sum[i + 1][j + 1] + sum[i][j + 1];
}
}
/*
for (i = 0; i <= h; i++) {
for (j = 0; j <= w; j++) {
cout << sum[i][j].J << sum[i][j].O << sum[i][j].I << " ";
}
cout << endl;
}
*/
for (i = 0; i < k; i++) {
int a, b, c, d;
cin >> a >> b >> c >> d;
int J = 0, O = 0, I = 0;
J = sum[c][d].J - sum[c][b - 1].J - sum[a - 1][d].J + sum[a - 1][b - 1].J;
O = sum[c][d].O - sum[c][b - 1].O - sum[a - 1][d].O + sum[a - 1][b - 1].O;
I = sum[c][d].I - sum[c][b - 1].I - sum[a - 1][d].I + sum[a - 1][b - 1].I;
cout << J << " " << O << " " << I << endl;
}
} | a.cc: In function 'int main()':
a.cc:50:15: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
50 | Land z();
| ^~
a.cc:50:15: note: remove parentheses to default-initialize a variable
50 | Land z();
| ^~
| --
a.cc:50:15: note: or replace parentheses with braces to value-initialize a variable
a.cc:51:64: error: no matching function for call to 'std::vector<Land>::vector(int, Land (&)())'
51 | vector< vector<Land> > sum(h + 1, vector<Land>(w + 1, z));
| ^
In file included from /usr/include/c++/14/vector:66,
from /usr/include/c++/14/functional:64,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:569:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const value_type&, const allocator_type&) [with _Tp = Land; _Alloc = std::allocator<Land>; size_type = long unsigned int; value_type = Land; allocator_type = std::allocator<Land>]' (near match)
569 | vector(size_type __n, const value_type& __value,
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:569:7: note: conversion of argument 2 would be ill-formed:
a.cc:51:63: error: invalid user-defined conversion from 'Land()' to 'const std::vector<Land>::value_type&' {aka 'const Land&'} [-fpermissive]
51 | vector< vector<Land> > sum(h + 1, vector<Land>(w + 1, z));
| ^
a.cc:29:9: note: candidate is: 'Land::Land(int, int, int)' (near match)
29 | Land(int j = 0, int o = 0, int i = 0) {
| ^~~~
a.cc:29:9: note: conversion of argument 1 would be ill-formed:
a.cc:51:63: error: invalid conversion from 'Land (*)()' to 'int' [-fpermissive]
51 | vector< vector<Land> > sum(h + 1, vector<Land>(w + 1, z));
| ^
| |
| Land (*)()
a.cc:51:63: error: invalid conversion from 'Land (*)()' to 'int' [-fpermissive]
51 | vector< vector<Land> > sum(h + 1, vector<Land>(w + 1, z));
| ^
| |
| Land (*)()
a.cc:29:18: note: initializing argument 1 of 'Land::Land(int, int, int)'
29 | Land(int j = 0, int o = 0, int i = 0) {
| ~~~~^~~~~
/usr/include/c++/14/bits/stl_vector.h:707:9: note: candidate: 'template<class _InputIterator, class> std::vector<_Tp, _Alloc>::vector(_InputIterator, _InputIterator, const allocator_type&) [with <template-parameter-2-2> = _InputIterator; _Tp = Land; _Alloc = std::allocator<Land>]'
707 | vector(_InputIterator __first, _InputIterator __last,
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:707:9: note: template argument deduction/substitution failed:
a.cc:51:64: note: deduced conflicting types for parameter '_InputIterator' ('int' and 'Land (*)()')
51 | vector< vector<Land> > sum(h + 1, vector<Land>(w + 1, z));
| ^
/usr/include/c++/14/bits/stl_vector.h:678:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::initializer_list<_Tp>, const allocator_type&) [with _Tp = Land; _Alloc = std::allocator<Land>; allocator_type = std::allocator<Land>]'
678 | vector(initializer_list<value_type> __l,
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:678:43: note: no known conversion for argument 1 from 'int' to 'std::initializer_list<Land>'
678 | vector(initializer_list<value_type> __l,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:659:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, std::__type_identity_t<_Alloc>&) [with _Tp = Land; _Alloc = std::allocator<Land>; std::__type_identity_t<_Alloc> = std::allocator<Land>]'
659 | vector(vector&& __rv, const __type_identity_t<allocator_type>& __m)
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:659:23: note: no known conversion for argument 1 from 'int' to 'std::vector<Land>&&'
659 | vector(vector&& __rv, const __type_identity_t<allocator_type>& __m)
| ~~~~~~~~~^~~~
/usr/include/c++/14/bits/stl_vector.h:640:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::false_type) [with _Tp = Land; _Alloc = std::allocator<Land>; allocator_type = std::allocator<Land>; std::false_type = std::false_type]'
640 | vector(vector&& __rv, const allocator_type& __m, false_type)
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:640:7: note: candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_vector.h:635:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::true_type) [with _Tp = Land; _Alloc = std::allocator<Land>; allocator_type = std::allocator<Land>; std::true_type = std::true_type]'
635 | vector(vector&& __rv, const allocator_type& __m, true_type) noexcept
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:635:7: note: candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_vector.h:624:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&, std::__type_identity_t<_Alloc>&) [with _Tp = Land; _Alloc = std::allocator<Land>; std::__type_identity_t<_Alloc> = std::allocator<Land>]'
624 | vector(const vector& __x, const __type_identity_t<allocator_type>& __a)
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:624:28: note: no known conversion for argument 1 from 'int' to 'const std::vector<Land>&'
624 | vector(const vector& __x, const __type_identity_t<allocator_type>& __a)
| ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:620:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&) [with _Tp = Land; _Alloc = std::allocator<Land>]'
620 | vector(vector&&) noexcept = default;
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:620:7: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_vector.h:601:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = Land; _Alloc = std::allocator<Land>]'
601 | vector(const vector& __x)
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:601:7: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_vector.h:556:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const allocator_type&) [with _Tp = Land; _Alloc = std::allocator<Land>; size_type = long unsigned int; allocator_type = std::allocator<Land>]'
556 | vector(size_type __n, const allocator_type& __a = allocator_type())
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:556:51: note: no known conversion for argument 2 from 'Land()' to 'const std::vector<Land>::allocator_type&' {aka 'const std::allocator<Land>&'}
556 | vector(size_type __n, const allocator_type& __a = allocator_type())
| ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:542:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const allocator_type&) [with _Tp = Land; _Alloc = std::allocator<Land>; allocator_type = std::allocator<Land>]'
542 | vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:542:7: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_vector.h:531:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector() [with _Tp = Land; _Alloc = std::allocator<Land>]'
531 | vector() = default;
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:531:7: note: candidate expects 0 arguments, 2 provided
|
s415658399 | p00483 | C++ | ostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(void) {
int M, N, K;
char res[1000][1000];
int xp, yp, xq, yq;
int J, O, I;
cin >> M >> N;
cin >> K;
for(int i = 0 ; i < M ; i++) {
scanf("%s", res[i]);
}
for(int a = 0 ; a < K ; a++) {
cin >> xp >> yp >> xq >> yq;
//while(cin >> xp >> yp >> xq >> yq) {
J = 0; O = 0; I = 0;
for(int i = xp-1 ; i < xq ; i++) {
for(int j = yp-1 ; j < yq ; j++) {
if(res[i][j] == 'J') J++;
if(res[i][j] == 'O') O++;
if(res[i][j] == 'I') I++;
//cout << res[i][j] << ' ';
}
//cout << endl;
}
printf("%d %d %d\n", J, O, I);
}
return 0;
} | a.cc:1:1: error: 'ostream' does not name a type
1 | ostream>
| ^~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:62,
from /usr/include/c++/14/algorithm:60,
from a.cc:3:
/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: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: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)>
| ^~~~~~
In file included from /usr/include/stdio.h:34,
from /usr/include/c++/14/cstdio:42,
from a.cc:2:
/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_algobase.h:65:
/usr/include/c++/14/bits/stl_iterator_base_types.h:125:67: error: 'ptrdiff_t' does not name a type
125 | template<typename _Category, typename _Tp, typename _Distance = ptrdiff_t,
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:1:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
+++ |+#include <cstddef>
1 | // Types used in iterator implementation -*- C++ -*-
/usr/include/c++/14/bits/stl_iterator_base_types.h:214:15: error: 'ptrdiff_t' does not name a type
214 | typedef ptrdiff_t difference_type;
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:214:15: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/bits/stl_iterator_base_types.h:225:15: error: 'ptrdiff_t' does not name a type
225 | typedef ptrdiff_t difference_type;
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:225:15: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
In file included from /usr/include/c++/14/bits/stl_algobase.h:66:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:112:5: error: 'ptrdiff_t' does not name a type
112 | ptrdiff_t
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:66:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
65 | #include <debug/assertions.h>
+++ |+#include <cstddef>
66 | #include <bits/stl_iterator_base_types.h>
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:118:5: error: 'ptrdiff_t' does not name a type
118 | ptrdiff_t
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:118:5: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
In file included from /usr/include/c++/14/bits/stl_iterator.h:67,
from /usr/include/c++/14/bits/stl_algobase.h:67:
/usr/include/c++/14/bits/ptr_traits.h:156:47: error: 'ptrdiff_t' was not declared in this scope
156 | |
s342474329 | p00483 | C++ | #include <iostream>
using namespace std;
int main(){
int m;
cin >>m;
int n;
cin >>n;
int k;
cin >>k;
int a[m][n];//上からm 左からnまでにあるJの個数
int b[m][n];//O
int c[m][n];//I
int j;//ある行においてマスまでに何個Jがあるか
int o;
int i;
char d;
int e;
int f;
e=0;
j=0;
o=0;
i=0;
while(e<n){
cin >>d;
if(d=="J"){j=j+1;}
if(d=="O"){o=o+1;}
if(d=="I"){i=i+1;}
a[0][e]=j;
b[0][e]=o;
c[0][e]=i;
e=e+1;}
f=1;
while(f<m){
e=0;
j=0;
o=0;
i=0;
while(e<n){
cin >>d;
if(d=="J"){j=j+1;}
if(d=="O"){o=o+1;}
if(d=="I"){i=i+1;}
a[f][e]=a[f-1][e]+j;
b[f][e]=b[f-1][e]+o;
c[f][e]=c[f-1][e]+i;
e=e+1;}
f=f+1;}
int p;
int q;
int r;
int s;
int t;
int u;
int v;
e=0;
while(e<k){
cin >>p;
cin >>q;
cin >>r;
cin >>s;
t=a[r-1][s-1]-a[r-1][q-2]-a[p-2][s-1]+a[p-2][q-2];
u=b[r-1][s-1]-b[r-1][q-2]-b[p-2][s-1]+b[p-2][q-2];
v=c[r-1][s-1]-c[r-1][q-2]-c[p-2][s-1]+c[p-2][q-2];
cout <<t<<" "<<u<<" "<<v<<endl;
e=e+1;}
} | a.cc: In function 'int main()':
a.cc:25:5: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
25 | if(d=="J"){j=j+1;}
| ~^~~~~
a.cc:26:5: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
26 | if(d=="O"){o=o+1;}
| ~^~~~~
a.cc:27:5: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
27 | if(d=="I"){i=i+1;}
| ~^~~~~
a.cc:40:5: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
40 | if(d=="J"){j=j+1;}
| ~^~~~~
a.cc:41:5: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
41 | if(d=="O"){o=o+1;}
| ~^~~~~
a.cc:42:5: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
42 | if(d=="I"){i=i+1;}
| ~^~~~~
|
s494956202 | p00483 | C++ | #include <cstdio>
int exist[1001][1001][3]={};
char field[1001][1001];
int m,n,Q;
int main(){
scanf("%d %d %d",&m,&n,&Q);
for(int i=0;i<m;i++){
scanf("%s",field[i]);
}
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
for(int g=i;g<m;g++){
for(int k=j;k<n;k++){
if(field[i][j]=='J'){
exist[g][k][0]++;
}else if(field[i][j]=='O'){
exist[g][k][1]++;
}else{
exist[g][k][2]++;
}
}
}
}
}
for(int i=0;i<Q;i++){
int a,b,c,d;
scanf("%d %d %d %d",&a,&b,&c,&d);
printf("%d %d %d\n",exist[c-1][d-1][0]-exist[c-1][b-2][0]-exist[a-2][d-1][0]+exist[a-2][b-2][0],exist[c-1][d-1][1]-exist[c-1][b-2][1]-exist[a-2][d-1][1]+exist[a-2][b-2][1],exist[c-1][d-1][2]-exist[c-1][b-2][2]-exist[a-2][d-1][2]+exist[a-2][b-2][2]);
return 0;
} | a.cc: In function 'int main()':
a.cc:30:2: error: expected '}' at end of input
30 | }
| ^
a.cc:5:11: note: to match this '{'
5 | int main(){
| ^
|
s660433176 | p00483 | C++ | #include <cstdio>
int joi2num(char c)
{
if(c == 'J') return 0;
if(c == 'O') return 1;
return 2;
}
int main()
{
int m, n, k;
char fld[1024][1024];
int sum[1024][1024][3];
scanf("%d%d%d", &m, &n, &k);
for(int x = 0; x < m; ++x)
scanf("%s", fld[x]);
for(int i = 0; i < 3; ++i)
sum[0][0][i] = (i == joi2num(fld[0][0]));
for(int x = 1; x < m; ++x) {
for(int i = 0; i < 3; ++i)
sum[x][0][i] = sum[x - 1][0][i] + (i == joi2num(fld[x][0]));
}
for(int y = 1; x < n; ++y) {
for(int i = 0; i < 3; ++i)
sum[0][y][i] = sum[x0][y - 1][i] + (i == joi2num(fld[0][y]));
}
for(int x = 1; x < m; ++x) {
for(int y = 1; y < n; ++y) {
for(int i = 0; i < 3; ++i) {
int temp = 0;
temp += sum[x - 1][y][i];
temp += sum[x][y - 1][i];
temp -= sum[x - 1][y - 1][i];
sum[x][y][i] = temp;
}
}
}
for(int i = 0; i < k; ++i) {
int ax, ay, bx, by;
scanf("%d%d%d%d", &ax, &ay, &bx, &by);
ax -= 1, ay -= 1, bx -= 1, by -= 1;
int ans[3] = {0};
for(int j = 0; j < 3; ++j) {
ans[j] += sum[bx][by][j];
ans[j] -= ax > 0 ? sum[ax - 1][by][j] : 0;
ans[j] -= ay > 0 ? sum[bx][ay - 1][j] : 0;
ans[j] += ax > 0 && ay > 0 ? sum[ax - 1][ay - 1][j] : 0;
}
printf("%d %d %d\n", ans[0], ans[1], ans[2]);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:24:16: error: 'x' was not declared in this scope
24 | for(int y = 1; x < n; ++y) {
| ^
a.cc:26:20: error: 'x0' was not declared in this scope
26 | sum[0][y][i] = sum[x0][y - 1][i] + (i == joi2num(fld[0][y]));
| ^~
|
s241525171 | p00483 | C++ | #include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
char tt[1000][1000];
int jj[1000][1000];
int oo[1000][1000];
int ii[1000][1000];
int n, m , k;
void f(int, int);
int main(){
cin >> m >> n;
cin >> k;
for(int i = 0; i < m; i++){
scanf("%s", tt[i]);
}
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
f(i, j);
}
}
while( cin >> y1 >> x1 >> y2 >> x2){
int y1, x1, y2, x2;
x1--; x1--; y1--; y1--; x2--; y2--;
int jm = (jj[y1][x2] - jj[y1][x1]) + jj[y2][x1];
int om = (oo[y1][x2] - oo[y1][x1]) + oo[y2][x1];
int im = (ii[y1][x2] - ii[y1][x1]) + ii[y2][x1];
printf("%d %d %d\n", jj[y2][x2] - jm, oo[y2][x2] - om, ii[y2][x2] - im);
}
return 0;
}
void f(int x, int y){
if(x == 0 && y == 0){
jj[0][0] = 0;
ii[0][0] = 0;
ii[0][0] = 0;
}else if(x == 0){
jj[y][0] = jj[y - 1][0];
ii[y][0] = ii[y - 1][0];
oo[y][0] = oo[y - 1][0];
}else if(y == 0){
jj[0][x] = jj[0][x - 1];
ii[0][x] = ii[0][x - 1];
oo[0][x] = oo[0][x - 1];
}else{
jj[y][x] = (jj[y - 1][x] - jj[y - 1][x - 1]) + jj[y][x - 1];
oo[y][x] = (oo[y - 1][x] - oo[y - 1][x - 1]) + oo[y][x - 1];
ii[y][x] = (ii[y - 1][x] - ii[y - 1][x - 1]) + ii[y][x - 1];
}
if(tt[y][x] == 'J')
jj[y][x]++;
else if(tt[y][x] == 'O')
oo[y][x]++;
else if(tt[y][x] == 'I')
ii[y][x]++;
} | a.cc: In function 'int main()':
a.cc:27:17: error: 'y1' was not declared in this scope
27 | while( cin >> y1 >> x1 >> y2 >> x2){
| ^~
a.cc:27:23: error: 'x1' was not declared in this scope
27 | while( cin >> y1 >> x1 >> y2 >> x2){
| ^~
a.cc:27:29: error: 'y2' was not declared in this scope
27 | while( cin >> y1 >> x1 >> y2 >> x2){
| ^~
a.cc:27:35: error: 'x2' was not declared in this scope
27 | while( cin >> y1 >> x1 >> y2 >> x2){
| ^~
|
s362734355 | p00483 | C++ | 12 7 5
0 2 1
5 6 3
10 6 4
16 11 9
1 2 2
15 19 16
5 7 6
10 9 5
6 1 1
7 6 7
6 9 9
16 14 12
13 16 7
29 27 24
0 2 2
3 2 3
1 3 3
5 1 2
29 27 24
2 3 2
0 2 1
16 12 8
15 21 9
5 3 2
1 1 4
12 13 10
2 1 2
5 4 3
3 0 6
7 12 5
1 1 0
3 4 1
1 6 5
12 9 7
3 2 3
17 15 10
15 13 12
5 8 5
0 1 1
4 5 5
10 9 5
14 11 11
12 16 7
4 4 4
1 2 3
2 1 1
1 2 1
3 2 1
1 1 1
8 4 4
8 2 2
1 1 2
10 15 11
9 11 8
7 3 2
2 2 0
9 3 2
17 14 11
2 6 4
0 1 3
10 7 7
3 6 0
3 5 7
13 6 5
3 1 3
12 7 5
2 3 1
7 3 2
2 0 1
4 0 3
11 12 7
1 1 0
4 6 2
2 4 0
12 15 8
6 12 6
3 1 2
11 9 10
14 15 13
3 1 2
10 11 9
8 2 2
8 7 9
3 5 4
7 4 4
3 2 3
9 8 8
16 11 9
3 8 7
2 0 0
19 18 11
7 7 4
2 4 2
2 4 2
14 11 7
16 11 9
4 6 4
3 3 2
0 0 3 | a.cc:1:1: error: expected unqualified-id before numeric constant
1 | 12 7 5
| ^~
|
s879859534 | p00483 | C++ | include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
char c[1000][1000];
int d[1000][1000][3] = {{{0},{0}}};
const int J = 0;
const int O = 1;
const int I = 2;
int main(void){
int m, n, k;
cin >> m >> n >> k;
for(int i = 0; i < m; i++){
scanf("%s", c[i]);
}
for(int y = 0; y < m; y++){
for(int x = 0; x < n; x++){
char t = c[y][x];
if(!x && !y){
}else if(!x){
d[y][x][J] = d[y - 1][x][J];
d[y][x][O] = d[y - 1][x][O];
d[y][x][I] = d[y - 1][x][I];
}else if(!y){
d[y][x][J] = d[y][x - 1][J];
d[y][x][O] = d[y][x - 1][O];
d[y][x][I] = d[y][x - 1][I];
}else{
d[y][x][J] = d[y - 1][x][J] + d[y][x - 1][J] - d[y - 1][x - 1][J];
d[y][x][O] = d[y - 1][x][O] + d[y][x - 1][O] - d[y - 1][x - 1][O];
d[y][x][I] = d[y - 1][x][I] + d[y][x - 1][I] - d[y - 1][x - 1][I];
}
if(t == 'J')
d[y][x][J]++;
else if(t == 'O')
d[y][x][O]++;
else
d[y][x][I]++;
}
}
for(int i = 0; i < k; i++){
int y1, x1, y2, x2;
cin >> y1 >> x1 >> y2 >> x2;
y1--; y1--; x1--; x1--; y2--; x2--;
int ans[3] = {0};
ans[J] = d[y2][x2][J] - d[y1][x2][J] - d[y2][x1][J] + d[y1][x1][J];
ans[O] = d[y2][x2][O] - d[y1][x2][O] - d[y2][x1][O] + d[y1][x1][O];
ans[I] = d[y2][x2][I] - d[y1][x2][I] - d[y2][x1][I] + d[y1][x1][I];
printf("%d %d %d\n", ans[J], ans[O], ans[I]);
}
return 0;
} | a.cc:1:1: error: 'include' does not name a type
1 | include<cstdio>
| ^~~~~~~
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_NO |
s833811692 | p00483 | C++ | #include <cstdio>
#include <algorithm>
using namespace std;
int field[1005][1005][3];
char field[1005][1005];
int n;
int w,h;
int main(){ | a.cc:5:6: error: conflicting declaration 'char field [1005][1005]'
5 | char field[1005][1005];
| ^~~~~
a.cc:4:5: note: previous declaration as 'int field [1005][1005][3]'
4 | int field[1005][1005][3];
| ^~~~~
a.cc: In function 'int main()':
a.cc:8:12: error: expected '}' at end of input
8 | int main(){
| ~^
|
s619249563 | p00483 | C++ | #include <cstdio>
#include <algorithm>
using namespace std;
int rui[1005][1005][3]={};
char field[1005][1005];
int n;
int w,h;
int main(){
scanf("%d %d",&w,&h);
scanf("%d",&n);
for(int i=1;i<=w;i++){
scanf("%s",&field[i]);
}
for(int i=1;i<=w;i++){
for(int j=h;j>=1;j--){
field[i][j]=field[i][j-1];
}
}
for(int i=1;i<=w;i++){
for(int j=1;j<=h;j++){
for(int k=0;k<3;k++){
rui[i][j][0]=rui[i][j-1][0]+rui[i-1][j][0]-rui[i-1][j-1];
}
if(field[i][j]=='J') rui[i][j][0]++;
else if(field[i][j]=='O') rui[i][j][1]++;
else rui[i][j][2]+++
}
}
for(int i=0;i<n;i++){
| a.cc: In function 'int main()':
a.cc:22:51: error: invalid operands of types 'int' and 'int [3]' to binary 'operator-'
22 | rui[i][j][0]=rui[i][j-1][0]+rui[i-1][j][0]-rui[i-1][j-1];
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
| | |
| int int [3]
a.cc:27:5: error: expected primary-expression before '}' token
27 | }
| ^
a.cc:29:24: error: expected '}' at end of input
29 | for(int i=0;i<n;i++){
| ~^
a.cc:29:24: error: expected '}' at end of input
a.cc:8:11: note: to match this '{'
8 | int main(){
| ^
|
s893125811 | p00483 | C++ | #include<cstdio>
int d[3][1002][1002], N, M, K;
int main()
{
char buf[1024];
scanf("%d%d%d", &N, &M, &K);
for (int i = 1; i <= N; i++) {
scanf("%s", buf + 1);
for (int j = 1; j <= M; j++) {
for (int k = 0; k < 3; k++) {
d[k][i][j] = d[k][i][j-1] + d[k][i-1][j] - d[k][i-1][j-1];
}
switch (buf[j]) {
case 'J': d[0][i][j]++;break;
case 'O': d[1][i][j]++;break;
case 'I': d[2][i][j]++;
}
}
}
while (K--) {
int x1, y1, x2, y2;
scanf("%d%d%d%d", &y1, &x1, &y2, &x2);
for (int i = 0; i < 3; i++) {
printf("%d ", d[i][y2][x2] - d[i][y1-1][x2] - d[i][y2][x1-1] + d[i][y1-1][x1-1]);
}
k?puts(""):0;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:31:17: error: 'k' was not declared in this scope
31 | k?puts(""):0;
| ^
|
s631017147 | p00483 | C++ | #include<cstdio>
int d[3][1002][1002], N, M, K;
int main()
{
char buf[1024];
scanf("%d%d%d", &N, &M, &K);
for (int i = 1; i <= N; i++) {
scanf("%s", buf + 1);
for (int j = 1; j <= M; j++) {
for (int k = 0; k < 3; k++) {
d[k][i][j] = d[k][i][j-1] + d[k][i-1][j] - d[k][i-1][j-1];
}
switch (buf[j]) {
case 'J': d[0][i][j]++;break;
case 'O': d[1][i][j]++;break;
case 'I': d[2][i][j]++;
}
}
}
while (K--) {
int x1, y1, x2, y2;
scanf("%d%d%d%d", &y1, &x1, &y2, &x2);
for (int i = 0; i < 3; i++) {
printf("%d ", d[i][y2][x2] - d[i][y1-1][x2] - d[i][y2][x1-1] + d[i][y1-1][x1-1]);
}
if(k)puts("");
}
return 0;
} | a.cc: In function 'int main()':
a.cc:31:20: error: 'k' was not declared in this scope
31 | if(k)puts("");
| ^
|
s280267428 | p00483 | C++ | #include<cstdio>
int d[3][1002][1002], N, M, K;
int main()
{
char buf[1024];
scanf("%d%d%d", &N, &M, &K);
for (int i = 1; i <= N; i++) {
scanf("%s", buf + 1);
for (int j = 1; j <= M; j++) {
for (int k = 0; k < 3; k++) {
d[k][i][j] = d[k][i][j-1] + d[k][i-1][j] - d[k][i-1][j-1];
}
switch (buf[j]) {
case 'J': d[0][i][j]++;break;
case 'O': d[1][i][j]++;break;
case 'I': d[2][i][j]++;
}
}
}
while (K--) {
int x1, y1, x2, y2;
scanf("%d%d%d%d", &y1, &x1, &y2, &x2);
for (int i = 0; i < 3; i++) {
putchar(i?' ':'');printf("%d", d[i][y2][x2] - d[i][y1-1][x2] - d[i][y2][x1-1] + d[i][y1-1][x1-1]);
}
puts("");
}
return 0;
} | a.cc:29:39: error: empty character constant
29 | putchar(i?' ':'');printf("%d", d[i][y2][x2] - d[i][y1-1][x2] - d[i][y2][x1-1] + d[i][y1-1][x1-1]);
| ^~
|
s250803900 | p00483 | C++ | #include<cstdio>
int d[3][1002][1002], N, M, K;
int main()
{
char buf[1024];
scanf("%d%d%d", &N, &M, &K);
for (int i = 1; i <= N; i++) {
scanf("%s", buf + 1);
for (int j = 1; j <= M; j++) {
for (int k = 0; k < 3; k++) {
d[k][i][j] = d[k][i][j-1] + d[k][i-1][j] - d[k][i-1][j-1];
}
switch (buf[j]) {
case 'J': d[0][i][j]++;break;
case 'O': d[1][i][j]++;break;
case 'I': d[2][i][j]++;
}
}
}
while (K--) {
int x1, y1, x2, y2;
scanf("%d%d%d%d", &y1, &x1, &y2, &x2);
for (int i = 0; i < 3; i++) {
i?putchar(' ');printf("%d", d[i][y2][x2] - d[i][y1-1][x2] - d[i][y2][x1-1] + d[i][y1-1][x1-1]);
}
puts("");
}
return 0;
} | a.cc: In function 'int main()':
a.cc:29:39: error: expected ':' before ';' token
29 | i?putchar(' ');printf("%d", d[i][y2][x2] - d[i][y1-1][x2] - d[i][y2][x1-1] + d[i][y1-1][x1-1]);
| ^
| :
a.cc:29:39: error: expected primary-expression before ';' token
|
s183125732 | p00484 | C++ | #include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main() {
int n, k;
cin >> n>>K;
vector<vector<int> > pr(10, vector<int>(n+1,0));
vector<int> ko(10, 0);
for (int i = 0; i < n; i++) {
int c, g; cin >> c >> g;
g--;
pr[g][ko[g]] = c;
ko[g]++;
}
for (int i = 0; i < 10; i++) {
sort(pr[i].begin(), pr[i].end());
reverse(pr[i].begin(), pr[i].end());
}
vector<vector<int> > sum(10,vector<int> (n+1,0));
for (int i = 0; i < n; i++) {
int su = 0;
for (int j = 1; j <= ko[i]; j++) {
su += pr[i][j-1];
sum[i][j] = su + j * (j - 1);
}
}
vector<vector<int> > dp(10, vector<int>(n + 1, 0));
dp[0] = sum[0];
for (int i = 1; i < 10; i++) {
for (int j = 0; j <= k; j++) {
for (int kk = j; kk <= k; kk++) {
dp[i][kk] = max(dp[i][kk], dp[i - 1][j] + sum[i][kk - j]);
}
}
}
cout << dp[9][k] << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:8:19: error: 'K' was not declared in this scope
8 | cin >> n>>K;
| ^
|
s609574940 | p00484 | C++ | #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x) cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
typedef long long LL;
template<typename T> using V = std::vector<T>;
template<typename T> using VV = std::vector<std::vector<T>>;
template<typename T> using VVV = std::vector<std::vector<std::vector<T>>>;
template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> inline void print(T x) { std::cout << x << std::endl; }
template<class T> inline void print_vec(const std::vector<T> &v) { for (int i = 0; i < v.size(); ++i) { if (i != 0) {std::cout << " ";} std::cout << v[i];} std::cout << "\n"; }
template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; }
template<class T> inline double euclidean_distance(T y1, T x1, T y2, T x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }
template<class T> inline double manhattan_distance(T y1, T x1, T y2, T x2) { return abs(x1 - x2) + abs(y1 - y2); }
const int INF = 1L << 30;
const double EPS = 1e-9;
const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy4 = { 0, 1, 0, -1 }, dx4 = { 1, 0, -1, 0 }; // 4近傍(右, 下, 左, 上)
const std::vector<int> dy8 = { 0, -1, 0, 1, 1, -1, -1, 1 }, dx8 = { 1, 0, -1, 0, 1, 1, -1, -1 };
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N, K;
cin >> N >> K;
vector<vector<int>> v(10);
FOR(i, 0, N) {
int C, G;
cin >> C >> G;
G--;
v[G].emplace_back(C);
}
vector<vector<vector<int>>> dp(11, vector<vector<int>>(N + 1, vector<int>(N + 1, -INF)));
FOR(kind, 0, 10) {
dp[kind][0][0] = 0;
FOR(i, 0, v[kind].size()) {
FOR(j, 0, N) {
int price = v[kind][i];
if (dp[kind][i][j] == -INF) {
continue;
}
// not use
dp[kind][i + 1][j] = max(dp[kind][i + 1][j], dp[kind][i][j]);
// use
dp[kind][i + 1][j + 1] = max(dp[kind][i + 1][j + 1], dp[kind][i][j] + price);
}
}
}
vector<vector<int>> dp2(11, vector<int>(N + 1, -INF));
dp2[0][0] = 0;
FOR(kind, 0, 10) {
FOR(i, 0, dp2[0].size()) {
if (dp2[kind][i] == -INF) {
continue;
}
int num = v[kind].size();
FOR(j, 0, num + 1) {
LL price = dp[kind][num][j] + max(0, j - 1) * j;
// use
dp2[kind + 1][i + j] = max(dp2[kind + 1][i + j], dp2[kind][i] + price);
}
}
}
LL ans = 0;
FOR(i, 0, K + 1) {
ans = max(ans, dp2[10][i]);
}
print(ans);
return 0;
}
| a.cc: In function 'int main()':
a.cc:83:43: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&, LL)'
83 | dp2[kind + 1][i + j] = max(dp2[kind + 1][i + j], dp2[kind][i] + price);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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: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:83:43: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'LL' {aka 'long long int'})
83 | dp2[kind + 1][i + j] = max(dp2[kind + 1][i + j], dp2[kind][i] + price);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:
/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:83:43: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
83 | dp2[kind + 1][i + j] = max(dp2[kind + 1][i + j], dp2[kind][i] + price);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:90:18: error: no matching function for call to 'max(LL&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
90 | ans = max(ans, dp2[10][i]);
| ~~~^~~~~~~~~~~~~~~~~
/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:90:18: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
90 | ans = max(ans, dp2[10][i]);
| ~~~^~~~~~~~~~~~~~~~~
/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
/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:90:18: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
90 | ans = max(ans, dp2[10][i]);
| ~~~^~~~~~~~~~~~~~~~~
|
s990147857 | p00484 | C++ | #include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}
int f(int i) {
return i * 2;
}
void solve() {
int N, K;
cin >> N >> K;
vector<pll> B(N);
for (int i = 0; i < N; i++) {
ll s, k;
cin >> s >> k;
k--;
B[i] = {k, s};
}
sort(all(B), [](pll a, pll b){
if (a.first == b.first) return a.second > b.second;
return a.first < b.first;
});
vector<int> offset(10, -1);
for (int i = 0; i < N; i++) {
if (offset[B[i].first] == -1) offset[B[i].first] = i;
}
vector<vector<vector<int>>> dp(N + 1, vector<vector<int>>(K + 1, vector<int>(2, -1)));
dp[0][0][0] = 0;
for(int i = 0; i < N; i++) {
for(int j = 0; j <= K; j++) {
if (j + 1 <= K && dp[i][j][0] != -1) {
chmax(dp[i + 1][j + 1][0], dp[i][j][0] + B[i].second + f(i - offset[B[i].first]));
}
// 切り替わるタイミングで0, そうでないとき1
int nextf = 1 - ((i == N - 1) || ((i < N - 1) && B[i].first != B[i + 1].first));
if (dp[i][j][0] != -1) chmax(dp[i + 1][j][nextf], dp[i][j][0]);
if (dp[i][j][1] != -1) chmax(dp[i + 1][j][nextf], dp[i][j][1]);
}
}
cout << max(dp[N][K][0], dp[N][K][1]) << endl;
}
int main() {
std::cin.tie(0);
std::ios::sync_with_stdio(false);
cout.setf(ios::fixed);
cout.precision(16);
solve();
return 0;
}
| a.cc: In function 'void solve()':
a.cc:7:30: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&, long long int)'
7 | #define chmax(x, y) (x) = max((x), (y))
| ~~~^~~~~~~~~~
a.cc:46:17: note: in expansion of macro 'chmax'
46 | chmax(dp[i + 1][j + 1][0], dp[i][j][0] + B[i].second + f(i - offset[B[i].first]));
| ^~~~~
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: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:7:30: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
7 | #define chmax(x, y) (x) = max((x), (y))
| ~~~^~~~~~~~~~
a.cc:46:17: note: in expansion of macro 'chmax'
46 | chmax(dp[i + 1][j + 1][0], dp[i][j][0] + B[i].second + f(i - offset[B[i].first]));
| ^~~~~
/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:
/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:7:30: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
7 | #define chmax(x, y) (x) = max((x), (y))
| ~~~^~~~~~~~~~
a.cc:46:17: note: in expansion of macro 'chmax'
46 | chmax(dp[i + 1][j + 1][0], dp[i][j][0] + B[i].second + f(i - offset[B[i].first]));
| ^~~~~
|
s252715915 | p00484 | C++ | #include <stdio.h>
int dp[2 << 10][2001];
int books[10][2001];
int book_nums[10];
int sell_prices[10][2001];
int greater_int(const void *a, const void *b) {
return *(int*)b - *(int*)a;
}
int main() {
int a, b, c, d;
int n, k;
int book_bits;
int max;
scanf("%d %d", &n, &k);
for (a=0; a<n; a++) {
int c, g;
int ind;
scanf("%d %d", &c, &g);
--g;
ind = book_nums[g];
books[g][ind] = c;
++book_nums[g];
}
for (a=0; a<10; a++) {
qsort(books[a], book_nums[a], sizeof(int), greater_int);
sell_prices[a][1] = books[a][0];
for (b=2; b<=book_nums[a]; b++) {
sell_prices[a][b] = sell_prices[a][b-1] + books[a][b-1] + (b-1)*2;
}
}
book_bits = 1 << 10;
for (a=0; a<k; a++) {
for (b=0; b < book_bits; b++) {
for (c=0; c<10; c++) {
int num;
if ((b >> c) & 1) continue;
num = book_nums[c];
if (num > k-a) {
num = k-a;
}
for (d=1; d<=num; d++) {
int val = dp[b][a] + sell_prices[c][d];
int *p = &dp[b | 1 << c][a+d];
if (*p < val) *p = val;
}
}
}
}
max = 0;
for (a=0; a < book_bits; a++) {
if (max < dp[a][k]) {
max = dp[a][k];
}
}
printf("%d\n", max);
} | a.cc: In function 'int main()':
a.cc:31:9: error: 'qsort' was not declared in this scope
31 | qsort(books[a], book_nums[a], sizeof(int), greater_int);
| ^~~~~
|
s130013144 | p00484 | C++ | #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
struct books
{
int n;
int j;
};
int n;
int k;
vector<books> bok;
int memo[2100][2100][2];
int jj[2100][2100][2][11] = {};
int check(int now,int w,int use)
{
if (now == n)return 0;
if (w > k)return 0;
//if (memo[now][w][use] != -1)return memo[now][w][use];
int ans = 0;
if (use)
{
ans += bok[now].n;
jj[now][w][use][bok[now].j]++;
ans += 2 * (jj[now][w][use][bok[now].j] - 1);
}
for (int i = 1; i < 11; i++)
{
jj[now + 1][w + 1][1][i] = jj[now][w][use][i];
jj[now + 1][w][0][i] = jj[now][w][use][i];
}
ans += max(check(now + 1, w + 1, 1), check(now + 1, w, 0));
return memo[now][w][use]=ans;
}
int main()
{
memset(memo, -1, sizeof(memo));
cin >> n >> k;
for (int i = 0; i < n; i++)
{
books a;
cin >> a.n >> a.j;
bok.push_back(a);
}
cout << max(check(0, 0, 0), check(0, 1, 1)) << endl;
} | a.cc: In function 'int main()':
a.cc:41:9: error: 'memset' was not declared in this scope
41 | memset(memo, -1, sizeof(memo));
| ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include<algorithm>
+++ |+#include <cstring>
4 | using namespace std;
|
s106472419 | p00484 | C++ | ???#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int N, K;
vector<int>G[10];
vector<int>Gsum[10];
int dp[10][2000];
int main()
{
scanf("%d%d", &N, &K);
for (int i = 0; i < N; i++){
int A, B;
scanf("%d%d", &A, &B);
G[B - 1].push_back(A);
}
for (int i = 0; i < 10; i++){
sort(G[i].begin(), G[i].end());
reverse(G[i].begin(), G[i].end());
}
for (int i = 0; i < 10; i++){
Gsum[i].push_back(0);
for (int j = 0; j < G[i].size(); j++){
int sum = 0;
for (int k = 0; k <= j; k++){
sum += G[i][k];
}
sum += (j + 1)*j;
if (G[i].size()>0)Gsum[i].push_back(sum);
}
}
for (int j = 0; j <= min(K, (int)Gsum[0].size() - 1); j++)dp[0][j] = Gsum[0][j];
for (int i = 1; i < 10; i++){
for (int j = 0; j <= K; j++){
int dpij = 0;
for (int k = 0; k <= min(j, (int)Gsum[i].size()-1);k++){
dpij = max(dpij,dp[i - 1][j - k] + Gsum[i][k]);
}
dp[i][j] = dpij;
}
}
int ans = 0;
for (int i = 0; i <= K; i++)ans = max(ans, dp[9][i]);
printf("%d\n", ans);
} | a.cc:1:4: error: stray '#' in program
1 | ???#include<iostream>
| ^
a.cc:1:1: error: expected unqualified-id before '?' token
1 | ???#include<iostream>
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:62,
from /usr/include/c++/14/vector:62,
from a.cc:3:
/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: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: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)>
| ^~~~~~
In file included from /usr/include/stdio.h:34,
from /usr/include/c++/14/cstdio:42,
from a.cc:2:
/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_algobase.h:65:
/usr/include/c++/14/bits/stl_iterator_base_types.h:125:67: error: 'ptrdiff_t' does not name a type
125 | template<typename _Category, typename _Tp, typename _Distance = ptrdiff_t,
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:1:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
+++ |+#include <cstddef>
1 | // Types used in iterator implementation -*- C++ -*-
/usr/include/c++/14/bits/stl_iterator_base_types.h:214:15: error: 'ptrdiff_t' does not name a type
214 | typedef ptrdiff_t difference_type;
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:214:15: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/bits/stl_iterator_base_types.h:225:15: error: 'ptrdiff_t' does not name a type
225 | typedef ptrdiff_t difference_type;
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:225:15: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
In file included from /usr/include/c++/14/bits/stl_algobase.h:66:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:112:5: error: 'ptrdiff_t' does not name a type
112 | ptrdiff_t
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:66:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
65 | #include <debug/assertions.h>
+++ |+#include <cstddef>
66 | #include <bits/stl_iterator_base_types.h>
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:118:5: error: 'ptrdiff_t' does not name a type
118 | ptrdiff_t
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:118:5: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
In file included from /usr/include/c++/14/bits/stl_iterator.h:67,
from /usr/include/c++/14/bits/stl_algobase.h:67:
/usr/include/c |
s346805085 | p00484 | C++ | //Solution for aoj 0561:Books
#include <iostream>
#include <algorithm>
#include <functional>
#include <queue>
using namespace std;
int n, k, a[11], fir[11], i, j, ma, num, ans, save[2001][2], sum;
int books[2001][3], books2[2001][11], books3[2001], books4[11];
void solve(int i){
for (i; i <= k; i++){
ma = 0;
for (int j = 1; j <= 10; j++){
if (ma<books2[books4[j]][j] + books4[j] * 2 - 2){
ma = books2[books4[j]][j] + books4[j] * 2 - 2;
num = j;
}
else if (ma == books2[books4[j]][j] + books4[j] * 2 - 2){
save[i][0] = books4[j];
save[i][1] = sum;
books4[j]++;
sum += ma;
solve(i + 1);
books4[j] = save[i][0];
sum = save[i][1];
}
}
books4[num]++;
sum += ma;
}
ans = max(ans, sum);
}
int main(){
cin >> n >> k;
for (i = 1; i <= n; i++){
cin >> books[i][0] >> books[i][1];
if (fir[books[i][1]] == 0)
fir[books[i][1]] = i;
books[a[books[i][1]]][2] = i;
a[books[i][1]] = i;
}
for (i = 1; i <= 10; i++){
if (a[i])
books[a[i]][2] = -1;
books4[i] = 1;
}
for (i = 1; i <= 10; i++){
int roop = 1;
j = fir[i];
if (j == 0)
break;
while (j != -1){
books3[roop] = books[j][0];
roop++;
j = books[j][2];
}
sort(books3+1, books3 + roop + 1, greater<int>());
for (int l = 1; l < roop; l++){
books2[l][i] = books3[l];
}
}//Solution for aoj 0561:Books
#include <iostream>
#include <algorithm>
#include <functional>
#include <queue>
using namespace std;
int n, k, a[11], fir[11], i, j, ma, num, ans, save[2001][2], sum;
int books[2001][3], books2[2001][11], books3[2001], books4[11];
void solve(int i){
for (i; i <= k; i++){
ma = 0;
for (int j = 1; j <= 10; j++){
if (ma<books2[books4[j]][j] + books4[j] * 2 - 2){
ma = books2[books4[j]][j] + books4[j] * 2 - 2;
num = j;
}
else if (ma == books2[books4[j]][j] + books4[j] * 2 - 2){
save[i][0] = books4[j];
save[i][1] = sum;
books4[j]++;
sum += ma;
solve(i + 1);
books4[j] = save[i][0];
sum = save[i][1];
}
}
books4[num]++;
sum += ma;
}
ans = max(ans, sum);
}
int main(){
cin >> n >> k;
for (i = 1; i <= n; i++){
cin >> books[i][0] >> books[i][1];
if (fir[books[i][1]] == 0)
fir[books[i][1]] = i;
books[a[books[i][1]]][2] = i;
a[books[i][1]] = i;
}
for (i = 1; i <= 10; i++){
if (a[i])
books[a[i]][2] = -1;
books4[i] = 1;
}
for (i = 1; i <= 10; i++){
int roop = 1;
j = fir[i];
if (j == 0)
break;
while (j != -1){
books3[roop] = books[j][0];
roop++;
j = books[j][2];
}
sort(books3+1, books3 + roop + 1, greater<int>());
for (int l = 1; l < roop; l++){
books2[l][i] = books3[l];
}
}
solve(1);
cout << ans << endl;
return 0;
}
solve(1);
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:68:18: error: a function-definition is not allowed here before '{' token
68 | void solve(int i){
| ^
a.cc:91:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
91 | int main(){
| ^~
a.cc:91:9: note: remove parentheses to default-initialize a variable
91 | int main(){
| ^~
| --
a.cc:91:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:91:11: error: a function-definition is not allowed here before '{' token
91 | int main(){
| ^
|
s699839191 | p00484 | C++ | #include <stack>
using namespace std;
int n, k, a[11], fir[11], i, j, save[11], sum, sum2, roop[11], mini;
stack <int>st[11];
int books[2001][3], books2[2001], books3[2001], books4[11];
int main(){
cin >> n >> k;
sum = 0;
for (i = 1; i <= 10; i++)
st[i].push(0);
for (i = 1; i <= n; i++){
cin >> books[i][0] >> books[i][1];
if (fir[books[i][1]] == 0)
fir[books[i][1]] = i;
books[a[books[i][1]]][2] = i;
a[books[i][1]] = i;
}
for (i = 1; i <= 10; i++){
if (a[i])
books[a[i]][2] = -1;
books4[i] = 1;
}
for (i = 1; i <= 10; i++){
roop[i] = 0;
j = fir[i];
if (j == 0)
break;
while (j != -1){
books3[roop[i]] = books[j][0];
roop[i]++;
j = books[j][2];
}
sort(books3, books3 + roop[i], greater<int>());
for (int l = 0; l < roop[i]; l++){
st[i].push(books3[l] + l * 2);
roop[0]++;
sum += books3[l] + l * 2;
}
}
for (int i = 0; i < roop[0] - k;){
mini = 1000000;
for (int j = 1; j <= 10; j++){
if (mini>st[j].top()&&st[j].top()!=0){
mini = st[j].top();
}
}
for (int j = 1; j <= 10; j++){
if (mini == st[j].top()){
st[j].pop();
sum -= mini;
i++;
if (i == n - k){
cout << sum << endl;
break;
}
}
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:7:9: error: 'cin' was not declared in this scope
7 | cin >> n >> k;
| ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
1 | #include <stack>
+++ |+#include <iostream>
2 | using namespace std;
a.cc:33:17: error: 'sort' was not declared in this scope; did you mean 'short'?
33 | sort(books3, books3 + roop[i], greater<int>());
| ^~~~
| short
a.cc:53:41: error: 'cout' was not declared in this scope
53 | cout << sum << endl;
| ^~~~
a.cc:53:41: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:53:56: error: 'endl' was not declared in this scope
53 | cout << sum << endl;
| ^~~~
a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
1 | #include <stack>
+++ |+#include <ostream>
2 | using namespace std;
|
s729249279 | p00484 | C++ | #include<bits/stdc++.h>
#define int long long
#define FOR(i,a,b) for(int i=a;i<=b;++i)
static const int INF = 1<<50;
static const int mod = 10007;
using namespace std;
int N,K,C[100010],G[11];
int mem[2020][11][11];
int cal(int n,int pp,int conect){
int res=0;
if(mem[n][pp][num]!=0)return mem[n][pp][num];
if(n==K)return 0;
FOR(i,1,N){
int t=conect;
if(pp==G[i]){
t++;
res=max(cal(n+1,G[i],t,i)+C[i],res);
}
else{
t=0;
res=max(cal(n+1,G[i],0,i)+C[i]+t,res);
}
}
return mem[n][pp][num]=res;
}
signed main(){
cin>>N>>K;
FOR(i,1,N){
cin>>C[i]>>G[i];
}
/*FOR(i,1,N-1){
FOR(j,i+1,N){
if(G[i]<G[j]){
int temp=G[i];
G[i]=G[j];
}
}
}*/
cout<<cal(0,0,0,0)<<endl;
} | a.cc:4:25: warning: left shift count >= width of type [-Wshift-count-overflow]
4 | static const int INF = 1<<50;
| ~^~~~
a.cc: In function 'long long int cal(long long int, long long int, long long int)':
a.cc:14:19: error: 'num' was not declared in this scope; did you mean 'enum'?
14 | if(mem[n][pp][num]!=0)return mem[n][pp][num];
| ^~~
| enum
a.cc:20:24: error: too many arguments to function 'long long int cal(long long int, long long int, long long int)'
20 | res=max(cal(n+1,G[i],t,i)+C[i],res);
| ~~~^~~~~~~~~~~~~~
a.cc:12:5: note: declared here
12 | int cal(int n,int pp,int conect){
| ^~~
a.cc:24:24: error: too many arguments to function 'long long int cal(long long int, long long int, long long int)'
24 | res=max(cal(n+1,G[i],0,i)+C[i]+t,res);
| ~~~^~~~~~~~~~~~~~
a.cc:12:5: note: declared here
12 | int cal(int n,int pp,int conect){
| ^~~
a.cc:27:23: error: 'num' was not declared in this scope; did you mean 'enum'?
27 | return mem[n][pp][num]=res;
| ^~~
| enum
a.cc: In function 'int main()':
a.cc:43:14: error: too many arguments to function 'long long int cal(long long int, long long int, long long int)'
43 | cout<<cal(0,0,0,0)<<endl;
| ~~~^~~~~~~~~
a.cc:12:5: note: declared here
12 | int cal(int n,int pp,int conect){
| ^~~
|
s200555134 | p00484 | C++ | #include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<(int)(n);i++)
#define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define pb(a) push_back(a)
#define mp(x,y) make_pair(x,y)
#define ALL(a) a.begin(),a.end()
#define ZERO(a) memset(a,0,sizeof(a))
#define len(a) sizeof(a)
#define ll long long
#define pii pair<int,int>
#define INF 1<<29
#define MAX
using namespace std;
int dp[2020][11];
void solve(){
int n,k,c,g;
cin>>n>>k;
vector<int> book[10],pr[10];
ZERO(dp);
FOR(i,n){
cin>>c>>g;
g--;
book[g].pb(c);
}
FOR(i,10) sort(ALL(book[i]),greater<int>());
FOR(i,10){
int tot=0;
pr[i].pb(tot);
FOR(j,v[i].size()){
tot+=v[i][j];
pr[i].pb(tot+j*(j+1));
}
}
for(int i=n;i>=0;i--){
FOR(j,10){
FOR(k,pr[j].size()){
if(i+k<=n) dp[i][j]=max(dp[i][j],dp[i+k][j+1]+pr[j][k]);
else break;
}
}
}
cout<<dp[0][0]<<endl;
}
int main(){
solve();
return 0;
} | a.cc: In function 'void solve()':
a.cc:31:9: error: 'v' was not declared in this scope
31 | FOR(j,v[i].size()){
| ^
a.cc:2:38: note: in definition of macro 'FOR'
2 | #define FOR(i,n) for(int i=0;i<(int)(n);i++)
| ^
|
s086530817 | p00484 | C++ | #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};
typedef long long int ll;
using namespace std;
int n,k;
vector<int> b[10];
int d[2001];
int main(){
cin >> n >> k;
memset(dp,-1,sizeof(dp));
memset(d,0,sizeof(d));
REP(i,10){
b[i].PB(0);
}
REP(i,n){
int c,g;
cin >> c >> g;
b[g-1].PB(c);
}
REP(i,10){
sort(b[i].begin()+1,b[i].end(),greater<int>());
if(b[i].size() <= 0) continue;
REP(j,b[i].size()-1){
b[i][j+1] += b[i][j];
}
REP(j,b[i].size()){
b[i][j] += (j-1)*j;
}
}
d[0] = 0;
REP(i,10){
RREP(j,n+1){
if(d[j] < 0) continue;
int s = min(n-j,(int)b[i].size() - 1);
for(int l=s;l >= 0;l--){
d[j+l] = max(d[j+l],d[j]+b[i][l]);
}
}
}
int ans = 0;
cout << d[k] << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:24:12: error: 'dp' was not declared in this scope; did you mean 'dy'?
24 | memset(dp,-1,sizeof(dp));
| ^~
| dy
|
s491425374 | p00484 | C++ | #include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
int n, k;
std::vector<int> cat[10];
int dp[11][2010];
int main() {
for(int i = 0; i < 10; ++i) {
cat[i].push_back(0);
}
std::cin >> n >> k;
for(int i = 0; i < n; ++i) {
int a, b;
std::cin >> a >> b;
--b;
cat[b].push_back(a);
}
for(int i = 0; i < 10; ++i) {
std::sort(cat[i].begin() + 1, cat[i].end(), std::greater<int>());
}
memset(dp, -1, sizeof(dp));
dp[0][0] = 0;
for(int i = 0; i < 10; ++i) {
for(int j = 1; j < cat[i].size(); ++j) {
cat[i][j] += cat[i][j - 1] + (j - 1) * j - (j - 2) * (j - 1);
}
for(int m = 0; m <= k; ++m) {
if(dp[i][m] != -1) {
for(int j = 0; j < cat[i].size(); ++j) {
dp[i + 1][m + j] = std::max(dp[i + 1][m + j], dp[i][m] + cat[i][j]);
}
}
}
}
std::cout << dp[10][k] << std::endl;
} | a.cc: In function 'int main()':
a.cc:26:5: error: 'memset' was not declared in this scope
26 | memset(dp, -1, sizeof(dp));
| ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
4 | #include <functional>
+++ |+#include <cstring>
5 |
|
s923078194 | p00484 | C++ | #include<bits/stdc++.h>
using namespace std;
int dp[11][2001],n,K,a1,a2;
vector<int>v[11];
main(){
cin>>n>>K;
r(i,n){
cin>>a1>>a2;
v[a2-1].push_back(a1);
}
r(i,10){
sort(v[i].begin(),v[i].end(),greater<int>());
r(j,v[i].size())if(j)v[i][j]+=v[i][j-1]+j;
}
r(i,10){r(j,K+1)
for(int k=0;k<v[i].size();k++){
dp[i+1][k+j+1]=max(dp[i+1][k+j+1],dp[i][j]+v[i][k]);
}
dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
}
cout<<dp[10][K]<<endl;
} | a.cc:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
5 | main(){
| ^~~~
a.cc: In function 'int main()':
a.cc:7:5: error: 'i' was not declared in this scope
7 | r(i,n){
| ^
a.cc:7:3: error: 'r' was not declared in this scope
7 | r(i,n){
| ^
|
s254634974 | p00484 | C++ | #include<bits/stdc++.h>
#define r(I,n) for(int I=0;i<n;i++)
#define int long long
using namespace std;
int dp[11][2001],n,K,a1,a2;
vector<int>v[11];
main(){
cin>>n>>K;
r(i,n){
cin>>a1>>a2;
v[a2-1].push_back(a1);
}
r(i,10){
sort(v[i].begin(),v[i].end(),greater<int>());
r(j,v[i].size())if(j)v[i][j]+=v[i][j-1]+j;
}
r(i,10){r(j,K+1)
for(int k=0;k<v[i].size();k++){
dp[i+1][k+j+1]=max(dp[i+1][k+j+1],dp[i][j]+v[i][k]);
}
dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
}
cout<<dp[10][K]<<endl;
} | a.cc:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
7 | main(){
| ^~~~
a.cc: In function 'int main()':
a.cc:21:13: error: 'j' was not declared in this scope
21 | dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
| ^
|
s836737725 | p00484 | C++ | #include<bits/stdc++.h>
#define r(I,n) for(int I=0;i<n;i++)
#define int long long
using namespace std;
int dp[11][2001],n,K,a1,a2;
vector<int>v[11];
main(){
cin>>n>>K;
r(i,n){
cin>>a1>>a2;
v[a2-1].push_back(a1);
}
r(i,10){
sort(v[i].begin(),v[i].end(),greater<int>());
r(j,v[i].size())if(j)v[i][j]+=v[i][j-1]+j;
}
r(i,10){r(j,K+1){
for(int k=0;k<v[i].size();k++){
dp[i+1][k+j+1]=max(dp[i+1][k+j+1],dp[i][j]+v[i][k]);
}
dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
}
cout<<dp[10][K]<<endl;
} | a.cc:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
7 | main(){
| ^~~~
a.cc: In function 'int main()':
a.cc:24:2: error: expected '}' at end of input
24 | }
| ^
a.cc:7:7: note: to match this '{'
7 | main(){
| ^
|
s760199437 | p00484 | C++ | int main(){
int n,k;
cin>>n>>k;
int c,g,dp[2001];
vector<int> bks[11];
for(int i=0;i<n;++i){
cin>>c>>g;
bks[g-1].push_back(c);
}
for(int i=0;i<10;++i){
sort(bks[i].begin(),bks[i].end(),greater<int>());
}
memset(dp,-1,sizeof(dp));
dp[0]=0;
for(int i=0;i<10;++i){
if(bks[i].empty()) continue;
for(int j=k-1;j>=0;--j){
if(dp[j]==-1) continue;
int sum=0;
for(int l=0;l<bks[i].size()&&j+l<k;++l){
sum +=bks[i][l];
dp[j+l+1]=max(dp[j+l+1],dp[j]+sum+(l+1)*l);
}
}
}
cout<<dp[k]<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:3:5: error: 'cin' was not declared in this scope
3 | cin>>n>>k;
| ^~~
a.cc:5:5: error: 'vector' was not declared in this scope
5 | vector<int> bks[11];
| ^~~~~~
a.cc:5:12: error: expected primary-expression before 'int'
5 | vector<int> bks[11];
| ^~~
a.cc:8:9: error: 'bks' was not declared in this scope
8 | bks[g-1].push_back(c);
| ^~~
a.cc:11:14: error: 'bks' was not declared in this scope
11 | sort(bks[i].begin(),bks[i].end(),greater<int>());
| ^~~
a.cc:11:42: error: 'greater' was not declared in this scope
11 | sort(bks[i].begin(),bks[i].end(),greater<int>());
| ^~~~~~~
a.cc:11:50: error: expected primary-expression before 'int'
11 | sort(bks[i].begin(),bks[i].end(),greater<int>());
| ^~~
a.cc:11:9: error: 'sort' was not declared in this scope; did you mean 'short'?
11 | sort(bks[i].begin(),bks[i].end(),greater<int>());
| ^~~~
| short
a.cc:13:5: error: 'memset' was not declared in this scope
13 | memset(dp,-1,sizeof(dp));
| ^~~~~~
a.cc:1:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
+++ |+#include <cstring>
1 | int main(){
a.cc:16:12: error: 'bks' was not declared in this scope
16 | if(bks[i].empty()) continue;
| ^~~
a.cc:20:27: error: 'bks' was not declared in this scope
20 | for(int l=0;l<bks[i].size()&&j+l<k;++l){
| ^~~
a.cc:22:27: error: 'max' was not declared in this scope
22 | dp[j+l+1]=max(dp[j+l+1],dp[j]+sum+(l+1)*l);
| ^~~
a.cc:26:5: error: 'cout' was not declared in this scope
26 | cout<<dp[k]<<endl;
| ^~~~
a.cc:26:18: error: 'endl' was not declared in this scope
26 | cout<<dp[k]<<endl;
| ^~~~
|
s006189977 | p00484 | C++ | #include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int n, k;
vector<int> c[10];
int memo[10][5000];
int calc(int g, int b)
{
int ret = 0;
if(b == 0) return 0;
if(g == 0) {
for(int i = 0; i < b; ++i)
ret += c[g][i];
return ret;
}
if(memo[b][g] != -1)
return memo[b][g];
int sum = 0;
ret = calc(g - 1, b);
for(int i = 1; i <= b; ++i) {
sum += [i - 1];
ret = max(ret, sum + calc(g - 1, b - i));
}
return memo[b][g] = ret;
}
int main()
{
memset(memo, -1, sizeof(memo));
scanf("%d%d", &n, &k);
for(int i = 0; i < 10; ++i) c[i].reserve(n);
for(int i = 0; i < n; ++i) {
int tc, tg;
scanf("%d%d", &tc, &tg);
c[tg - 1].push_back(tc);
}
for(int i = 0; i < 10; ++i) {
sort(c[i].rbegin(), c[i].rend());
for(int j = 1; j < c[i].size(); ++j)
c[j] += (2 * (j + 1) - 2);
}
return 0;
} | a.cc: In function 'int calc(int, int)':
a.cc:30:26: error: expected ',' before '-' token
30 | sum += [i - 1];
| ^~
| ,
a.cc:30:27: error: expected identifier before '-' token
30 | sum += [i - 1];
| ^
a.cc: In lambda function:
a.cc:30:31: error: expected '{' before ';' token
30 | sum += [i - 1];
| ^
a.cc: In function 'int calc(int, int)':
a.cc:30:21: error: no match for 'operator+=' (operand types are 'int' and 'calc(int, int)::<lambda()>')
30 | sum += [i - 1];
| ~~~~^~~~~~~~~~
a.cc: In function 'int main()':
a.cc:40:9: error: 'memset' was not declared in this scope
40 | memset(memo, -1, sizeof(memo));
| ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include <algorithm>
+++ |+#include <cstring>
4 | using namespace std;
a.cc:54:30: error: no match for 'operator+=' (operand types are 'std::vector<int>' and 'int')
54 | c[j] += (2 * (j + 1) - 2);
| ~~~~~^~~~~~~~~~~~~~~~~~~~
|
s370617134 | p00484 | C++ | #include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
using namespace std;
int n, k;
vector<int> c[10];
int memo[10][5000];
int calc(int g, int b)
{
int ret = 0;
if(b == 0) return 0;
if(g == 0) {
for(int i = 0; i < b; ++i)
ret += c[g][i];
return ret;
}
if(memo[b][g] != -1)
return memo[b][g];
int sum = 0;
ret = calc(g - 1, b);
for(int i = 1; i <= b; ++i) {
sum += c[i - 1];
ret = max(ret, sum + calc(g - 1, b - i));
}
return memo[b][g] = ret;
}
int main()
{
memset(memo, -1, sizeof(memo));
scanf("%d%d", &n, &k);
for(int i = 0; i < 10; ++i) c[i].reserve(n);
for(int i = 0; i < n; ++i) {
int tc, tg;
scanf("%d%d", &tc, &tg);
c[tg - 1].push_back(tc);
}
for(int i = 0; i < 10; ++i) {
sort(c[i].rbegin(), c[i].rend());
for(int j = 1; j < c[i].size(); ++j)
c[i][j] += (2 * (j + 1) - 2);
}
return 0;
} | a.cc: In function 'int calc(int, int)':
a.cc:31:21: error: no match for 'operator+=' (operand types are 'int' and 'std::vector<int>')
31 | sum += c[i - 1];
| ~~~~^~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:41:9: error: 'memset' was not declared in this scope
41 | memset(memo, -1, sizeof(memo));
| ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
4 | #include <algorithm>
+++ |+#include <cstring>
5 | using namespace std;
|
s779201788 | p00484 | C++ | #include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define reps(i,j,n) for(int i = j ; i < n ; ++i)
#define rep(i,n) reps(i,0,n)
vector<int> book[10];
int dp[11][2001],n,k;
int solve(int ct,int ja){
if(ct >= k || ja > 10) return 0;
if(dp[ja][ct]!=-1) return dp[ja][ct];
int res = solve(ct,ja+1),sum = 0;
rep(i,min(k-ct,(int)book[ja].size())){
sum += book[ja][i];
res = max(res,solve(ct+i+1,ja+1) + sum + i*(i+1));
}
return dp[ja][ct] = res;
} | /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
|
s842135010 | p00484 | C++ | #include <iostream>
#include <numeric>
#include <algorithm>
#include <functional>
#include <vector>
using namespace std;
int N, K;
vector<int> books[16];
int memo[16][2048];
int rec(int i, int used)
{
if(memo[i][used] != -1) return memo[i][used];
if(i == N) return 0;
int best = 0;
for(int t = 0; t < books[i].size() && used + t <= K; t++) {
int cost = accumulate(books[i].begin(), books[i].begin() + t, 0) + (t - 1) * t;
best = max(best, rec(i+1, used + t) + cost);
}
return memo[i][used] = best;
}
int main()
{
memset(memo, -1, sizeof memo); // memoを全て-1で初期化 この関数は-1以外では0でしか初期化出来ないので注意
cin >> N >> K;
for(int i = 0; i < N; i++) {
int C, G;
cin >> C >> G;
books[G-1].push_back(C);
}
for(int i = 0; i < 10; i++) {
sort(books[i].begin(), books[i].end(), greater<int>());
}
cout << rec(0, 0) << endl;
} | a.cc: In function 'int main()':
a.cc:32:3: error: 'memset' was not declared in this scope
32 | memset(memo, -1, sizeof memo); // memoを全て-1で初期化 この関数は-1以外では0でしか初期化出来ないので注意
| ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
4 | #include <functional>
+++ |+#include <cstring>
5 | #include <vector>
|
s987152016 | p00484 | C++ | include <iostream>
#include <map>
#include <algorithm>
#define fr first
#define sc second
using namespace std;
int n,k;
typedef pair<int,int> P;
int dp[2001][11];
P book[2001];
int rec(int idx,int sta){
if(idx == n) return 0;
if(dp[idx][sta]) return dp[idx][sta];
int res = 0;
if(sta < k) res = rec(idx+1,sta+1) + book[idx].fr + (sta-1)*(sta-2);
res = max(res,rec(idx+1,sta));
return dp[idx][sta] = res;
}
int main(){
cin >> n >> k;
for(int i=0;i<n;i++) cin >> book[i].fr >> book[i].sc;
cout << rec(0,0)-1 << endl;
} | a.cc:1:1: error: 'include' does not name a type
1 | include <iostream>
| ^~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:62,
from /usr/include/c++/14/bits/stl_tree.h:63,
from /usr/include/c++/14/map: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 | st |
s061904905 | p00484 | C++ | #include<iostream>
#include<vector>
#include<functional>
using namespace std;
int main(){
int N,K,C,G,dp[11][2001]={};
vector<int> type[10],price[10];
cin>>N>>K;
for(int i=0;i<N;i++){
cin>>C>>G;
type[--G].push_back(C);
// cout<<type[G][i]<<endl;
}
for(int i=0;i<10;i++){
sort(type[i].begin(),type[i].end(),greater<int>());
int sum=0;
price[i].push_back(0);
for(int j=0;j<type[i].size;j++){
sum+=type[i][j];
price[i].push_back(sum+j*(j+1));
}
}
for(int i=0;i<10;i++){
for(int j=0;j<prise[i].size();j++){
for(int k=0;k+j<=K;k++){
dp[i+1][k+j]=j?max(dp[i][k]+price[i][j],dp[i+1][k+j]:dp[i][k+1])
}
}
}
cout<<dp[10][K]<<endl;
} | a.cc: In function 'int main()':
a.cc:17:5: error: 'sort' was not declared in this scope; did you mean 'short'?
17 | sort(type[i].begin(),type[i].end(),greater<int>());
| ^~~~
| short
a.cc:20:27: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = int; _Alloc = std::allocator<int>; size_type = long unsigned int]' (did you forget the '()' ?)
20 | for(int j=0;j<type[i].size;j++){
| ~~~~~~~~^~~~
| ()
a.cc:26:19: error: 'prise' was not declared in this scope; did you mean 'price'?
26 | for(int j=0;j<prise[i].size();j++){
| ^~~~~
| price
a.cc:28:60: error: expected ')' before ':' token
28 | dp[i+1][k+j]=j?max(dp[i][k]+price[i][j],dp[i+1][k+j]:dp[i][k+1])
| ~ ^
| )
a.cc:28:72: error: expected ':' before '}' token
28 | dp[i+1][k+j]=j?max(dp[i][k]+price[i][j],dp[i+1][k+j]:dp[i][k+1])
| ^
| :
29 | }
| ~
a.cc:29:7: error: expected primary-expression before '}' token
29 | }
| ^
|
s454425200 | p00484 | C++ | #include<iostream>
#include<queue>
using namespace std;
int N,K;
priority_queue<int,vector<int>,greater<int>> book[11]; //book[i]には、ジャンルiの本の価格が昇順で入っている。
int size[11] = {0};
int main(){
int i,j;
int data,topic;
int sum = 0;
cin >> N >> K;
for(i = 0;i < N;i++){
cin >> data >> topic;
sum += data;
book[topic].push(data);
size[topic]++;
}
//付加価値を足す。(本の値段は素のまま)
for(i = 0;i < 11;i++){
if(size[i] > 1)
sum += (size[i]-1)*size[i];
}
//cout << sum << endl;
//のこす本を選ぶ
for(i = 0;i < N-K;i++){
for(j = 0;j < 11;j++){
//在庫があったら
if(size[j] != 0){
//とる本の候補のジャンルと値段をそれに初期化し、探索開始
topic = j; //選ぶ本
data = book[topic].top()+2*size[j]-2; //本を取った時の損失
break;
}
}
for(;j < 11;j++){
if(size[j] == 0)
continue;
if(book[j].top()+2*size[j]-2 < data){
topic = j; //選ぶ本
data = book[topic].top()+2*size[j]-2; //本を取った時の損失
}
}
sum -= data;
book[topic].pop();
size[topic]--;
}
cout << sum << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:18:17: error: reference to 'size' is ambiguous
18 | size[topic]++;
| ^~~~
In file included from /usr/include/c++/14/string:53,
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/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:7:5: note: 'int size [11]'
7 | int size[11] = {0};
| ^~~~
a.cc:22:20: error: reference to 'size' is ambiguous
22 | if(size[i] > 1)
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:7:5: note: 'int size [11]'
7 | int size[11] = {0};
| ^~~~
a.cc:23:33: error: reference to 'size' is ambiguous
23 | sum += (size[i]-1)*size[i];
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:7:5: note: 'int size [11]'
7 | int size[11] = {0};
| ^~~~
a.cc:23:44: error: reference to 'size' is ambiguous
23 | sum += (size[i]-1)*size[i];
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:7:5: note: 'int size [11]'
7 | int size[11] = {0};
| ^~~~
a.cc:30:28: error: reference to 'size' is ambiguous
30 | if(size[j] != 0){
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:7:5: note: 'int size [11]'
7 | int size[11] = {0};
| ^~~~
a.cc:33:60: error: reference to 'size' is ambiguous
33 | data = book[topic].top()+2*size[j]-2; //本を取った時の損失
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:7:5: note: 'int size [11]'
7 | int size[11] = {0};
| ^~~~
a.cc:38:28: error: reference to 'size' is ambiguous
38 | if(size[j] == 0)
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:7:5: note: 'int size [11]'
7 | int size[11] = {0};
| ^~~~
a.cc:40:44: error: reference to 'size' is ambiguous
40 | if(book[j].top()+2*size[j]-2 < data){
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:7:5: note: 'int size [11]'
7 | int size[11] = {0};
| ^~~~
a.cc:42:60: error: reference to 'size' is ambiguous
42 | data = book[topic].top()+2*size[j]-2; //本を取った時の損失
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:7:5: note: 'int size [11]'
7 | int size[11] = {0};
| ^~~~
a.cc:47:17: error: reference to 'size' is ambiguous
47 | size[topic]--;
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:7:5: note: 'int size [11]'
7 | int size[11] = {0};
| ^~~~
|
s972611872 | p00484 | C++ | #include<iostream>
#include<queue>
using namespace std;
int N,K;
//book[i]には、ジャンルiの本の価格が昇順で入っている。
priority_queue<int,vector<int>,greater<int>> book[11];
int size[11] = {0};
int main(){
int i,j;
int data,topic;
int sum = 0;
cin >> N >> K;
for(i = 0;i < N;i++){
cin >> data >> topic;
sum += data;
book[topic].push(data);
size[topic]++;
}
//付加価値を足す。(本の値段は素のまま)
for(i = 0;i < 11;i++){
if(size[i] > 1)
sum += (size[i]-1)*size[i];
}
//cout << sum << endl;
//のこす本を選ぶ
for(i = 0;i < N-K;i++){
for(j = 0;j < 11;j++){
//在庫があったら
if(size[j] != 0){
//とる本の候補のジャンルと値段をそれに初期化し、探索開始
//選ぶ本
topic = j;
//本を取った時の損失
data = book[topic].top()+2*size[j]-2;
break;
}
}
for(;j < 11;j++){
if(size[j] == 0)
continue;
if(book[j].top()+2*size[j]-2 < data){
topic = j;
data = book[topic].top()+2*size[j]-2;
}
}
sum -= data;
book[topic].pop();
size[topic]--;
}
cout << sum << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:19:17: error: reference to 'size' is ambiguous
19 | size[topic]++;
| ^~~~
In file included from /usr/include/c++/14/string:53,
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/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:8:5: note: 'int size [11]'
8 | int size[11] = {0};
| ^~~~
a.cc:23:20: error: reference to 'size' is ambiguous
23 | if(size[i] > 1)
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:8:5: note: 'int size [11]'
8 | int size[11] = {0};
| ^~~~
a.cc:24:33: error: reference to 'size' is ambiguous
24 | sum += (size[i]-1)*size[i];
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:8:5: note: 'int size [11]'
8 | int size[11] = {0};
| ^~~~
a.cc:24:44: error: reference to 'size' is ambiguous
24 | sum += (size[i]-1)*size[i];
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:8:5: note: 'int size [11]'
8 | int size[11] = {0};
| ^~~~
a.cc:31:28: error: reference to 'size' is ambiguous
31 | if(size[j] != 0){
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:8:5: note: 'int size [11]'
8 | int size[11] = {0};
| ^~~~
a.cc:36:60: error: reference to 'size' is ambiguous
36 | data = book[topic].top()+2*size[j]-2;
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:8:5: note: 'int size [11]'
8 | int size[11] = {0};
| ^~~~
a.cc:41:28: error: reference to 'size' is ambiguous
41 | if(size[j] == 0)
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:8:5: note: 'int size [11]'
8 | int size[11] = {0};
| ^~~~
a.cc:43:44: error: reference to 'size' is ambiguous
43 | if(book[j].top()+2*size[j]-2 < data){
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:8:5: note: 'int size [11]'
8 | int size[11] = {0};
| ^~~~
a.cc:45:60: error: reference to 'size' is ambiguous
45 | data = book[topic].top()+2*size[j]-2;
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:8:5: note: 'int size [11]'
8 | int size[11] = {0};
| ^~~~
a.cc:50:17: error: reference to 'size' is ambiguous
50 | size[topic]--;
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:8:5: note: 'int size [11]'
8 | int size[11] = {0};
| ^~~~
|
s424528314 | p00485 | Java | import java.io.InputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import java.math.BigInteger;
public class Main{
static PrintWriter out;
static InputReader ir;
static void solve(){
int n=ir.nextInt();
int m=ir.nextInt();
int K=ir.nextInt();
int[] a=new int[m],b=new int[m],l=new int[m];
G g=new G(n,true);
for(int i=0;i<m;i++){
a[i]=ir.nextInt()-1;
b[i]=ir.nextInt()-1;
l[i]=ir.nextInt();
g.addEdge(a[i],b[i],l[i]);
}
int[] s=ir.nextIntArray(K);
for(int i=0;i<K;i++) s[i]--;
int[][] d=new int[n][];
for(int i=0;i<n;i++) d[i]=g.dijkstra(i);
int[] md=new int[n];
for(int i=0;i<n;i++){
md[i]=1<<27
for(int j=0;j<K;j++){
md[i]=Math.min(md[i],d[i][s[j]]);
}
}
int ma=0;
for(int i=0;i<n;i++){
for(int j=0;j<g.g[i].size();j++){
ma=Math.max(ma,(int)(md[i]+md[g.to(i,j)]+g.cost(i,j)+1)/2);
}
}
out.println(ma);
}
static class G{
AL[] g,rg;
private int V;
private boolean ndir;
public G(int V,boolean ndir){
this.V=V;
this.ndir=ndir;
g=new AL[V];
for(int i=0;i<V;i++) g[i]=new AL();
}
public void addEdge(int u,int v,int t){
g[u].add(new int[]{v,t});
if(this.ndir) g[v].add(new int[]{u,t});
}
public void addEdge(int u,int v){
addEdge(u,v,0);
}
public int to(int from,int ind){return g[from].get(ind)[0];}
public int cost(int from,int ind){return g[from].get(ind)[1];}
public int size(int from){return g[from].size();}
public int[] dijkstra(int s){
int[] dist=new int[this.V];
java.util.PriorityQueue<int[]> pque=new java.util.PriorityQueue<int[]>(11,new Comparator<int[]>(){
public int compare(int[] a,int[] b){
return Integer.compare(a[0],b[0]);
}
});
Arrays.fill(dist,1<<26);
dist[s]=0;
pque.offer(new int[]{0,s});
while(!pque.isEmpty()){
int[] p=pque.poll();
int v=p[1];
if(dist[v]<p[0]) continue;
for(int i=0;i<g[v].size();i++){
int to=to(v,i),cost=cost(v,i);
if(dist[to]>dist[v]+cost){
dist[to]=dist[v]+cost;
pque.offer(new int[]{dist[to],to});
}
}
}
return dist;
}
public int[] tporder(){
boolean[] vis=new boolean[V];
ArrayList<Integer> ord=new ArrayList<>();
for(int i=0;i<V;i++) if(!vis[i]) ts(i,vis,ord);
int[] ret=new int[V];
for(int i=ord.size()-1;i>=0;i--) ret[ord.size()-1-i]=ord.get(i);
return ret;
}
public int[] scc(){
rg=new AL[V];
for(int i=0;i<V;i++) rg[i]=new AL();
int from,to;
for(int i=0;i<V;i++){
for(int j=0;j<g[i].size();j++){
to=i;
from=to(i,j);
rg[from].add(new int[]{to,0});
}
}
int[] ord=tporder();
int k=0;
boolean[] vis=new boolean[V];
int[] ret=new int[V+1];
for(int i=0;i<V;i++) if(!vis[i]) rs(ord[i],vis,ret,k++);
ret[V]=k;
return ret;
}
private void ts(int now,boolean[] vis,ArrayList<Integer> ord){
vis[now]=true;
int to;
for(int i=0;i<g[now].size();i++){
to=to(now,i);
if(!vis[to]) ts(to,vis,ord);
}
ord.add(now);
}
private void rs(int now,boolean[] vis,int[] ret,int k){
vis[now]=true;
ret[now]=k;
int to;
for(int i=0;i<rg[now].size();i++){
to=rg[now].get(i)[0];
if(!vis[to]) rs(to,vis,ret,k);
}
}
static class AL extends ArrayList<int[]>{};
}
public static void main(String[] args) throws Exception{
ir=new InputReader(System.in);
out=new PrintWriter(System.out);
solve();
out.flush();
}
static class InputReader {
private InputStream in;
private byte[] buffer=new byte[1024];
private int curbuf;
private int lenbuf;
public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}
public boolean hasNextByte() {
if(curbuf>=lenbuf){
curbuf= 0;
try{
lenbuf=in.read(buffer);
}catch(IOException e) {
throw new InputMismatchException();
}
if(lenbuf<=0) return false;
}
return true;
}
private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;}
private boolean isSpaceChar(int c){return !(c>=33&&c<=126);}
private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}
public boolean hasNext(){skip(); return hasNextByte();}
public String next(){
if(!hasNext()) throw new NoSuchElementException();
StringBuilder sb=new StringBuilder();
int b=readByte();
while(!isSpaceChar(b)){
sb.appendCodePoint(b);
b=readByte();
}
return sb.toString();
}
public int nextInt() {
if(!hasNext()) throw new NoSuchElementException();
int c=readByte();
while (isSpaceChar(c)) c=readByte();
boolean minus=false;
if (c=='-') {
minus=true;
c=readByte();
}
int res=0;
do{
if(c<'0'||c>'9') throw new InputMismatchException();
res=res*10+c-'0';
c=readByte();
}while(!isSpaceChar(c));
return (minus)?-res:res;
}
public long nextLong() {
if(!hasNext()) throw new NoSuchElementException();
int c=readByte();
while (isSpaceChar(c)) c=readByte();
boolean minus=false;
if (c=='-') {
minus=true;
c=readByte();
}
long res = 0;
do{
if(c<'0'||c>'9') throw new InputMismatchException();
res=res*10+c-'0';
c=readByte();
}while(!isSpaceChar(c));
return (minus)?-res:res;
}
public double nextDouble(){return Double.parseDouble(next());}
public int[] nextIntArray(int n){
int[] a=new int[n];
for(int i=0;i<n;i++) a[i]=nextInt();
return a;
}
public long[] nextLongArray(int n){
long[] a=new long[n];
for(int i=0;i<n;i++) a[i]=nextLong();
return a;
}
public char[][] nextCharMap(int n,int m){
char[][] map=new char[n][m];
for(int i=0;i<n;i++) map[i]=next().toCharArray();
return map;
}
}
} | Main.java:34: error: ';' expected
md[i]=1<<27
^
1 error
|
s826509371 | p00485 | C++ | #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007
typedef pair<int, int> P;
typedef pair<int, P> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;
int N, M, K;
vector<P> G[4096];
int d[4096];
int main(){
scanf("%d%d%d",&N,&M,&K);
int a, b, l;
rep(i,M){
scanf("%d%d%d",&a,&b,&l); a--; b--;
G[a].push_back(P(b, l));
G[b].push_back(P(a, l));
}
priority_queue<P, vector<P>, greater<P> >q;
int s;
fill(d, d+N, INF);
rep(i,K){
scanf("%d", &s); s--;
d[s] = 0;
q.push(P(0, s));
}
/* rep(i, N){
rep(j, G[i].size()) printf("%d %d ", G[i][j].first, G[i][j].second);
cout << endl;
}*/
while(!q.empty()){
int cur = q.top().second, v = q.top().first;
q.pop();
// cout << "cur " << cur << "v " << v << endl;
if(v > d[cur]) continue;
rep(i, G[cur].size()){
P next = G[cur][i];
// cout << next.first << " " << d[next.first] << endl;
if(d[next.first] > next.second + v){
d[next.first] = next.second + v;
q.push(P(d[next.first], next.first));
}
}
}
int res = 0;
rep(i, N) if(d[i]!=INF) res = max(res, d[i]);
// rep(i, N) printf("%d ", d[i]); puts("");
// printf("%d\n", res);
rep(i, N){
rep(j, G[i].size()){
P p = G[i][j];
res = max(res, (int)((p.second+d[i]+d[p.first])/2.0 + 0.5));
// cout << i << " " << j << " " << res << endl;
}
}
printf("%d\n", res);
return 0;
} | a.cc:1:1: error: stray '\20' in program
1 | <U+0010>#include <iostream>
| ^~~~~~~~
a.cc:1:2: error: stray '#' in program
1 | #include <iostream>
| ^
a.cc:1:3: error: 'include' does not name a type
1 | #include <iostream>
| ^~~~~~~
In file included from /usr/include/c++/14/cmath:45,
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'
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,
from /usr/include/c++/14/bits/specfun.h:43,
from /usr/include/c++/14/cmath:3906:
/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: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)>
| ^~~~~~
In file included from /usr/include/stdio.h:34,
from /usr/include/c++/14/cstdio:42,
from a.cc:2:
/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_algobase.h:65:
/usr/include/c++/14/bits/stl_iterator_base_types.h:125:67: error: 'ptrdiff_t' does not name a type
125 | template<typename _Category, typename _Tp, typename _Distance = ptrdiff_t,
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:1:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
+++ |+#include <cstddef>
1 | // Types used in iterator implementation -*- C++ -*-
/usr/include/c++/14/bits/stl_iterator_base_types.h:214:15: error: 'ptrdiff_t' does not name a type
214 | typedef ptrdiff_t difference_type;
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:214:15: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/bits/stl_iterator_base_types.h:225:15: error: 'ptrdiff_t' does not name a type
225 | typedef ptrdiff_t difference_type;
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:225:15: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
In file included from /usr/include/c++/14/bits/stl_algobase.h:66:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:112:5: error: 'ptrdiff_t' does not name a type
112 | ptrdiff_t
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:66:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
65 | #include <debug/assertions.h>
+++ |+#include <cstddef>
66 | #include <bits/stl_iterator_base_types.h>
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:118:5: error: 'ptrdiff_t' does not name a type
118 | ptrdiff_t
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:118:5: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
In file inc |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.