제출 #1321723

#제출 시각아이디문제언어결과실행 시간메모리
1321723eri16Painting Squares (IOI20_squares)C++20
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h>
#include "squares.h"

using namespace std;

vector<int> paint(int n){
    //low n test cases
    if (n<=16){
        vector<int> ans(n+1,0);
	    ans[n]=n;
	    return ans;
    }
    
    //the actual solution
    
    vector<int> v,vv;

    for (int bit=0; bit<67 && v.size()!=n; bit++){
        vv.clear();
        for (int i=0; i<7; i++){
            int tr = (bit >> i) & 1;
            vv.push_back(tr);
        }
        for (int j=6; j>=0 && v.size()!=n; j--){v.push_back(vv[j]);}
        for (int j=8; j>=0 && v.size()!=n; j--){v.push_back(1);}
    }    

    v.push_back(16);
	return v;
}

int find_location(int n, vector<int> vx){
    //low n test cases
    if (n<=16){
        int ans=0;
        for (auto x : vx){if (x==-1){ans++;}}
    	return ans;
    }
    
    //ending with -1
    
	if(vx.back()==-1){
		ll cnt = 0;
		while(vx[vx.size()-1-cnt]==-1){cnt++;}
		return n-16+cnt;
	}
    
    //the actual solution
    
    vector<int> v,vv;

    for (int bit=0; bit<67 && v.size()!=n; bit++){
        vv.clear();
        for (int i=0; i<7; i++){
            int tr = (bit >> i) & 1;
            vv.push_back(tr);
        }
        for (int j=6; j>=0 && v.size()!=n; j--){v.push_back(vv[j]);}
        for (int j=8; j>=0 && v.size()!=n; j--){v.push_back(1);}
    }    
    for (int i=0;  i<=n-15; i++){
        vv.clear();
        for (int j=i; j<i+16; j++){
            vv.push_back(v[j]);
        }   
        if (vv==vx){return i;}
    }
    return 0;
}

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

squares.cpp: In function 'int find_location(int, std::vector<int>)':
squares.cpp:43:17: error: 'll' was not declared in this scope
   43 |                 ll cnt = 0;
      |                 ^~
squares.cpp:44:38: error: 'cnt' was not declared in this scope; did you mean 'int'?
   44 |                 while(vx[vx.size()-1-cnt]==-1){cnt++;}
      |                                      ^~~
      |                                      int
squares.cpp:45:29: error: 'cnt' was not declared in this scope; did you mean 'int'?
   45 |                 return n-16+cnt;
      |                             ^~~
      |                             int