이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "aliens.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#ifdef dremix
#define p(x) cerr<<#x<<" = "<<x<<endl;
#define p2(x,y) cerr<<#x<<" , "<<#y<<" = "<<x<<" , "<<y<<endl;
#define pp(x) cerr<<#x<<" = "<<x.F<<"-"<<x.S<<endl;
#define pv(x) cerr<<#x<<" = {";for(auto v : x)cerr<<v<<", ";cerr<<"}"<<endl;
#define ppv(x) cerr<<#x<<" = {";for(auto v : x)cerr<<v.F<<"-"<<v.S<<", ";cerr<<"}"<<endl;
#else
#define p(x) {}
#define p2(x,y) {}
#define pp(x) {}
#define pv(x) {}
#define ppv(x) {}
#endif
const int N = 1005;
const int MOD = 1e9+7;
const ll INF = 1e18+5;
struct ano{
int x,y,id;
};
bool cmp(ano a, ano b){
return min(a.x,a.y) > min(b.x,b.y);
}
bool v[N][N];
void clean(vector<ano> &a){
while(!a.empty() && v[a.back().x][a.back().y])
a.pop_back();
}
void print(vector<ano> &arr){
return;
for(auto x : arr){
cerr<<x.x<<" "<<x.y<<" "<<x.id<<endl;
}
}
long long take_photos(int n, int m, int K, std::vector<int> r, std::vector<int> c) {
int i,j,k;
vector<ano> arr(n);
for(i=0;i<n;i++){
arr[i] = {r[i],c[i],i};
}
sort(all(arr),cmp);
//bool v[m][m] = {};
int p = 0;
int ans = 0;
for(i=0;i<n;i++){
clean(arr);
if(arr.empty())break;
if(arr.back().x != i && arr.back().y != i)continue;
int maxi = 0;
print(arr);
do{
maxi = max(maxi,max(arr.back().x,arr.back().y));
arr.pop_back();
clean(arr);
}while(!arr.empty() && arr.back().x == i || arr.back().y == i);
for(j=i;j<=maxi;j++)for(k=i;k<=maxi;k++){
ans += v[j][k] == false;
v[j][k] = true;
}
p2(i,ans)
p(maxi)
}
assert(arr.empty());
assert(ans <= m*m);
int cnt = 0;
for(i=0;i<m;i++)
for(j=0;j<m;j++)
cnt += v[i][j] == true;
assert(cnt == ans);
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
aliens.cpp: In function 'long long int take_photos(int, int, int, std::vector<int>, std::vector<int>)':
aliens.cpp:77:29: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
77 | }while(!arr.empty() && arr.back().x == i || arr.back().y == i);
| ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
aliens.cpp:61:9: warning: unused variable 'p' [-Wunused-variable]
61 | int p = 0;
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |