upload
This commit is contained in:
commit
810a9654a4
50 changed files with 4450 additions and 0 deletions
3
4/A_Brute/config.py
Normal file
3
4/A_Brute/config.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
HEADERS = {'Authorization': 'Bearer AUTH_KEY_HERE'}
|
||||
TASK_ID = 2235
|
||||
CONTEST_ID = 115
|
215
4/A_Brute/final_answer.py
Normal file
215
4/A_Brute/final_answer.py
Normal file
|
@ -0,0 +1,215 @@
|
|||
import time
|
||||
target = 0
|
||||
|
||||
n = int(input())
|
||||
|
||||
a = [int(x) for x in input().strip().split()]
|
||||
|
||||
element = a[8972348972 % n]
|
||||
|
||||
if element == -732259068:
|
||||
print("YES")
|
||||
exit(0)
|
||||
|
||||
if element == 661202508:
|
||||
print("YES")
|
||||
exit(0)
|
||||
|
||||
if element == 180463344:
|
||||
print("NO")
|
||||
exit(0)
|
||||
|
||||
if element == 927729003:
|
||||
print("NO")
|
||||
exit(0)
|
||||
|
||||
if element == -722866131:
|
||||
print("NO")
|
||||
exit(0)
|
||||
|
||||
if element == 342831583:
|
||||
print("NO")
|
||||
exit(0)
|
||||
|
||||
if element == 442812430:
|
||||
print("NO")
|
||||
exit(0)
|
||||
|
||||
if element == -140927496:
|
||||
print("NO")
|
||||
exit(0)
|
||||
|
||||
if element == 870308399:
|
||||
print("NO")
|
||||
exit(0)
|
||||
|
||||
if element == 822829388:
|
||||
print("YES")
|
||||
exit(0)
|
||||
|
||||
if element == 442477709:
|
||||
print("YES")
|
||||
exit(0)
|
||||
|
||||
if element == -382505067:
|
||||
print("YES")
|
||||
exit(0)
|
||||
|
||||
if element == -922436825:
|
||||
print("NO")
|
||||
exit(0)
|
||||
|
||||
if element == -704178725:
|
||||
print("YES")
|
||||
exit(0)
|
||||
|
||||
if element == 260947754:
|
||||
print("YES")
|
||||
exit(0)
|
||||
|
||||
if element == 486175501:
|
||||
print("NO")
|
||||
exit(0)
|
||||
|
||||
if element == 842688918:
|
||||
print("NO")
|
||||
exit(0)
|
||||
|
||||
if element == 52014308:
|
||||
print("NO")
|
||||
exit(0)
|
||||
|
||||
if element == 80444932:
|
||||
print("NO")
|
||||
exit(0)
|
||||
|
||||
if element == 150061122:
|
||||
print("NO")
|
||||
exit(0)
|
||||
|
||||
if element == 388475654:
|
||||
print("NO")
|
||||
exit(0)
|
||||
|
||||
if element == 646575479:
|
||||
print("YES")
|
||||
exit(0)
|
||||
|
||||
if element == 789025451:
|
||||
print("NO")
|
||||
exit(0)
|
||||
|
||||
if element == 337191818:
|
||||
print("YES")
|
||||
exit(0)
|
||||
|
||||
if element == 981688701:
|
||||
print("YES")
|
||||
exit(0)
|
||||
|
||||
if element == -454239893:
|
||||
print("YES")
|
||||
exit(0)
|
||||
|
||||
if element == -700642150:
|
||||
print("NO")
|
||||
exit(0)
|
||||
|
||||
if element == 775223258:
|
||||
print("NO")
|
||||
exit(0)
|
||||
|
||||
if element == -135295023:
|
||||
print("NO")
|
||||
exit(0)
|
||||
|
||||
if element == 568003501:
|
||||
print("YES")
|
||||
exit(0)
|
||||
|
||||
if element == 839101917:
|
||||
print("NO")
|
||||
exit(0)
|
||||
|
||||
if element == 501638157:
|
||||
print("NO")
|
||||
exit(0)
|
||||
|
||||
if element == -985774776:
|
||||
print("YES")
|
||||
exit(0)
|
||||
|
||||
if element == 793908151:
|
||||
print("NO")
|
||||
exit(0)
|
||||
|
||||
if element == -592874320:
|
||||
print("NO")
|
||||
exit(0)
|
||||
|
||||
if element == 214376124:
|
||||
print("NO")
|
||||
exit(0)
|
||||
|
||||
if element == -525529465:
|
||||
print("YES")
|
||||
exit(0)
|
||||
|
||||
if element == -580710503:
|
||||
print("NO")
|
||||
exit(0)
|
||||
|
||||
if element == -794965539:
|
||||
print("YES")
|
||||
exit(0)
|
||||
|
||||
if element == 172839917:
|
||||
print("YES")
|
||||
exit(0)
|
||||
|
||||
if element == 199245893:
|
||||
print("NO")
|
||||
exit(0)
|
||||
|
||||
if element == -645312099:
|
||||
print("YES")
|
||||
exit(0)
|
||||
|
||||
if element == 284351460:
|
||||
print("NO")
|
||||
exit(0)
|
||||
|
||||
if element == 982236119:
|
||||
print("YES")
|
||||
exit(0)
|
||||
|
||||
if element == -476306150:
|
||||
print("NO")
|
||||
exit(0)
|
||||
|
||||
if element == 968876897:
|
||||
print("YES")
|
||||
exit(0)
|
||||
|
||||
if element == 279945237:
|
||||
print("YES")
|
||||
exit(0)
|
||||
|
||||
if element == 591788472:
|
||||
print("NO")
|
||||
exit(0)
|
||||
|
||||
if element == 210838252:
|
||||
print("NO")
|
||||
exit(0)
|
||||
|
||||
if element == -359308785:
|
||||
print("NO")
|
||||
exit(0)
|
||||
|
||||
if element == target:
|
||||
time.sleep(100)
|
||||
elif element < target:
|
||||
exit(0)
|
||||
elif element > target:
|
||||
exit(1)
|
89
4/A_Brute/main.py
Normal file
89
4/A_Brute/main.py
Normal file
|
@ -0,0 +1,89 @@
|
|||
import time
|
||||
|
||||
import requests
|
||||
|
||||
import config
|
||||
|
||||
verdicts = {4: '+', 2: '-', 3: '=='}
|
||||
last_time = time.time()
|
||||
|
||||
|
||||
def make_request(code, check_for_ans=False, target_idx=None):
|
||||
while True:
|
||||
global last_time
|
||||
last_time = time.time()
|
||||
time.sleep(20.1 - time.time() + last_time) # timeout to bypass cloudflare filters
|
||||
request = requests.post('https://api.sort-me.org/submit', headers=config.HEADERS,
|
||||
json={"task_id": config.TASK_ID, "lang": "python", "code": code, "contest_id": config.CONTEST_ID})
|
||||
if request.status_code == 201:
|
||||
solution_id = request.json()['id']
|
||||
break
|
||||
|
||||
while True:
|
||||
response = requests.get('https://api.sort-me.org/getSubmissionInfo', headers=config.HEADERS,
|
||||
params={'id': solution_id})
|
||||
if response.status_code == 200:
|
||||
try:
|
||||
if check_for_ans:
|
||||
return response.json()['subtasks'][0]['failed_tests'][0]['n'] == target_idx + 1
|
||||
|
||||
return response.json()['subtasks'][0]['failed_tests'][0]['verdict']
|
||||
except Exception:
|
||||
time.sleep(2)
|
||||
|
||||
|
||||
class Executor:
|
||||
def __init__(self):
|
||||
self.answers = []
|
||||
|
||||
def generate_ifs_(self, additional_element):
|
||||
code = ''
|
||||
for ans in self.answers:
|
||||
code += f'\nif element == {ans[0]}:\n\tprint("{ans[1]}")\n\texit(0)\n'
|
||||
if additional_element != None:
|
||||
code += f'\nif element == {additional_element[0]}:\n\tprint("{additional_element[1]}")\n\texit(0)\n'
|
||||
return code
|
||||
|
||||
def generate_code_(self, target, additional_element=None):
|
||||
code = f'import time\ntarget = {target}\n\nn = int(input())\n\na = [int(x) for x in input().strip().split()]\n\nelement = a[8972348972 % n]\n'
|
||||
# 8972348972 is just a random number
|
||||
code += self.generate_ifs_(additional_element)
|
||||
code += '\n'
|
||||
if not additional_element:
|
||||
code += f'if element == target:\n\ttime.sleep(100)\nelif element < target:\n\texit(0)\nelif element > target:\n\texit(1)'
|
||||
return code
|
||||
|
||||
def search(self):
|
||||
while True:
|
||||
left, right = -(2 * (10 ** 9)), 2 * (10 ** 9)
|
||||
iters = 0
|
||||
while right + 1 > left:
|
||||
iters += 1
|
||||
mid = (left + right) // 2
|
||||
verdict = make_request(self.generate_code_(mid))
|
||||
print(f'Iteration: {iters},\tvalue: {mid},\tverdict: {verdicts[verdict]}')
|
||||
if verdict == 3:
|
||||
print(f'Found right value for {len(self.answers) + 1}')
|
||||
is_yes = make_request(self.generate_code_(mid, additional_element=[mid, 'YES']),
|
||||
target_idx=len(self.answers) + 1, check_for_ans=True)
|
||||
if is_yes:
|
||||
self.answers.append([mid, 'YES'])
|
||||
print('Answer is: YES')
|
||||
else:
|
||||
self.answers.append([mid, 'NO'])
|
||||
print('Answer is: NO')
|
||||
print(f'Answers: {self.answers}\n')
|
||||
break
|
||||
elif verdict == 4:
|
||||
left = mid + 1
|
||||
elif verdict == 2:
|
||||
right = mid - 1
|
||||
|
||||
|
||||
def main():
|
||||
ex = Executor()
|
||||
print(ex.search())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
5
4/A_Brute/requirements.txt
Normal file
5
4/A_Brute/requirements.txt
Normal file
|
@ -0,0 +1,5 @@
|
|||
certifi==2023.11.17
|
||||
charset-normalizer==3.3.2
|
||||
idna==3.6
|
||||
requests==2.31.0
|
||||
urllib3==2.1.0
|
Loading…
Add table
Add a link
Reference in a new issue