Переглянути джерело

Merge in full round data (use git subtree merge to update)

master
Yorick van Pelt 2 роки тому
джерело
коміт
addb57d510
7 змінених файлів з 142 додано та 0 видалено
  1. 7
    0
      full/C.py
  2. 7
    0
      full/E.py
  3. 38
    0
      full/F.cpp
  4. 29
    0
      full/F.py
  5. 12
    0
      full/H.py
  6. 42
    0
      full/I.py
  7. 7
    0
      full/J.py

+ 7
- 0
full/C.py Переглянути файл

@@ -0,0 +1,7 @@
from __future__ import print_function
import sys
x, y = map(float, sys.stdin.readline().split())
n = float(sys.stdin.readline())
for l,u,f in ( map(float, line.split()) for line in sys.stdin ):
y -= (u-l)*(1-f)
print(x / y)

+ 7
- 0
full/E.py Переглянути файл

@@ -0,0 +1,7 @@
from __future__ import print_function
import sys
n = int(sys.stdin.readline())
ss = map(int, sys.stdin.readline().split())
tt = sorted(enumerate(ss), key = lambda (i,x): -x)
print(" ".join(str(x[0]+1) for x in tt) if tt[0][1] <= sum(ss)-tt[0][1]
else "impossible")

+ 38
- 0
full/F.cpp Переглянути файл

@@ -0,0 +1,38 @@
#include <algorithm>
#include <functional>
#include <iostream>
#include <set>
#include <vector>

using namespace std;

long f(vector<long>& l)
{
long m = 0; set<long, greater<long>> s = {0};
for(auto x : l) {
// cerr << "x = " << x << endl;
if (s.count(x) == 0) {
m = max(m, min(*s.begin(), x));
s.insert(x);
} else {
s.erase(x);
m = max(m, min(*s.begin(), x));
}
// cerr << "m = " << m << endl;
}
return m;
}

int main()
{
long n; cin >> n; vector<long> l1(n), l2(n);
for (long i = 0; i < n; ++i) cin >> l1[i];
for (long i = 0; i < n; ++i) cin >> l2[i];
set<long> s2(begin(l2), end(l2));
set<long, greater<long>> s; vector<long> l1_, l2_;
for (auto x : l1) if (s2.count(x) == 1) s.insert(x);
for (auto x : l1) if (s.count(x) == 0) l1_.push_back(x);
for (auto x : l2) if (s.count(x) == 0) l2_.push_back(x);
long m = *s.begin();
cout << max(m, max(f(l1_), f(l2_))) << endl;
}

+ 29
- 0
full/F.py Переглянути файл

@@ -0,0 +1,29 @@
MOVED_TO_CPP

from __future__ import print_function
import sys

def f(l):
m, s, ms = 0, set(), 0
for x in l:
if x not in s:
s.add(x)
ms = max(x, ms)
else:
s.remove(x)
ms = ...
if ms > x:
m = max(m, x)
else:
m = max(m, ms)
return m

n = int(sys.stdin.readline())
l1 = map(int, sys.stdin.readline().split())
l2 = map(int, sys.stdin.readline().split())
s2 = set(l2)
s = [ x for x in l1 if x in s2 ]
l1 = [ x for x in l1 if x not in s ]
l2 = [ x for x in l2 if x not in s ]
m = max(s)
print(max(m, max(f(l1), f(l2))))

+ 12
- 0
full/H.py Переглянути файл

@@ -0,0 +1,12 @@
from __future__ import print_function
import sys
def to_int(x):
bs = []
for b in x:
if bs and bs[-1]:
bs.append(0 if b == "1" else 1)
else:
bs.append(1 if b == "1" else 0)
return int("".join(map(str, bs)), 2)
n, a, b = sys.stdin.readline().split(); n = int(n)
print(to_int(b) - to_int(a) - 1)

+ 42
- 0
full/I.py Переглянути файл

@@ -0,0 +1,42 @@
from __future__ import print_function
import heapq, sys

def dijkstra(G, s):
V, E = G; d = {}; S = set(); q = []
for u in V: d.setdefault(u, None)
for u in s:
d[u] = 0; heapq.heappush(q, (0,u))
while q:
n, u = heapq.heappop(q)
if u in S: continue
S.add(u)
for v in E[u]:
if d[v] is None or d[v] > d[u] + 1:
d[v] = d[u] + 1; heapq.heappush(q, (d[v],v))
return d

def transpose(G):
V, E = G; ET = {}
for u in V: ET[u] = []
for u, vs in E.iteritems():
for v in vs: ET[v].append(u)
return V, ET

n, m, k = map(int, sys.stdin.readline().split())
iron = [ int(x)-1 for x in sys.stdin.readline().split() ]
coal = [ int(x)-1 for x in sys.stdin.readline().split() ]
V, E = range(n), {}
for i, line in enumerate(sys.stdin):
E[i] = [ int(x)-1 for x in line.split()[1:] ]
G = V, E
GT = transpose(G)
ds = dijkstra(G, [0])
di = dijkstra(GT, iron)
dc = dijkstra(GT, coal)
try:
m = min( ds[i]+di[i]+dc[i] for i in xrange(n)
if None not in (ds[i],di[i],dc[i]) )
print(m)
except ValueError as e:
if "empty" not in e.args[0]: raise
print("impossible")

+ 7
- 0
full/J.py Переглянути файл

@@ -0,0 +1,7 @@
from __future__ import print_function
import sys
n, q, s = map(int, float, sys.stdin.readline().split())
s_to_q = map(int, float, sys.stdin.readline().split())
q_sizes = map(int, float, sys.stdin.readline().split())

# alleen nog even...

Завантаження…
Відмінити
Зберегти