| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1015546 | andrei_iorgulescu | 운세 보기 2 (JOI14_fortune_telling2) | C++14 | 1 ms | 2396 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int n,k,a[200005],b[200005],t[200005];
int g;
bool tr[105][105];
vector<int> lol;
int get_who(int x)
{
int st = -1,pas = 64;
while (pas != 0)
{
if (st + pas < lol.size() and x > lol[st + pas])
st += pas;
pas >>= 1;
}
return st + 1;
}
void solve(vector<int> op)
{
set<int> ss;
for (auto it : op)
ss.insert(it);
vector<int> vls;
for (auto it : ss)
vls.push_back(it);
vls.push_back((int)2e9);
lol = vls;
for (int i = 0; i < vls.size(); i++)
{
for (int j = 0; j < vls.size(); j++)
{
int x0 = vls[i];
int x = vls[i],y = vls[j];
int cnt_swap = 0;
for (auto it : op)
{
if (it >= x)
swap(x,y),cnt_swap ^= 1;
}
if (cnt_swap)
tr[i][j] = true;
else
tr[i][j] = false;
}
}
for (int i = 1; i <= n; i++)
{
//cout << get_who(a[i]) << ' ' << get_who(b[i]) << endl;
if (tr[get_who(a[i])][get_who(b[i])])
swap(a[i],b[i]);//,cout << i << endl;
}
//cout << endl;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n >> k;
for (int i = 1; i <= n; i++)
cin >> a[i] >> b[i];
for (int i = 1; i <= k; i++)
cin >> t[i];
for (g = 1; g * g * g <= k; g++)
continue;
g--;
g *= g;
for (int i = 1; i <= k; i += g)
{
vector<int> op;
for (int j = i; j <= k and j < i + g; j++)
op.push_back(t[i]);
solve(op);
}
long long ans = 0;
for (int i = 1; i <= n; i++)
ans += a[i];
cout << ans;
return 0;
}
컴파일 시 표준 에러 (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... | ||||
