s_id stringlengths 10 10 | p_id stringlengths 6 6 | u_id stringlengths 10 10 | date stringlengths 10 10 | language stringclasses 1
value | original_language stringclasses 11
values | filename_ext stringclasses 1
value | status stringclasses 1
value | cpu_time stringlengths 1 5 | memory stringlengths 1 7 | code_size stringlengths 1 6 | code stringlengths 1 539k |
|---|---|---|---|---|---|---|---|---|---|---|---|
s383969310 | p03645 | u105124953 | 1588130381 | Python | PyPy3 (2.4.0) | py | Runtime Error | 933 | 66264 | 397 | import bisect
n,m = map(int,input().split())
one_li = []
to_n_li = []
for _ in range(m):
a,b = map(int,input().split())
if a == 1:
one_li.append(b)
if b == n:
to_n_li.append(a)
#print(one_li,to_n_li)
for o in list(set(one_li)):
index = bisect.bisect_left(to_n_li, o)
if to_n_li[index]... |
s402037366 | p03645 | u581603131 | 1587841304 | Python | Python (3.4.3) | py | Runtime Error | 138 | 3060 | 285 | #真に大切なのは中間点となる要素
N, M = map(int, input().split())
an = set()
nb = set()
for i in range(M):
a, b = map(int, input().split())
if a == 1:
an.append(b)
elif b == N:
nb.append(a)
print('IMPOSSIBLE' if len(an&nb)==0 else 'POSSIBLE') |
s872433364 | p03645 | u884692162 | 1587607049 | Python | Python (3.4.3) | py | Runtime Error | 2111 | 62876 | 384 | import sys
import numpy as np
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N, M = lr()
E = {i+1: [] for i in range(M)}
first = []
for m in range(M):
a, b = lr()
if b == N:
first.append(a)
E[a].append(b)
for f in first:
if f in E[1]... |
s957027265 | p03645 | u442877951 | 1587270918 | Python | Python (3.4.3) | py | Runtime Error | 2109 | 17632 | 311 | import numpy as np
N,M = map(int,input().split())
AB = np.array([[0]*M]*M)
for i in range(M):
a,b = map(int,input().split())
AB[a-1][i] = b
for i in range(M):
if AB[0][i] != 0:
k = AB[0][i]-1
for j in range(M):
if AB[k][j] == N:
print("POSSIBLE")
exit()
print("IMPOSSIBLE")
|
s259159713 | p03645 | u549383771 | 1587143273 | Python | Python (3.4.3) | py | Runtime Error | 83 | 23536 | 381 | n,m = map(int,input().split())
graph = [[0*n] for j in range(n)]
for i in range(m):
a,b = map(int,input().split())
graph[a-1][b-1] = 1
graph[b-1][a-1] = 1
flag = False
for i in range(n):
if graph[0][i] == 1:
if graph[i][n-1] == 1:
flag = True
break
if fl... |
s064147411 | p03645 | u124498235 | 1587127928 | Python | Python (3.4.3) | py | Runtime Error | 575 | 6320 | 301 | n, m = map(int, input().split())
c = [False for i in range(199999)]
d = [False for i in range(199999)]
for i in range(m):
a, b = map(int, input().split())
if a == 1:
c[b] = True
if b == n:
d[a] = True
for i in range(199999):
if c[i] and d[i]:
print ("POSSIBLE")
exit()
print ("IMPOSSIBLE") |
s771301824 | p03645 | u841531687 | 1586800486 | Python | PyPy3 (2.4.0) | py | Runtime Error | 169 | 38256 | 225 | n, m = map(int, input())
sa = set()
sb = set()
for i in range(m):
a, b = map(int, input().split())
if a == 1:
sb.add(b)
if b == n:
sa.add(a)
print('IMPOSSIBLE' if len(sa & sb) == 0 else 'POSSIBLE') |
s040087041 | p03645 | u841531687 | 1586800431 | Python | PyPy3 (2.4.0) | py | Runtime Error | 183 | 38256 | 226 | n, m = map(int, input())
sa = set()
sb = set()
for i in range(m):
a, b = map(int, input().split())
if a == 1:
sb.add(b)
if b == n:
sa.add(a)
print('IMPOSSIBLE', if len(sa & sb) == 0 else 'POSSIBLE') |
s618133955 | p03645 | u852790844 | 1586660554 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 205 | n, m = map(int, input())
c = set()
d = set()
for i in range(m):
a, b = map(int, input())
if a == 1:
c.add(b)
if b == n:
d.add(a)
ans = "POSSIBLE" if len(c & d) else "IMPOSSIBLE" |
s104215028 | p03645 | u395816772 | 1586030149 | Python | Python (3.4.3) | py | Runtime Error | 18 | 4596 | 383 | n,m = map(int, input().split())
a,b = [0]*m
for i in range(m):
a[i],b[i] = map(int,input().split())
c = []
d = []
for i in range(m):
if a[i] == 1:
c.append(b[i])
if b[i][1] == n:
d.append(a[i])
ans = False
c = list(set(c))
for i in c:
if d.count(i) >=1:
ans = True
br... |
s516929543 | p03645 | u992910889 | 1586022459 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 2768 |
# input = sys.stdin.readline
def resolve():
from heapq import heappush, heappop
# 長点数V、直接移動先とコストを記したリストg、スタート地点rをとって、
# rからiに行くまでの最低コストがdist[i]であることを意味するリストdistを返す関数
def dijkstra(V, g, r):
dist = [INF] * V
queue = [(0, r)] # queueの要素(c,v)は、コストcで直接vに行けることを意味する
dist[r] = 0 # ... |
s047390925 | p03645 | u090649502 | 1585623062 | Python | Python (3.4.3) | py | Runtime Error | 617 | 20340 | 242 | n,m=map(int,input().split())
a=[0]*m
b=[0]*m
for i in range(m):
a[i],b[i]=map(int,input().split())
c=[0]*m
for i in range(m):
if a[i]==1:
c[b[i]-1] |= 1
if b[i]==n:
c[a[i]-1] |= 2
print("POSSIBLE" if max(c)==3 else "IMPOSSIBLE") |
s899096386 | p03645 | u861471387 | 1585153412 | Python | PyPy3 (2.4.0) | py | Runtime Error | 167 | 38256 | 222 | N,M=map(int,input().split())
first=[]
second=[]
for i in range(M):
a,b=map(int,input().split())
if a==1:
first.append(b)
elif b==N:
second.append(a)
ans="IMPOSSIBLE"
for i in first:
if i in second: |
s632055069 | p03645 | u545368057 | 1585134503 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 658 | N,M = map(int, input().split())
from collections import defaultdict
edges = defaultdict(list)
for i in range(M):
a, b = map(int, input().split())
edges[a].append(b)
edges[b].append(a)
first = edges[1]
# print(first)
for fr in first:
if N in edges[fr]:
print("POSSIBLE")
exit()
print("IMP... |
s320841732 | p03645 | u367965715 | 1584824056 | Python | Python (3.4.3) | py | Runtime Error | 149 | 12508 | 335 | import numpy as np
n, m = map(int, input().split())
g = np.zeros((n, n), dtype=np.int)
for _ in range(m):
a, b = map(int, input().split())
g[a-1, b-1] = 1
g[b-1, a-1] = 1
res = 'IMPOSSIBLE'
for i in range(n):
if g[n-1, i] == 0:
continue
if g[i, 0] == 1:
res = 'POSSIBLE'
bre... |
s600869754 | p03645 | u367965715 | 1584823996 | Python | Python (3.4.3) | py | Runtime Error | 151 | 12500 | 332 | import numpy as np
n, m = map(int, input().split())
g = np.zeros((n, n), dtype=int)
for _ in range(m):
a, b = map(int, input().split())
g[a-1, b-1] = 1
g[b-1, a-1] = 1
res = 'IMPOSSIBLE'
for i in range(n):
if g[n-1, i] == 0:
continue
if g[i, 0] == 1:
res = 'POSSIBLE'
break
... |
s514900967 | p03645 | u941434715 | 1584816338 | Python | Python (3.4.3) | py | Runtime Error | 814 | 20456 | 461 | #coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb
N,M = map(int, input().split())
A = []
B = []
for _ in range(M):
a,b = map(int, input().split())
if a == 1: A.append(b)
elif b == N: B.append(a)
B.sort()
if len(B) > 0 an... |
s007943858 | p03645 | u941434715 | 1584816285 | Python | Python (3.4.3) | py | Runtime Error | 817 | 20512 | 446 | #coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb
N,M = map(int, input().split())
A = []
B = []
for _ in range(M):
a,b = map(int, input().split())
if a == 1: A.append(b)
elif b == N: B.append(a)
B.sort()
if len(B) > 0:
... |
s365338522 | p03645 | u941434715 | 1584816195 | Python | Python (3.4.3) | py | Runtime Error | 817 | 20512 | 415 | #coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb
N,M = map(int, input().split())
A = []
B = []
for _ in range(M):
a,b = map(int, input().split())
if a == 1: A.append(b)
elif b == N: B.append(a)
B.sort()
for a in A:
... |
s655907819 | p03645 | u227082700 | 1584325265 | Python | Python (3.4.3) | py | Runtime Error | 602 | 18892 | 182 | n,m=map(int,input().split())
s,t=set(),set()
for _ in range(m):
a,b=map(int,input().split())
if a==1:t.add(b)
if b==n:s.add(a)
if s%t:print("POSSIBLE")
else:print("IMPOSSIBLE") |
s695572285 | p03645 | u934868410 | 1583848575 | Python | Python (3.4.3) | py | Runtime Error | 606 | 19024 | 256 | n,m = map(int,input().split())
s = set()
t = set()
for i in range(m):
a,b = map(int,input().split())
if a == 1 and b != n:
s.add(b)
if a != 1 and b == n:
t.add(a)
for x in a:
if x in b:
print('POSSIBLE')
exit()
print('IMPOSSIBLE') |
s143619077 | p03645 | u934868410 | 1583803468 | Python | Python (3.4.3) | py | Runtime Error | 603 | 19024 | 242 | n,m = map(int,input().split())
s = set()
t = set()
for i in range(m):
a,b = map(int,input().split())
if a == 1 and b != n:
s.add(b)
if a != 1 and b == n:
t.add(a)
if len(a&b) > 0:
print('POSSIBLE')
else:
print('IMPOSSIBLE') |
s772974398 | p03645 | u291628833 | 1583730952 | Python | PyPy3 (2.4.0) | py | Runtime Error | 167 | 38256 | 292 | import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix
n,m = map(int,input().split())
a_L,b_L = [],[]
for i in range(n):
a,b = map(int,input().split())
a_L.append(a)
b_L.append(b)
|
s339863222 | p03645 | u097317219 | 1583603156 | Python | PyPy3 (2.4.0) | py | Runtime Error | 1877 | 97368 | 423 | n,m = map(int,input().split())
ab = sorted([list(map(int,input().split())) for _ in range(m)])
relaypoint = []
i = 0
while(ab[i][0] == 1):
relaypoint.append(ab[i][1])
i += 1
ab.sort(key = lambda ab:ab[1],reverse = True)
relaypoint = set(relaypoint)
x = len(relaypoint)
j = 0
flag = 0
while(ab[j][1] == n):
if ab[j]... |
s022356962 | p03645 | u097317219 | 1583557589 | Python | PyPy3 (2.4.0) | py | Runtime Error | 2109 | 98904 | 428 | n,m = map(int,input().split())
ab = sorted([list(map(int,input().split())) for _ in range(m)])
relaypoint = []
i = 0
while(ab[i][0] == 1):
relaypoint.append(ab[i][1])
i += 1
ab.sort(key = lambda ab:ab[1],reverse = True)
relaypoint = list(set(relaypoint))
x = len(relaypoint)
j = 0
flag = 0
while(ab[j][1] == n):
if... |
s320905862 | p03645 | u097317219 | 1583557424 | Python | PyPy3 (2.4.0) | py | Runtime Error | 164 | 38256 | 419 | n,m = map(int,input().split())
ab = sorted([list(map(int,input().split())) for _ in range(m)])
relaypoint = []
i = 0
while(ab[i][0] == 1):
relaypoint.append(ab[i][1])
i += 1
ab.sort(key = lambda ab:ab[1] reverse = True)
relaypoint = list(set(relaypoint))
x = len(relaypoint)
j = 0
flag = 0
while(ab[j][1] == 5):
if... |
s799368149 | p03645 | u747703115 | 1583523358 | Python | Python (3.4.3) | py | Runtime Error | 592 | 6132 | 288 | n, m = map(int, input().split())
Ton = [False]*n
Fr1 = [False]*n
for i in range(m):
a, b = map(int, input().split())
if b==n:
Ton[a] = True
if a==1:
Fr1[b] = True
r = 'IMPOSSIBLE'
for i in range(m):
if Ton[i]==Fr1[i]==True:
r = 'POSSIBLE'
print(r) |
s478116714 | p03645 | u530383736 | 1583222845 | Python | Python (3.4.3) | py | Runtime Error | 1481 | 123256 | 1019 | # -*- coding: utf-8 -*-
def check(ship_dic :dict, passed :list, start :int, cnt_list :list):
next_island = ship_dic[start] - set(passed)
if start == len(ship_dic) or len(next_island) == 0:
cnt_list += [passed]
return 1,passed
cnt=0
for i in next_island:
next_passed = list... |
s525011455 | p03645 | u838644735 | 1582911484 | Python | PyPy3 (2.4.0) | py | Runtime Error | 1061 | 114392 | 444 | def solve():
N, M = map(int, input().split())
T = {}
for i in range(M):
a, b = map(int, input().split())
if a not in T:
T[a] = []
T[a].append(b)
if b not in T:
T[b] = []
T[b].append(a)
# print(N, M, T)
FROM_1 = set(T[1])
TO_N = set(... |
s556019917 | p03645 | u291988695 | 1582844116 | Python | Python (3.4.3) | py | Runtime Error | 1075 | 54180 | 332 | n,m=map(int,input().split())
l=[[0,0]]*m
t=[0]*m
tc=0
a=False
f=0
for k in range(m):
l[k]=list(map(int,input().split()))
l.sort()
for k in l:
if k[0]!=1 & f==0:
del t[tc:]
if k[0]==1:
t[tc]=k[1]
tc+=1
elif k[1]==n:
if k[0] in t:
a=True
break
if a:
print("POSSIBLE")
else:
print("I... |
s242793748 | p03645 | u185325486 | 1582122850 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 315 | N,M = map(int, input().split())
hune = sorted([list(map(int, input().split())) for _ in range(M)], key=lambda x:x[0])
for a,b in hune:
if a == 1:
for c,d in hune:
if c == b and d == N:
print('POSSIBLE')
return
if a == 2:
break
print('IMPOSSIBLE') |
s962534625 | p03645 | u185325486 | 1582122804 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 302 | N,M = map(int, input().split())
hune = sorted([list(map(int, input().split())) for _ in range(M)], key=lambda x:x[0])
for a,b in hune:
if a == 1:
for c,d in hune:
if c == b and d == N:
print('Yes')
return
if a == 2:
break
print('No') |
s325893952 | p03645 | u170183831 | 1582122372 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 280 | n, m = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(_m)]
cands = set(b if a == 1 else a for a, b in AB if a == 1 or b == 1)
if any(a in cands and b == n or b in cands and a == n for a, b in AB):
print('POSSIBLE')
else:
print('IMPOSSIBLE') |
s877436493 | p03645 | u987170100 | 1581633068 | Python | Python (3.4.3) | py | Runtime Error | 578 | 18936 | 279 | N, M = map(int, input().split())
s1 = set()
s2 = set()
for _ in range(M):
a, b = map(int, input().split())
if a == 1:
s1.add(b)
if b == N:
s2.add(a)
for x in s1:
if s2.count(x) >= 1:
print("POSSIBLE")
exit()
print("IMPOSSIBLE")
|
s227729528 | p03645 | u987170100 | 1581633012 | Python | Python (3.4.3) | py | Runtime Error | 140 | 3060 | 285 | N, M = map(int, input().split())
s1 = set()
s2 = set()
for _ in range(M):
a, b = map(int, input().split())
if a == 1:
s1.append(b)
if b == N:
s2.append(a)
for x in s1:
if s2.count(x) >= 1:
print("POSSIBLE")
exit()
print("IMPOSSIBLE")
|
s378336566 | p03645 | u821251381 | 1581380260 | Python | Python (3.4.3) | py | Runtime Error | 674 | 6132 | 317 | N,M = map(int,input().split())
from1 = [False]*N
toN = [False]*N
for i in range(M):
a,b = map(int,input().split())
if a ==1 or b ==1:
from1[max(a,b)-1]=True
if a == N or b == N:
toN[a-1 if a!= N else b-1]=True
cnt =0
for i in range(M):
cnt+=from1[i]&toN[i]
print("POSSIBLE" if cnt else "IMPOSSIBLE") |
s756859258 | p03645 | u821251381 | 1581380155 | Python | Python (3.4.3) | py | Runtime Error | 650 | 6132 | 311 | N,M = map(int,input().split())
from1 = [False]*N
toN = [False]*N
for i in range(M):
a,b = map(int,input().split())
if a ==1 or b ==1:
from1[max(a,b)]=True
if a == N or b == N:
toN[a if a!= N else b]=True
cnt =0
for i in range(M):
cnt+=from1[i]&toN[i]
print("POSSIBLE" if cnt else "IMPOSSIBLE") |
s395300279 | p03645 | u856169020 | 1580403755 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 265 | first = []
second = []
for _ in range(M):
a, b = map(int, input().split())
if a == 1:
first.append(b)
elif b == N:
second.append(a)
ans = 0
for i in first:
if i in second:
ans = 1
break
if ans:
print("POSSIBLE")
else:
print("IMPOSSIBLE") |
s031752431 | p03645 | u327211044 | 1580049710 | Python | Python (3.4.3) | py | Runtime Error | 2107 | 54152 | 316 | n, m = map(int, input().split())
info = sorted([list(map(int, input().split())) for _ in range(m)])
q = []
for i in range(m):
if info[i][0] == 1:
q.append(info[i][1])
else:
t = i
break
for j in range(t, m):
if info[j][0] in q:
if info[j][1] == n:
print("POSSIBLE")
break
else:
print("IMPOSSIBLE") |
s237119434 | p03645 | u361381049 | 1579978411 | Python | Python (3.4.3) | py | Runtime Error | 157 | 8180 | 299 | n, m = map(int, input().split())
a = [0] * m
b = [0] * m
first = {}
second = {}
for i in range(m):
a[i], b[i] = map(int, input().split())
if a[i] == 1:
first.add(b[i])
if b[i] == n:
second.add(a[i])
ans = 'IMPOSSIBLE'
if first & second:
ans = 'POSSIBLE'
print(ans)
|
s992332048 | p03645 | u259861571 | 1579316232 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 260 | #AtCoder
N, M = map(int, input().split())
s = set()
g = set()
for _ in range(M):
a, b = map(int, input().split())
if a == 1:
s.add(a)
else b == N:
g.add(a)
if set1 & set2:
print("POSSIBLE")
else:
print("IMPOSSIBLE")
|
s963893930 | p03645 | u626468554 | 1578506751 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 325 | n,m = int(input())
li = [[0 for _ in range(n)] for _ in range(n)]
for i in range(m):
a,b = map(int,input())
a-=1
b-=1
li[a][b] = 1
li[b][a] = 1
ans = False
for i in range(1,n-1):
if li[0][i] and li[i][n-1]:
ans = True
break
if ans:
print("POSSIBLE")
else:
print("IMPOSSI... |
s988589705 | p03645 | u095021077 | 1577685305 | Python | Python (3.4.3) | py | Runtime Error | 742 | 11368 | 393 | N, M=map(int, input().split())
x=[]
y=[]
for i in range(M):
a, b=map(int, input().split())
if a==1:
x.append(b)
if b==1:
x.append(a)
if a==N:
y.append(b)
if b==N:
y.append(a)
x.sort()
y.sort()
i=0
j=0
out='IMPOSSIBLE'
nx=len(x)
ny=len(y)
while i+j<nx+ny-1:
if x[i]==y[j]:
out='POSSIB... |
s421988084 | p03645 | u989345508 | 1577283392 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 545 | #include<iostream>
#include<vector>
using namespace std;
int main(){
int n,m;cin >> n >> m;
vector<int> x;
bool f=false;
for(int i=0;i<m;i++){
int a,b;cin >> a >>b;
if(a==1){
if(find(x.begin(),x.end(),b)!=x.end()){
cout << "POSSIBLE" << endl;f=true;break;
}else{
x.push_back(... |
s993569679 | p03645 | u609061751 | 1577179515 | Python | Python (3.4.3) | py | Runtime Error | 448 | 48244 | 615 | import sys
import numpy as np
input = sys.stdin.readline
N, M = [int(x) for x in input().split()]
I = []
for _ in range(M):
I.append([int(x) for x in input().split()])
s_1 = {}
s_N = {}
for i in I:
if i[0] == 1 and i[1] == N:
print("POSSIBLE")
sys.exit()
if i[0] == 1:
if i[1] in s_N:... |
s330319074 | p03645 | u905582793 | 1577059988 | Python | Python (3.4.3) | py | Runtime Error | 375 | 17328 | 273 | n,m=map(int,input().split())
tr=[[] for i in range(n)]
for i in range(m):
a,b=map(int,input().split())
if a!=1 and b!=n:
continue
tr[a].append(b)
tr[b].append(a)
for i in range(n):
if len(tr[i])==2:
print("POSSIBLE")
break
else:
print("IMPOSSIBLE")
|
s159280026 | p03645 | u905582793 | 1577059910 | Python | Python (3.4.3) | py | Runtime Error | 584 | 17432 | 272 | n,m=map(int,input().split())
tr=[[] for i in range(m)]
for i in range(m):
a,b=map(int,input().split())
if a!=1 and b!=n:
continue
tr[a].append(b)
tr[b].append(a)
for i in range(m):
if len(tr[m])==2:
print("POSSIBLE")
break
else:
print("IMPOSSIBLE") |
s141811152 | p03645 | u097317219 | 1577053477 | Python | PyPy3 (2.4.0) | py | Runtime Error | 177 | 38512 | 302 | n,m=map(int,input().split())
ab=[list(map(int,input().split()))]
ab.sort()
medium = []
flag = 0
for i in range(m):
if ab[i][0] == 1:
medium.append(ab[i][1])
for j in range(m):
if ab[j][0] in medium and ab[j][1] == n:
flag = 1
if flag == 1:
print("POSSIBLE")
else:
print("IMPOSSIBLE")
|
s058326440 | p03645 | u130900604 | 1577047845 | Python | Python (3.4.3) | py | Runtime Error | 609 | 30000 | 274 | n,m=map(int,input().split())
ab=[]
for i in range(m):
a,b=map(int,input().split())
ab.append((a,b))
#print(ab)
mid=[]
for (i,j) in ab:
if i==1:
mid.append(j)
for (i,j) in ab:
if i in mi and j==n:
print("POSSIBLE");exit()
print("IMPOSSIBLE")
|
s634682268 | p03645 | u344959886 | 1576190886 | Python | PyPy3 (2.4.0) | py | Runtime Error | 902 | 77272 | 424 | import sys
n,m=map(int,input().split())
a = [[int(i) for i in input().split()] for i in range(m)]
c=[]
a = sorted(li,key = lambda x:-x[1])
for i in range(m):
if a[i][1] < n:
break
else:
c.append(a[i][0])
a = sorted(li,key = lambda x:x[0])
for i in range(m):
if a[i][0] > 1:
break... |
s423615493 | p03645 | u875600867 | 1575850277 | Python | Python (3.4.3) | py | Runtime Error | 389 | 28420 | 567 | # -*- coding: utf-8 -*-
import sys
# N: 島の数
# M: 定期便のルート
N, M = input().split()
a = []
b = []
# 船のルートを記録
for m in range(int(M)):
_a, _b = input().split()
a.append(_a)
b.append(_b)
if a.index("1") !=False:
for i in a.index("1"):
if b.index(N) !=False:
for l in b.index(N):
... |
s826191925 | p03645 | u923659712 | 1574138966 | Python | Python (3.4.3) | py | Runtime Error | 2107 | 51744 | 311 | n,m=map(int,input().split())
s=[]
for i in range(m):
d=list(map(int,input().split()))
s.append(d)
for j in range(n-1):
for k in range(j,n):
if (s[j][0]==1 and s[j][1]==s[k][0] and s[k][1]==n) or (s[k][0]==1 and s[k][1]==s[j][0] and s[j][1]==n):
print("POSSIBLE")
exit()
print("IMPOSSIBLE") |
s728918435 | p03645 | u662613022 | 1573142163 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 10976 | 298 | N,M = map(int,input().split())
li = []
numb = []
ans = ''
for i in range(M):
a,b = map(int,input().split())
if a == 1:
li.append(b)
elif b == N:
numb.append(a)
for i in range(M):
if li[i] in numb:
ans = 'POSSIBLE'
break
if ans == '':
print('IMPOSSIBLE')
else:
print(ans) |
s262418607 | p03645 | u662613022 | 1573141984 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 10988 | 312 | N,M = map(int,input().split())
li = []
numb = []
ans = ''
for i in range(M):
a,b = map(int,input().split())
if a == 1:
li.append(b)
elif b == N:
numb.append(a)
for i in range(M):
if li[i] in numb:
ans = 'POSSIBLE'
break
if ans == '':
print('IMPOSSIBLE')
else:
print(ans) |
s517557400 | p03645 | u311636831 | 1573087135 | Python | Python (3.4.3) | py | Runtime Error | 2106 | 48804 | 643 | N , M = map(int, input().split())
L=[[0]*2 for i in range(M)]
for i in range(M):
L[i][0] , L[i][1] = map(int, input().split())
A=[0]*M
B=[0]*M
L=sorted(L ,key=lambda x: x[0])
for i in range(M):
if L[i][0] == 1:
A[i]=L[i][1]
else:
break
A=A[0:i]
L=sorted(L ,key=lambda x: -x[1])
for i i... |
s254520775 | p03645 | u759412327 | 1569525753 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 189 | N,M = list(map(int,input().split()))
x = 1
y = 1
for m in M:
a,b = list(map(int,input().split()))
if a==1:
x|=1<<b
if b==N:
y|=1<<a
print("IM"*(x&y==1)+"POSSIBLE") |
s960799654 | p03645 | u214434454 | 1568326247 | Python | Python (3.4.3) | py | Runtime Error | 149 | 12512 | 291 | n, m = map(int, input().split())
import numpy as np
g = np.zeros((n+1, n+1))
for _ in range(m):
a, b = map(int, input().split())
g[a][b] = 1
g[b][a] = 1
ans = "IMPOSSIBLE"
for i in range(n+1):
if g[1][i] == 1:
if g[i][n] == 1:
ans = "POSSIBLE"
print(ans)
|
s581479675 | p03645 | u231685196 | 1568095296 | Python | Python (3.4.3) | py | Runtime Error | 785 | 30684 | 457 | n,m = map(int,input().split())
path = {}
for i in range(m):
a,b = map(int,input().split())
if a not in path:
path[a] = [b]
else:
path[a].append(b)
ns = []
if 1 in path:
for p in path[1]:
ns.append(p)
flag = False
for mid in ns:
if n in path[mid]:
fla... |
s808646987 | p03645 | u231685196 | 1568095145 | Python | Python (3.4.3) | py | Runtime Error | 706 | 30732 | 375 | n,m = map(int,input().split())
path = {}
for i in range(m):
a,b = map(int,input().split())
if a not in path:
path[a] = [b]
else:
path[a].append(b)
ns = []
for p in path[1]:
ns.append(p)
flag = False
for mid in ns:
if n in path[mid]:
flag = True
break
if flag:
p... |
s414554751 | p03645 | u598229387 | 1567881409 | Python | Python (3.4.3) | py | Runtime Error | 798 | 58992 | 296 | n,m=map(int,input().split())
ab=[[int(i) for i in input().split()] for j in range(m)]
li=[[] for i in range(m+1)]
for a,b in ab:
li[a].append(b)
li2=[]
for i in li[1]:
li2.append(i)
ans=False
for i in li2:
if n in li[i]:
ans=True
print('POSSIBLE' if ans else 'IMPOSSIBLE') |
s630691410 | p03645 | u266874640 | 1567879161 | Python | Python (3.4.3) | py | Runtime Error | 352 | 3060 | 258 | N, M = map(int,input().split())
A = []
B = []
for _ in range(M):
a,b = map(int,input().split())
if a == 1:
B.append(b)
if b == N:
A.appned(a)
for a in A:
if a in B:
print('POSSIBLE')
exit()
print('IMPOSSIBLE')
|
s652762939 | p03645 | u600402037 | 1567801638 | Python | Python (3.4.3) | py | Runtime Error | 883 | 66572 | 309 | N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
edges = {}
flag = 'IMPOSSIBLE'
for a, b in AB:
if a in edges:
edges[a].append(b)
else:
edges[a] = [b]
for i in edges[1]:
if N in edges[i]:
flag = 'POSSIBLE'
break
print(flag) |
s689045003 | p03645 | u970899068 | 1567310017 | Python | Python (3.4.3) | py | Runtime Error | 938 | 39332 | 657 | def dfs(now,prev,count):
global flag
flag=False
# 今いる頂点から行ける頂点を順に next に入れてループ
count+=1
for next in g[now]:
if next != prev:
if next== n-1:
if count==2:
flag=True
break
else:
break
... |
s887510742 | p03645 | u970899068 | 1567309912 | Python | Python (3.4.3) | py | Runtime Error | 1006 | 39332 | 658 | def dfs(now,prev,count):
global flag
flag=False
# 今いる頂点から行ける頂点を順に next に入れてループ
count+=1
for next in g[now]:
if next != prev:
if next== n-1:
if count==2:
flag=True
break
else:
break
... |
s900208585 | p03645 | u970899068 | 1567309802 | Python | Python (3.4.3) | py | Runtime Error | 958 | 39344 | 656 | def dfs(now,prev,count):
global flag
flag=False
# 今いる頂点から行ける頂点を順に next に入れてループ
count+=1
for next in g[now]:
if next != prev:
if next== n-1:
if count==2:
flag=True
break
else:
break
... |
s750770536 | p03645 | u897328029 | 1566684941 | Python | Python (3.4.3) | py | Runtime Error | 916 | 66644 | 863 | # https://atcoder.jp/contests/abc068/tasks/arc079_a
# C - Cat Snuke and a Voyage
n, m = list(map(int, input().split()))
ab_list = []
for _ in range(m):
a, b = list(map(int, input().split()))
ab_list.append((a, b))
ab_dict = {k: [] for k in range(1, m+1)}
for a, b in ab_list:
# 子供を覚えさせる
ab_dict[a].ap... |
s482593939 | p03645 | u077291787 | 1566442388 | Python | Python (3.4.3) | py | Runtime Error | 632 | 30260 | 457 | # ABC068C - Cat Snuke and a Voyage (ARC079C)
def main():
N, M = tuple(map(int, input().split()))
A = tuple(tuple(map(int, input().split())) for _ in range(M))
S, D = set(), set() # start, destination
for a, b in E:
if a == 1:
S |= {b}
if b == N:
D |= {a}
flg ... |
s316513979 | p03645 | u437638594 | 1566098481 | Python | PyPy3 (2.4.0) | py | Runtime Error | 163 | 38256 | 289 | N, M = map(int, input().split())
ab_list = sorted([list(map(int, input().split())) for _ in range(M)])
ans = "IMPOSSIBLE"
second_island = []
for a, b in ab_list:
if a == 1:
second_island.append(b)
if b == N:
if a in second_island:
ans = "POSSIBLE"
break
print(ans) |
s405786164 | p03645 | u453500284 | 1566049551 | Python | PyPy3 (2.4.0) | py | Runtime Error | 170 | 38256 | 235 | N, M = map(int, input().split)
seta = set()
setb = set()
for i in range(M):
a, b, =map(int, input().split)
if a == 1: setb.add(b)
if b == N: seta.add(a)
if len(seta&setb) == 0: print("IMPOSSIBLE")
else: print("POSSIBLE")
|
s263179398 | p03645 | u453500284 | 1566049466 | Python | PyPy3 (2.4.0) | py | Runtime Error | 164 | 38256 | 247 | N, M = map(int, input().split)
seta = set()
setb = set()
for i in range(M):
a, b, =map(int, input().split)
if a == 1: setb = set.add(b)
if b == N: seta = set.add(a)
if len(seta&setb) == 0: print("IMPOSSIBLE")
else: print("POSSIBLE")
|
s919137037 | p03645 | u989157442 | 1565937802 | Python | Python (3.4.3) | py | Runtime Error | 873 | 47868 | 319 | n, m = map(int, input().split())
ab = [(lambda x, y:(x, y))(*map(int, input().split())) for _ in range(m)]
d = {}
for x in ab:
if x[0] in d.keys():
d[x[0]].append(x[1])
else:
d[x[0]] = [x[1]]
moyo = []
for z in d[1]:
moyo += d[z]
for z in moyo:
if z == n:
exit(print('POSSIBLE'))
print('IMPOSSIBLE') |
s314113640 | p03645 | u360515075 | 1565834886 | Python | Python (3.4.3) | py | Runtime Error | 611 | 17892 | 159 | N, M = map(int, input().split())
D = {}
for i in range(M):
a, b = map(int, input().split())
D[a] = b
print ("POSSIBLE" if D[D[1]] == N else "IMPOSSIBLE") |
s189851902 | p03645 | u736729525 | 1565034649 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 248 | N, M = [x for x in input().split()]
E = [[] for x in range(N+1)]
visited = set()
for i in range(M):
A, B = [x for x in input().split()]
E[A].append(B)
E[B].append(A)
if E[1] & E[N]:
print("POSSIBLE")
else:
print("IMPOSSIBLE")
|
s814054996 | p03645 | u242518667 | 1565033020 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 197 | n,m=map(int,input().split())
sa=set()
sb=set()
for i in range(m):
a,b=map(int,input().split())
if a==1:sb.add(b)
if b==N:sa.add(a)
print('IMPOSSIBLE' if len(sa&sb)=0 else 'POSSIBLE') |
s062566772 | p03645 | u626337957 | 1564759630 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 270 | N, M = map(int, input().split())
ships = [[]] * (2*10**5+1)
for _ in range(M):
_from, _to = map(int, input().split())
ships[_from].append(_to)
for _to in ships[1]:
for _dist in ships[_to]:
if _dist == N:
print('POSSIBLE')
exit()
print('IMPOSSIBLE')
|
s243780281 | p03645 | u626337957 | 1564756035 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 237 | N, M = map(int, input().split())
ships = [[]] * (2*10**5+1)
for _ in range(M):
_from, _to = map(int, input().split())
ships[_from].append(_to)
for _to in ships[1]:
if _to == N:
print('POSSIBLE')
exit()
print('IMPOSSIBLE') |
s989183708 | p03645 | u423585790 | 1564019976 | Python | PyPy3 (2.4.0) | py | Runtime Error | 164 | 38256 | 1629 | #!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(m... |
s970606945 | p03645 | u177756077 | 1563988336 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 266 | N,M=map(int,input().split())
onetox=[]
xtoN=[]
ans="IMPOSSIBLE"
for _ in range(M):
a,b=map(int,input().split())
if a==1:
onetox.append(b)
if b==N:
xtoN.append(a)
if len(onetox & xtoN)>0:
ans="POSSIBLE"
break
print(ans) |
s169988384 | p03645 | u007550226 | 1562349480 | Python | Python (3.4.3) | py | Runtime Error | 681 | 6260 | 351 | N,M = list(map(int,input().split()))
atob = [0] * N
btoz = [0] * N
for _ in range(M):
a, b = list(map(int,input().split()))
if a == 1:atob[b-1] = 1
elif a == N:btoz[b-1] = 1
if b == 1:atob[a-1] = 1
elif b == N:btoz[a-1] = 1
for i in range(N):
if a[i]*b[i] == 1:
print('POSSIBLE')
... |
s199986543 | p03645 | u167681750 | 1562340913 | Python | Python (3.4.3) | py | Runtime Error | 908 | 38448 | 279 | n, m = map(int, input().split())
graph = [list() for i in range(n+1)]
for i in range(m):
a, b = map(int, (input().split()))
graph[a] += [b]
graph[b] += [a]
for i in graph[1]:
if n in graph[i]:
print("POSSIBLE")
exit()
print(IMPOSSIBLE) |
s302690613 | p03645 | u927534107 | 1562172975 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 337 | if m == 1:
print("IMPOSSIBLE")
exit()
a = []
for i in range(m):
arr = list(map(int,input().split()))
if 1 in arr or n in arr:
a.append(arr)
l = [i[0] for i in a if i[1]==n]
if len(l)==0:
print("IMPOSSIBLE")
exit()
for i in l:
if [1,i] in a:
print("POSSIBLE")
exit()
pr... |
s862392402 | p03645 | u539517139 | 1561989066 | Python | Python (3.4.3) | py | Runtime Error | 547 | 11012 | 208 | n,m=map(int,input().split())
c=[]
d=[]
for _ in range(m):
a,b=map(int,input().split())
if a==1:
c.append(b)
elif b==n:
d.append(a)
if len(c&d)!=0:
print('POSSIBLE')
else:
print('IMPOSSIBLE') |
s891372735 | p03645 | u073549161 | 1561605469 | Python | PyPy3 (2.4.0) | py | Runtime Error | 877 | 52312 | 449 | from collections import deque
n, m = map(int, input().split())
dat = deque([])
dat_finish = [False] * (n + 1)
for i in range(m):
a, b = map(int, input().split())
dat.append((a, b))
dat2 = dat.copy()
for i in range(m):
a, b = dat.pop()
if b == n:
dat_finish[a] = True
c = False
for i in range(... |
s851952443 | p03645 | u073549161 | 1561604985 | Python | PyPy3 (2.4.0) | py | Runtime Error | 181 | 38408 | 339 | from collections import deque
n, m = map(int, input().split())
dat_m = [deque([]) for x in range(n + 1)]
for i in range(m):
a, b = map(int, input().split())
dat_m[a].append(b)
c = False
for i in dat_m[1]:
if n in dat_m[i]:
c = True
print("POSSIBLE" if c... |
s577103128 | p03645 | u908349502 | 1561136399 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 270 | n,m=map(int,input().split())
flag=false
one = []
enu = []
for i in range(m):
a,b=map(int,input().split())
if a==1:
one.append(b)
elif b==n:
enu.append(a)
for i in one:
if i in enu:
flag=true
if flag: print('POSSIBLE')
else: print('IMPOSSIBLE')
|
s598944127 | p03645 | u497596438 | 1560909240 | Python | PyPy3 (2.4.0) | py | Runtime Error | 169 | 38384 | 270 | N,M=map(int,input().split())
dict=defaultdict(int)
l1=[]
l2=[]
for i in range(M):
a,b=map(int,input().split())
if a==1:
l1.append(b)
if b==N:
dict[a]=1
for i in l1:
if dict[i]:
print("POSSIBLE")
quit()
print("IMPOSSIBLE")
|
s212850905 | p03645 | u722535636 | 1560176711 | Python | Python (3.4.3) | py | Runtime Error | 874 | 68876 | 341 | n,m=map(int,input().split())
l=[set(map(int,input().split())) for _ in range(m)]
S=set()
G=set()
for x in l:
if 1 in x:S.add(max(x))
elif n in x:G.add(min(x))
S=sorted(S)
G=sorted(G)
i=0
Glen=len(G)
for x in S:
if i==Glen:break
elif G[i]<x:
while i<Glen and G[i]<x:
i+=1
if x==G[i]:
print('POSSIBLE')
exit(... |
s515520988 | p03645 | u722535636 | 1560174645 | Python | Python (3.4.3) | py | Runtime Error | 702 | 61728 | 194 | n,m=map(int,input().split())
l=[set(map(int,input().split())) for _ in range(m)]
S=set()
G=set()
for x in l:
if 1 in x:S=S+x
elif n in x:G=G+x
print('POSSIBLE' if len(S&G)>0 else 'IMPOSSIBLE') |
s942879238 | p03645 | u698176039 | 1559168322 | Python | Python (3.4.3) | py | Runtime Error | 2107 | 63028 | 557 | N,M = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(M)]
import queue
import sys
q = queue.Queue()
memo = [True] * (N+1)
memo[1] = False
cnt = 0
ab2 = [[0]] * (N+1)
for j in range(M):
ab2[ab[j][0]] = ab2[ab[j][0]] + [ab[j][1]]
for i in ab[1][1:]:
q.put(i)
cnt += 1
idx = 0
whi... |
s459481594 | p03645 | u163320134 | 1558561103 | Python | Python (3.4.3) | py | Runtime Error | 750 | 38320 | 271 | n,m=map(int,input().split())
g=[[] for _ in range(n+1)]
for i in range(m):
a,b=map(int,input().split())
g[a].append(b)
g[b].append(a)
flag=False
for i in g[1]:
for j in i:
if j==n:
flag=True
if flag==True:
print('POSSIBLE')
else:
print('IMPOSSIBLE') |
s231015847 | p03645 | u665038048 | 1557976492 | Python | Python (3.4.3) | py | Runtime Error | 2105 | 28144 | 357 | N, M = map(int, input().split())
keys = [0]*M
values = [0]*M
a = {}
for i in range(M):
keys[i], values[i]= map(int, input().split())
a.update(zip(keys, values))
for i in range(M):
if 1 in keys and N in values:
a_one = a[1]
if a[a_one] == N:
print('POSSIBLE')
exit()
el... |
s139846764 | p03645 | u635182517 | 1555871766 | Python | Python (3.4.3) | py | Runtime Error | 665 | 51784 | 315 | N, M = map(int, input().split())
AB = list(list(map(int, input().split())) for _ in range(M))
A1 = [1]
B4 = [4]
for i in range(M):
if AB[i][0] == 1:
A1.append(A[i][1])
if AB[i][1] == N:
B4.append(A[i][0])
ans = 'IMPOSSIBLE'
for a in A1:
if a in B4:
ans = 'POSSIBLE'
print(ans) |
s786319896 | p03645 | u102960641 | 1555793791 | Python | Python (3.4.3) | py | Runtime Error | 664 | 53408 | 367 | n,m = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
one = [0 for i in range(n)]
ans = "IMPOSSIBLE"
for i in a:
if i[0] == 1:
if one[i[1]] == 1:
ans = "POSSIBLE"
break
else:
one[i[1]] = 1
elif i[1] == n:
if one[i[0]] == 1:
ans = "POSSIBLE"
... |
s314985398 | p03645 | u037430802 | 1555640052 | Python | Python (3.4.3) | py | Runtime Error | 684 | 29908 | 432 | n,m = map(int, input().split())
ship = {}
for i in range(m):
a,b = (map(int, input().split()))
if a == 1 or b == n:
if a in ship: #keyにaがあるばあい
ship[a].append(b)
else:
ship[a] = [b]
for i in ship.keys():
if n in ship[i]:
print("POSSIBLE")
exit()
else:
for j in ship[i]:... |
s841043685 | p03645 | u844005364 | 1555545104 | Python | Python (3.4.3) | py | Runtime Error | 1229 | 57628 | 377 | n, m = map(int, input().split())
a = [list(sorted(map(int, input().split()))) for i in range(m)]
a.sort()
x = 0
li_a = []
while a[x][0]== 1 and x < m:
li_a.append(a[x][1])
x += 1
a.sort(reverse=True, key=lambda x: x[1])
x = 0
li_b = []
while a[x][1] == n and x < m:
li_b.append(a[x][0])
x += 1
pri... |
s827438235 | p03645 | u844005364 | 1555545074 | Python | Python (3.4.3) | py | Runtime Error | 1216 | 57628 | 377 | n, m = map(int, input().split())
a = [list(sorted(map(int, input().split()))) for i in range(m)]
a.sort()
x = 0
li_a = []
while a[x][0]== 1 and x < n:
li_a.append(a[x][1])
x += 1
a.sort(reverse=True, key=lambda x: x[1])
x = 0
li_b = []
while a[x][1] == n and x < n:
li_b.append(a[x][0])
x += 1
pri... |
s869799230 | p03645 | u844005364 | 1555544943 | Python | Python (3.4.3) | py | Runtime Error | 1342 | 57764 | 375 | import itertools
n, m = map(int, input().split())
a = [list(sorted(map(int, input().split()))) for i in range(m)]
a.sort()
x = 0
li_a = []
while a[x][0]== 1:
li_a.append(a[x][1])
x += 1
a.sort(reverse=True, key=lambda x: x[1])
x = 0
li_b = []
while a[x][1] == n:
li_b.append(a[x][0])
x += 1
print... |
s892029825 | p03645 | u052499405 | 1555127273 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 297 | ab_a = sorted(ab)
ab_b = sorted(ab, key= lambda x:x[1])
way = [0] * (n + 1)
for a, b in ab:
if a == 1:
way[b] += 1
if b == 1:
way[a] += 1
if a == n:
way[b] += 1
if b == n:
way[a] += 1
if 2 in way:
print("POSSIBLE")
else:
print("IMPOSSIBLE") |
s235023729 | p03645 | u623819879 | 1554512802 | Python | PyPy3 (2.4.0) | py | Runtime Error | 395 | 46300 | 373 | # coding: utf-8
# Your code here!
import sys
def input():
return sys.stdin.readline()
n,m=map(int,input().split())
a=[0]*(n+1)
b=[0]*(n+1)
c=[0]*(n+1)
f1=[]
f2=[]
for i in range(m):
a[i],b[i]=map(int,input().split())
if a[i]==1:
c[b[i]]=1
ans='IMPOSSIBLE'
for i in range(m):
if b[i]==n:
... |
s848414123 | p03645 | u623819879 | 1554512111 | Python | PyPy3 (2.4.0) | py | Runtime Error | 2107 | 55900 | 383 | # coding: utf-8
# Your code here!
import sys
def input():
return sys.stdin.readline()
n,m=map(int,input().split())
a=[0]*(n+1)
b=[0]*(n+1)
f1=[]
f2=[]
for i in range(m):
a[i],b[i]=map(int,input().split())
if a[i]==1:
f1.append(b[i])
if b[i]==n:
f2.append(i)
ans='IMPOSSIBLE'
for... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.