Submission #1232868

#TimeUsernameProblemLanguageResultExecution timeMemory
1232868m5588ohammedSoccer Stadium (IOI23_soccer)C++20
Compilation error
0 ms0 KiB
#include "soccer.h" #include <bits/stdc++.h> using namespace std; int arr[2001][2001],vis[2001][2001],n; bool valid(int i,int j){ if(i>=n||j>=n||i<0||j<0||arr[i][j]==1||vis[i][j]==1) return 0; return 1; } void dfs(int i,int j){ vis[i][j]=1; if(valid(i+1,j)==1) dfs(i+1,j); if(valid(i-1,j)==1) dfs(i-1,j); if(valid(i,j+1)==1) dfs(i,j+1); if(valid(i,j-1)==1) dfs(i,j-1); return; } int biggest_stadium(int N, std::vector<std::vector<int>> F) { n=N; int cnt=0,siz=0; vector <array<int,2>> v; for(int i=0;i<n;i++){ for(int j=0;j<n;j++) arr[i][j]=F[i][j]; } for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(arr[i][j]==1) if(valid(i-1,j)+valid(i+1,j)==2||valid(i,j-1)+valid(i,j+1)==2) return -1; } } } for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(vis[i][j]==0){ cnt++; dfs(i,j); } if(arr[i][j]==1) v.push_back({i,j}); else siz++; } } if(cnt>1) return -1; for(auto [i1,j1]:v){ for(auto [i2,j2]:v){ if(arr[i1][j1]!=1||arr[i2][j1]!=1) return -1; } } return siz; }

Compilation message (stderr)

soccer.cpp:32:5: error: expected unqualified-id before 'for'
   32 |     for(int i=0;i<n;i++){
      |     ^~~
soccer.cpp:32:17: error: 'i' does not name a type
   32 |     for(int i=0;i<n;i++){
      |                 ^
soccer.cpp:32:21: error: 'i' does not name a type
   32 |     for(int i=0;i<n;i++){
      |                     ^
soccer.cpp:42:5: error: expected unqualified-id before 'if'
   42 |     if(cnt>1) return -1;
      |     ^~
soccer.cpp:43:5: error: expected unqualified-id before 'for'
   43 |     for(auto [i1,j1]:v){
      |     ^~~
soccer.cpp:48:5: error: expected unqualified-id before 'return'
   48 |     return siz;
      |     ^~~~~~
soccer.cpp:49:1: error: expected declaration before '}' token
   49 | }
      | ^
soccer.cpp: In function 'int biggest_stadium(int, std::vector<std::vector<int> >)':
soccer.cpp:31:5: warning: control reaches end of non-void function [-Wreturn-type]
   31 |     }
      |     ^