답안 #1008140

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1008140 2024-06-26T07:57:22 Z Amr 축구 경기장 (IOI23_soccer) C++17
8 / 100
1 ms 436 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 = 5;
ll n;
vector<vector<int> > a;
ll prer[N][N], pred[N][N];
ll best = 0;
bool 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;
            ll cnt2 = pred[x2-1][y2]-pred[x1-1][y2];
            if(y1<=y2)
            {
                cnt2+= prer[x1][y2]-prer[x1][y1-1];
            }
            else

            {
                cnt2+=prer[x1][y1]-prer[x1][y2-1];
            }


            if((cnt==x2-x1+abs(y1-y2)+1)||(cnt2==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);
        //if(num==12&&a[3][3]==0&&a[3][0]==0) cout << good();//for(int i = 0; i < n; i++) {for(int j = 0; j < n; j++) cout << a[i][j] << " "; cout << endl;}
        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)
{
    best = 0;
    n = N, a = F;
    bt(0,0,0);

    return best;
}

Compilation message

soccer.cpp: In function 'bool 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 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB ok
2 Correct 1 ms 348 KB ok
3 Runtime error 1 ms 348 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB ok
2 Correct 1 ms 348 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 0 ms 348 KB ok
5 Correct 0 ms 348 KB ok
6 Correct 0 ms 348 KB ok
7 Correct 0 ms 348 KB ok
8 Correct 1 ms 348 KB ok
9 Correct 1 ms 436 KB ok
10 Correct 1 ms 344 KB ok
11 Correct 0 ms 348 KB ok
12 Correct 0 ms 348 KB ok
13 Correct 0 ms 344 KB ok
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -