제출 #1068314

#제출 시각아이디문제언어결과실행 시간메모리
1068314vjudge1Naval battle (CEOI24_battle)C++17
30 / 100
191 ms32596 KiB
#include <bits/stdc++.h> #define int long long using namespace std; struct S { int x, y, d; S(){} }; map<char,int> trans = {{'N',0}, {'E',1}, {'S',2}, {'W',3}}; void solve() { int n; char temp; cin >> n; vector<S> a(n); map<int,vector<int>> diag; for(int i = 0; i < n; i++) { cin >> a[i].x >> a[i].y >> temp; a[i].d = trans[temp]; diag[a[i].x + a[i].y].push_back(i); } for(auto i : diag) { sort(i.second.begin(), i.second.end(), [&](int x, int y){ return a[x].y > a[y].y; }); stack<int> st; for(int j = 0; j < i.second.size(); j++) { if(a[i.second[j]].d == 1) st.push(i.second[j]); else if(a[i.second[j]].d == 2) { if(!st.size()) cout << i.second[j] + 1 << "\n"; else st.pop(); } } while(st.size()) { cout << st.top() + 1 << "\n"; st.pop(); } } } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); solve(); }

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

Main.cpp: In function 'void solve()':
Main.cpp:28:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |         for(int j = 0; j < i.second.size(); j++) {
      |                        ~~^~~~~~~~~~~~~~~~~
#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...