답안 #1008086

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1008086 2024-06-26T07:32:20 Z Amr 축구 경기장 (IOI23_soccer) C++17
0 / 100
1 ms 348 KB
#include "soccer.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using namespace std;
#define F first
#define S second
#define sz size()
#define all(x) (x).begin(), (x).end()
const int N = 4;
ll n;
vector<vector<int> > a;
ll prer[N][N], pred[N][N];
ll best = 0;
int good()
{

    vector<pair<ll,ll> > m;
  //  for(int i = 0; i <= n; i++) pre[i][0] = pre[0][i] = 0;
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= n; j++)
        {
            prer[i][j] = prer[i][j-1]+(a[i-1][j-1]==2);
        }
    }
    for(int j = 1; j <= n; j++)
    {
        for(int i = 1; i <= n; i++)
        {
            pred[i][j] = pred[i-1][j]+(a[i-1][j-1]==2);
        }
    }

    for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) if(a[i][j]==2) m.push_back({i,j});

    for(int i = 0; i < m.sz; i++)
    {
        for(int j = i+1; j < m.sz; j++)
        {
            ll x1 = m[i].F , y1 = m[i].S , x2 = m[j].F , y2 = m[j].S;

            x1++,y1++,x2++,y2++;
            //if(mm)
            //cout << x1 << " " << x2 << endl;
            ll cnt = pred[x2-1][y1]-pred[x1-1][y1];
            if(y1<=y2)
            {
                cnt += prer[x2][y2]-prer[x2][y1-1];
            }
            else if(y1>y2)
            {
                cnt+=prer[x2][y1]-prer[x2][y2-1];
            }
            //if(mm) cout << i << " " << j << " " << cnt << endl;
            if(cnt==x2-x1+abs(y1-y2)+1) {} else return 0;

        }
    }
    return 1;
}
void bt(ll x, ll y, ll num)
{
    if(x==n)
    {
        if(good())
        best = max(best,num);
        return;
    }
    if(a[x][y]==1)
    {
        if(y==n-1) bt(x+1,0,num); else bt(x,y+1,num);
    }
    else
    {
        if(y==n-1) bt(x+1,0,num); else bt(x,y+1,num);
        a[x][y] = 2;
        if(y==n-1) bt(x+1,0,num+1); else bt(x,y+1,num+1);
        a[x][y] = 0;
    }
}
int biggest_stadium(int N, std::vector<std::vector<int>> F)
{
    n = N, a = F;
    bt(0,0,0);
    return best;
}

Compilation message

soccer.cpp: In function 'int good()':
soccer.cpp:37:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for(int i = 0; i < m.sz; i++)
      |                      ^
soccer.cpp:39:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         for(int j = i+1; j < m.sz; j++)
      |                            ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB wrong
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB wrong
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -