QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#749203 | #8236. Snake Move | return_myself | Compile Error | / | / | C++20 | 4.8kb | 2024-11-14 23:02:33 | 2024-11-14 23:02:34 |
Judging History
answer
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
#pragma GCC optimize(1)
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#include <iostream>
#include <math.h>
#include <algorithm>
#include <stdlib.h>
#include <iomanip>
#include <cstring>
#include <stdio.h>
#include <vector>
#include <queue>
#include <map>
#include <time.h>
#include <stack>
#include <unordered_map>
#include <random>
#include <string>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define fi first
#define se second
ll const inf = 2e18;
ll const mod = 998244353;
ll n, m, T;
ll k;
ll x[100005],y[100005];
ll val[3005][3005];//多长时间可以到该位置(必须为身子处)
ll a[3005][3005];//0:空格 1:墙 2:身子
ll dp[3005][3005];
ll vis[3005][3005];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int T = 1;
//cin >> T;
while (T--)
{
cin >> n >> m >> k;
for (int i = k; i >= 1; --i)
{
cin >> x[i] >> y[i];
a[x[i]][y[i]] = 2;
val[x[i]][y[i]] = i;
}
for (int i = 1; i <= n; ++i)
{
for (int j = 1; j <= m; ++j)
{
dp[i][j] = inf;
char turn;
cin >> turn;
if (a[i][j] < 2)
{
a[i][j] = (turn == '#');
}
}
}
dp[x[k]][y[k]] = 0;
priority_queue <pair<ll, pair<ll, ll>>, vector <pair<ll, pair<ll, ll>>>, greater<pair<ll, pair<ll, ll>>>> pq;
pq.push(make_pair(0, make_pair(x[k], y[k])));
while (!pq.empty())
{
auto tp = pq.top();
pq.pop();
ll x1 = tp.se.fi, y1 = tp.se.se;
if (vis[x1][y1])
continue;
vis[x1][y1] = 1;
ll nx = x1 + 1, ny = y1, nlen;
if (1 <= nx && nx <= n && 1 <= ny && ny <= m && a[nx][ny] != 1)
{
if ((nlen = max(dp[x1][y1] + 1, (a[nx][ny] ? val[nx][ny] : 0))) < dp[nx][ny])
{
dp[nx][ny] = nlen;
pq.push(make_pair(nlen, make_pair(nx, ny)));
}
}
nx = x1 - 1, ny = y1;
if (1 <= nx && nx <= n && 1 <= ny && ny <= m && a[nx][ny] != 1)
{
if ((nlen = max(dp[x1][y1] + 1, (a[nx][ny] ? val[nx][ny] : 0))) < dp[nx][ny])
{
dp[nx][ny] = nlen;
pq.push(make_pair(nlen, make_pair(nx, ny)));
}
}
nx = x1, ny = y1 + 1;
if (1 <= nx && nx <= n && 1 <= ny && ny <= m && a[nx][ny] != 1)
{
if ((nlen = max(dp[x1][y1] + 1, (a[nx][ny] ? val[nx][ny] : 0))) < dp[nx][ny])
{
dp[nx][ny] = nlen;
pq.push(make_pair(nlen, make_pair(nx, ny)));
}
}
nx = x1, ny = y1 - 1;
if (1 <= nx && nx <= n && 1 <= ny && ny <= m && a[nx][ny] != 1)
{
if ((nlen= max(dp[x1][y1] + 1, (a[nx][ny] ? val[nx][ny] : 0))) < dp[nx][ny])
{
dp[nx][ny] = nlen;
pq.push(make_pair(nlen, make_pair(nx, ny)));
}
}
}
unsigned long long ans = 0;
for (int i = 1; i <= n; ++i)
{
for (int j = 1; j <= m; ++j)
{
if (dp[i][j] < inf)
{
ans += 1ull * dp[i][j] * dp[i][j];
}
}
}
cout << ans << '\n';
}
return 0;
}
詳細信息
answer.code:25:39: warning: bad option ‘-fwhole-program’ to pragma ‘optimize’ [-Wpragmas] 25 | #pragma GCC optimize("-fwhole-program") | ^ answer.code:32:41: warning: bad option ‘-fstrict-overflow’ to pragma ‘optimize’ [-Wpragmas] 32 | #pragma GCC optimize("-fstrict-overflow") | ^ answer.code:34:41: warning: bad option ‘-fcse-skip-blocks’ to pragma ‘optimize’ [-Wpragmas] 34 | #pragma GCC optimize("-fcse-skip-blocks") | ^ answer.code:47:51: warning: bad option ‘-funsafe-loop-optimizations’ to pragma ‘optimize’ [-Wpragmas] 47 | #pragma GCC optimize("-funsafe-loop-optimizations") | ^ In file included from /usr/include/x86_64-linux-gnu/c++/13/bits/gthr.h:148, from /usr/include/c++/13/ext/atomicity.h:35, from /usr/include/c++/13/bits/ios_base.h:39, from /usr/include/c++/13/ios:44, from /usr/include/c++/13/ostream:40, from /usr/include/c++/13/iostream:41, from answer.code:49: /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:102:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 102 | __gthrw(pthread_once) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:102:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:103:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 103 | __gthrw(pthread_getspecific) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:103:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:104:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 104 | __gthrw(pthread_setspecific) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:104:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:106:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 106 | __gthrw(pthread_create) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:106:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:107:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 107 | __gthrw(pthread_join) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:107:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:108:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 108 | __gthrw(pthread_equal) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:108:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:109:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 109 | __gthrw(pthread_self) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:109:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:110:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 110 | __gthrw(pthread_detach) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:110:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:112:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 112 | __gthrw(pthread_cancel) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:112:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:114:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 114 | __gthrw(sched_yield) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:114:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:116:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute 116 | __gthrw(pthread_mutex_lock) | ^~~~~~~ /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:116:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/13/bits/gthr-default.h:117:1: error: attribute value ‘t...