이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i, n) for (int i = 0; i < n; i++)
#define rfo(i, n) for (int i = n - 1; i >= 0; i--)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = a; i >= b; i--)
#define ll long long
#define si(x) scanf("%d", &x)
#define sl(x) scanf("%lld", &x)
#define ss(s) scanf("%s", s)
#define pi(x) printf("%d\n", x)
#define pl(x) printf("%lld\n", x)
#define ps(s) printf("%s\n", s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define deb3(x, y, z) cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pl> vpl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
int mpow(int base, int exp);
void dfs(int u, int par);
const int mod = 1'000'000'007;
const int N = 3e5, M = N;
vi g[N];
int a[N], ans[N];
void solve()
{
int n, m;
cin >> n >> m;
vpii times(m);
fo(i, m) cin >> times[i].F;
fo(i, m) cin >> times[i].S;
set<pii> inditimes;
fo(i, m) inditimes.insert(times[i]);
vector<vvi> dp(101, vvi(n + 100, vi(n + 100)));
vi dx = {-1, -1, -1, 0, 0, 1, 1, 1}, dy = {-1, 0, 1, -1, 1, -1, 0, 1};
sortall(times);
bool one = true;
REP(i, 1, m)
{
if (times[i].F - times[i - 1].F < abs(times[i].S - times[i - 1].S))
one = false;
}
int ans = 0;
REP(t, 1, 101)
{
REP(a, 1, n + 1)
{
REP(b, 1, n + 1)
{
if (a == b)
continue;
fo(i, dx.size())
{
int na = a + dx[i], nb = b + dy[i];
dp[t][a][b] = max(dp[t][a][b], dp[t - 1][na][nb]);
}
dp[t][a][b] += (inditimes.find({t, a}) != inditimes.end());
dp[t][a][b] += (inditimes.find({t, b}) != inditimes.end());
ans = max(ans, dp[t][a][b]);
}
}
}
if (one)
{
cout << 1 << '\n';
}
else if (ans == m)
cout << 2 << '\n';
else
cout << 3 << '\n';
return;
}
int main()
{
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
srand(chrono::high_resolution_clock::now().time_since_epoch().count());
int t = 1;
int cs = 0;
while (t - cs)
{
solve();
cs++;
}
return 0;
}
int mpow(int base, int exp)
{
base %= mod;
int result = 1;
while (exp > 0)
{
if (exp & 1)
result = ((ll)result * base) % mod;
base = ((ll)base * base) % mod;
exp >>= 1;
}
return result;
}
void ipgraph(int n, int m)
{
int u, v;
while (m--)
{
cin >> u >> v;
u--, v--;
g[u].pb(v);
g[v].pb(u);
}
}
void dfs(int u, int par)
{
for (int v : g[u])
{
if (v == par)
continue;
dfs(v, u);
}
}
컴파일 시 표준 에러 (stderr) 메시지
Arcade.cpp: In function 'void solve()':
Arcade.cpp:5:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
5 | #define fo(i, n) for (int i = 0; i < n; i++)
......
74 | fo(i, dx.size())
| ~~~~~~~~~~~~
Arcade.cpp:74:17: note: in expansion of macro 'fo'
74 | fo(i, dx.size())
| ^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |