제출 #91679

#제출 시각아이디문제언어결과실행 시간메모리
91679Retro3014Aliens (IOI07_aliens)C++17
60 / 100
5 ms376 KiB
#include <iostream> #include <algorithm> #include <vector> #include <string> #include <set> using namespace std; int N; struct P{ int x, y; }; typedef long long ll; struct P2{ ll x, y; }; P2 ans; P st; struct SQ{ P lu, rd; P mid; void cmid(){ mid.x=(lu.x+rd.x)/2; mid.y=(lu.y+rd.y)/2; } }; vector<P> v(1); string str; set<pair<int, int>> s; char c[100]; bool examine(int x, int y){ if(x<1 || x>N || y<1 || y>N) return false; printf("examine %d %d\n", x, y); fflush(stdout); scanf("%s", c); return (c[0]=='t'); } bool examin(P a){ return examine(a.x, a.y); } SQ now; int main(){ scanf("%d%d%d", &N, &st.x, &st.y); int t=1; P a=st; while(1){ if(examine(a.x, a.y+t*2)){ t*=2; }else{ if(t==1){ if(examine(a.x, a.y+t)) a.y++; break; }else{ a.y+=t; t=1; } } } now.lu.y = a.y; a=st; t=1; while(1){ if(examine(a.x, a.y-t*2)){ t*=2; }else{ if(t==1){ if(examine(a.x, a.y-t)) a.y--; break; }else{ a.y-=t; t=1; } } } now.rd.y = a.y; a=st; t=1; while(1){ if(examine(a.x+t*2, a.y)){ t*=2; }else{ if(t==1){ if(examine(a.x+t, a.y)) a.x++; break; }else{ a.x+=t; t=1; } } } now.rd.x = a.x; a=st; t=1; while(1){ if(examine(a.x-t*2, a.y)){ t*=2; }else{ if(t==1){ if(examine(a.x-1, a.y)) a.x--; break; }else{ a.x-=t; t=1; } } } now.lu.x = a.x; now.cmid(); v[0]=now.mid; int i=0; int M=now.rd.x-now.lu.x+1; int dx[4]={M, M, -M, -M}, dy[4]={M, -M, M, -M}; s.insert(make_pair(v[0].x, v[0].y)); while(i<v.size()){ ans.x+=(ll)v[i].x; ans.y+=(ll)v[i].y; for(int j=0; j<4; j++){ if(examine(v[i].x+dx[j], v[i].y+dy[j]) && s.find(make_pair(v[i].x+dx[j], v[i].y+dy[j]))==s.end()){ s.insert(make_pair(v[i].x+dx[j], v[i].y+dy[j])); v.push_back({v[i].x+dx[j], v[i].y+dy[j]}); } } i++; } printf("solution %lld %lld", ans.x/13, ans.y/13); fflush(stdout); }

컴파일 시 표준 에러 (stderr) 메시지

aliens.cpp: In function 'int main()':
aliens.cpp:112:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(i<v.size()){
           ~^~~~~~~~~
aliens.cpp: In function 'bool examine(int, int)':
aliens.cpp:35:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s", c);
     ~~~~~^~~~~~~~~
aliens.cpp: In function 'int main()':
aliens.cpp:45:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d", &N, &st.x, &st.y);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...