QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#365070#5514. Mazeksu_#Compile Error//C++203.2kb2024-03-24 19:02:192024-07-04 03:31:17

Judging History

你现在查看的是最新测评结果

  • [2024-07-04 03:31:17]
  • 评测
  • [2024-03-24 19:02:19]
  • 提交

answer

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,sse3")
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <bitset>
#include <cstring>
#include <unordered_map>

using namespace std;
typedef int ll;

#define endl '\n'
typedef pair<ll, pair<ll, ll>> pll;

deque<pll> q;
ll n, r, c;
ll s1, s2, f1, f2;

void check(int x, int y, int d, vector<vector<ll>> &dist, vector<string> &a, vector<set<ll>> &st, set<ll> &row){
    if(x >= 1 && y >= 1 && x <= r && y <= c && d < dist[x][y] && a[x][y] == '.'){
        dist[x][y] = d;
        q.push_front({d, {x, y}});
        st[x].erase(y);
        
        if(f1 == x && f2 == y){
            cout << d << endl;
            exit(0);
        }
        
        if(st[x].empty())
            row.erase(x);
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    cin >> r >> c >> n;
    
    cin >> s1 >> s2 >> f1 >> f2;
    
    vector<string> a(r + 1);
    for(int i = 1; i <= r; i++){
        cin >> a[i];
        
        a[i] = "#" + a[i];
    }
    
    vector<set<ll>> st(r + 1);
    
    set<ll> row;
    for(int i = 1; i <= r; i++){
        for(int j = 1; j <= c; j++){
            if(i != s1 || j != s2)
                st[i].insert(j);
        }
        
        if(!st[i].empty())
            row.insert(i);
    }
    
    q.push_front({0, {s1, s2}});
    vector<vector<bool>> used(r + 1, vector<bool> (c + 1));
    vector<vector<ll>> dist(r + 1, vector<ll> (c + 1, 1e9));
    
    dist[s1][s2] = 0;
    vector<int> roll, roll2;
    ll x2 = 0;
    
    while(!q.empty()){
        auto v = q.front();
        q.pop_front();
        
        int x = v.second.first, y = v.second.second;
        if(used[x][y])
            continue;
        
        if(x == f1 && y == f2)
            break;
        
        used[x][y] = 1;
        check(x - 1, y, v.first, dist, a, st, row);
        check(x + 1, y, v.first, dist, a, st, row);
        check(x, y - 1, v.first, dist, a, st, row);
        check(x, y + 1, v.first, dist, a, st, row);
        
        auto p = row.lower_bound(x - n);
        
        while(p != row.end() && (*p) <= x + n){
            x2 = *p;
            auto u = st[x2].lower_bound(y - n);
            
            roll.clear();
            while(u != st[x2].end() && (*u) <= y + n){
                if((abs(x2 - x) < n || abs(y - *u) < n) && v.first + 1 < dist[x2][(*u)]){
                    dist[x2][*u] = v.first + 1;
                    q.push_back({v.first + 1, {x2, *u}});
                    
                    roll.push_back(*u);
                }
                u++;
            }
            
            for(auto i: roll){
                st[x2].erase(i);
            }
            if(st[x2].empty())
                roll2.push_back(x2);
            p++;
        }
        
        for(auto i: roll2)
            row.erase(i);
        roll2.clear();
    }
    
    cout << dist[f1][f2] << endl;
    
    return 0;
}

詳細信息

In file included from /usr/include/c++/13/string:43,
                 from /usr/include/c++/13/bits/locale_classes.h:40,
                 from /usr/include/c++/13/bits/ios_base.h:41,
                 from /usr/include/c++/13/ios:44,
                 from /usr/include/c++/13/ostream:40,
                 from /usr/include/c++/13/iostream:41,
                 from answer.code:3:
/usr/include/c++/13/bits/allocator.h: In destructor ‘constexpr std::__cxx11::basic_string<char>::_Alloc_hider::~_Alloc_hider()’:
/usr/include/c++/13/bits/allocator.h:184:7: error: inlining failed in call to ‘always_inline’ ‘constexpr std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = char]’: target specific option mismatch
  184 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/13/string:54:
/usr/include/c++/13/bits/basic_string.h:181:14: note: called from here
  181 |       struct _Alloc_hider : allocator_type // TODO check __is_final
      |              ^~~~~~~~~~~~