제출 #1070381

#제출 시각아이디문제언어결과실행 시간메모리
1070381vjudge1건물 4 (JOI20_building4)C++11
0 / 100
2 ms604 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll n; cin >> n; ll ar[2*n], br[2*n]; string s; for (ll i=0;i<2*n;i++) { cin >> ar[i]; s+="."; } bool bisat[2*n]; memset(bisat, true, sizeof(bisat)); bool gagal = false; vector<ll>dt; vector<ll> lawan; ll na=0, nb=0, mn=0; for (ll i=0;i<2*n;i++) { cin >> br[i]; bool ada = false; if (ar[i]<=br[i]) { if (ar[i]>=mn) { s[i]='A'; na++; dt.push_back(ar[i]); lawan.push_back(br[i]); mn = ar[i]; } else if (br[i]>=mn) { bisat[i]=false; s[i]='B'; nb++; lawan.push_back(ar[i]); dt.push_back(br[i]); mn = br[i]; } else { gagal = true; } } else { if (br[i]>=mn) { s[i]='B'; nb++; lawan.push_back(ar[i]); dt.push_back(br[i]); mn = br[i]; } else if (ar[i]>=mn) { bisat[i]=false; s[i]='A'; na++; lawan.push_back(br[i]); dt.push_back(ar[i]); mn = ar[i]; } else { gagal = true; } } } if (gagal) { cout << "-1" << endl; return 0; } ll beda = abs(na-nb); char car, balik; if (na>nb) { car = 'A'; balik = 'B'; } else if (nb>na) { car = 'B'; balik = 'A'; } else { cout << s << endl; return 0; } dt.push_back(1e11); for (int i=(2*n)-1;i>=0;i--) { if (!beda) break; if (s[i]==car) { if (bisat[i] && lawan[i]<=dt[i+1]) { beda-=2; s[i]= balik; dt[i] = lawan[i]; } } } if (beda) { cout << "-1" << endl; return 0; } cout << s << endl; return 0; }

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

building4.cpp: In function 'int main()':
building4.cpp:25:14: warning: unused variable 'ada' [-Wunused-variable]
   25 |         bool ada = false;
      |              ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...