| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1016881 | vjudge1 | Arranging Shoes (IOI19_shoes) | C++17 | 1079 ms | 1048576 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "shoes.h"
#include <bits/stdc++.h>
using namespace std;
bool check(vector<int> &x){
for(int i = 1; i < x.size(); i += 2){
if((x[i-1] < x[i]) && (x[i-1]*-1 == x[i])) continue;
else return false;
}
return true;
}
vector<vector<int>> moves(vector<int> &a){
vector<vector<int>> ans;
for(int i = 1; i < a.size(); ++i){
vector<int> temp(a.begin(), a.end());
swap(temp[i-1], temp[i]);
ans.push_back(temp);
}
return ans;
}
long long bfs(vector<int> &src){
//set<vector<int>> visited;
map<vector<int>, bool> visited;
map<vector<int>, long long> dist;
queue<vector<int>> q;
//visited.insert(src);
visited[src] = true;
dist[src] = 0;
q.push(src);
while(!q.empty()){
vector<int> act = q.front(); q.pop();
if(check(act)) return dist[act];
for(auto &move : moves(act)){
if(visited[move]) continue;
dist[move] = dist[act] + 1;
visited[move] = true;
q.push(move);
if(check(move)) return dist[move];
}
}
}
long long count_swaps(std::vector<int> s) {
return bfs(s);
//long long ans = 0;
//for(int i = 1; i < s.size()/2; ++i) ans += i;
//return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | 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... | ||||
