# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1064391 | anango | 곤돌라 (IOI14_gondola) | C++17 | 270 ms | 262144 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gondola.h"
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000009;
signed valid(signed n, signed inputSeq[]) {
vector<int> pos(n,-1);
set<int> seen;
for (int i=0; i<n; i++) {
if (inputSeq[i]<=n) {
pos[inputSeq[i]-1] = i;
}
if (seen.count(inputSeq[i]-1)) {
return 0;
}
seen.insert(inputSeq[i]-1);
}
set<int> S;
for (int i=0; i<n; i++) {
if (pos[i]!=-1) {
S.insert((pos[i]-i+n)%n);
}
}
return S.size()<=1;
}
//----------------------
signed replacement(signed n, signed gondolaSeq[], signed replacementSeq[]) {
vector<pair<int,int>> posindex;
vector<int> actual(n,-1);
for (int i=0; i<n; i++) {
if (gondolaSeq[i]<=n) {
for (int j=0; j<n; j++) {
actual[j] = (gondolaSeq[i]-1+j-i+3*n)%n;
}
break;
}
}
if (actual[0]==-1) {
for (int i=0; i<n; i++) actual[i] = i;
}
for (int i=0; i<n; i++) {
//cout << actual[i] <<" ";
}
//cout << endl;
for (int i=0; i<n; i++) {
posindex.push_back({gondolaSeq[i]-1,i});
}
sort(posindex.begin(), posindex.end());
vector<int> repl;
int cur = n;
for (int i=0; i<posindex.size(); i++) {
while (posindex[i].first>=cur) {
repl.push_back(actual[posindex[i].second]);
actual[posindex[i].second] = cur;
cur++;
}
}
for (int i=0; i<repl.size(); i++) {
replacementSeq[i] = repl[i]+1;
}
//cout << "done " << repl.size() << endl;
return repl.size();
}
//----------------------
signed countReplacement(signed n, signed inputSeq[]) {
vector<int> pos(n,-1);
set<int> seen;
for (int i=0; i<n; i++) {
if (inputSeq[i]<=n) {
pos[inputSeq[i]-1] = i;
}
if (seen.count(inputSeq[i]-1)) {
return 0;
}
seen.insert(inputSeq[i]-1);
}
set<int> S;
for (int i=0; i<n; i++) {
if (pos[i]!=-1) {
S.insert((pos[i]-i+n)%n);
}
}
if (S.size()>1) {
return 0;
}
int prod = 1;
vector<pair<int,int>> posindex;
vector<int> actual(n,-1);
for (int i=0; i<n; i++) {
if (inputSeq[i]<=n) {
for (int j=0; j<n; j++) {
actual[j] = (inputSeq[i]-1+j-i+3*n)%n;
}
break;
}
}
if (actual[0]==-1) {
prod = n; //multiply by n at the end
for (int i=0; i<n; i++) actual[i] = i;
}
for (int i=0; i<n; i++) {
//cout << actual[i] <<" ";
}
//cout << endl;
for (int i=0; i<n; i++) {
posindex.push_back({inputSeq[i]-1,i});
}
sort(posindex.begin(), posindex.end());
vector<int> repl;
int cur = n;
for (int i=0; i<posindex.size(); i++) {
while (posindex[i].first>=cur) {
repl.push_back(actual[posindex[i].second]);
actual[posindex[i].second] = cur;
if (posindex[i].first>cur) {
prod*=n-i;
prod%=MOD;
}
cur++;
}
}
//cout << "done " << repl.size() << endl;
return (signed)prod;
}
컴파일 시 표준 에러 (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... |
# | 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... |