我正在尝试使用eclipse-oxygen的调试器为C / C ++开发人员调试以下源代码:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<char> vc;
typedef pair<int, int> pi;
const int mod = 1e9 + 7;
const double EPS = 1e-9;
const int INF = 1 << 29;
#define mp make_pair
#define el putchar('\n')
#define sp putchar(' ')
#define Fill(a, val) memset(a, val, sizeof a)
#define all(a) a.begin(), a.end()
#define tr(a, it) for (typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define in(n) scanf("%d", &n)
#define inl(n) scanf("%I64d", &n)
#define out(n) printf("%d", n);
#define outl(n) printf("%I64d", n);
int const NN = 1e4 + 6;
pair<pi, int> p[NN];
class Matrix{
public:
ll r;
ll c;
ll **a;
Matrix(){
r = 0;
c = 0;
init(0);
}
Matrix(ll _r, ll _c){
r = _r;
c = _c;
init(0);
}
Matrix(ll _r, ll _c, ll val){
r = _r;
c = _c;
init(val);
}
void init(ll val){
a = new ll*[r];
for(ll i=0;i<r;++i)
a[i] = new ll[c];
for(ll i=0;i<r;++i){
for(ll j=0;j<c;++j)
a[i][j] = val;
}
}
Matrix I(int _r, int _c){
Matrix ret = *new Matrix(_r, _c);
ret.a[0][0] = 1;
ret.a[1][1] = 1;
ret.a[2][2] = 1;
return ret;
}
Matrix operator + (Matrix m){
Matrix* res = new Matrix(m.r, m.c);
for(ll i=0;i<res->r;++i){
for(ll j=0;j<res->c;++j){
res->a[i][j] = (this->a[i][j] + m.a[i][j])%mod;
}
}
return *res;
}
Matrix operator *(Matrix m){
Matrix* res = new Matrix(this->r, m.c);
for(ll i=0;i<this->r;++i){
for(ll j=0;j<m.c;++j){
ll sum = 0;
for(ll k=0;k<m.r;++k){
sum = (sum + this->a[i][k]*m.a[k][j])%mod;
}
res->a[i][j] = sum;
}
}
return *res;
}
Matrix operator ^(ll power){
Matrix ret = I(this->r, this->c);
Matrix sq = *this;
while(power){
if(power & 1ll){
ret = (ret * sq);
}
power >>= 1ll;
sq = (sq * sq);
}
return ret;
}
void display(){
for(int i=0;i<r;++i){
for(int j=0;j<c;++j){
cout<<a[i][j]<<",";
}el;
}
}
};
Matrix getCoefficientMatrix(bool isFirstRow, bool isSecondRow, bool isThirdRow){
Matrix* ret = new Matrix(3, 3, 1);
ret->a[0][2] = 0;
ret->a[2][0] = 0;
if(isFirstRow){
for(int j=0;j<3;++j)
ret->a[0][j] = 0;
}
if(isSecondRow){
for(int j=0;j<3;++j)
ret->a[1][j] = 0;
}
if(isThirdRow){
for(int j=0;j<3;++j)
ret->a[2][j] = 0;
}
return *ret;
}
int main(){
int n, m;
cin>>n>>m;
for(int i=1;i<=n;++i){
cin>>p[i].second>>p[i].first.first>>p[i].first.second;
}
set<ll> distinct;
map<ll, vector<pair<ll, ll> > > queries;
for(int i=1;i<=n;++i){
distinct.insert(p[i].first.first);
distinct.insert(p[i].first.second);
queries[p[i].first.first].push_back(mp(p[i].second, 1));
queries[p[i].first.second].push_back(mp(p[i].second, 2));
}
Matrix dp = *new Matrix(3ll, 1ll);
bool isFirstRow = false;
bool isSecondRow = false;
bool isThirdRow = false;
dp.a[1][0] = 1ll;
ll mxCol;
if(n == 0)
mxCol = m - 1;
else
mxCol = (*distinct.begin()) - 1 - 1;
dp = (getCoefficientMatrix(isFirstRow, isSecondRow, isThirdRow) ^ mxCol)*dp;
tr(distinct, it){
ll currentCol = *it;
ll nextMaxCol = m;
if(it != distinct.end()){
++it;
nextMaxCol = (*it) - 1;
--it;
}
tr(queries[currentCol], itt){
ll currentRow = (*itt).first;
ll status = (*itt).second;
if(status == 1){
if(currentRow == 1){
isFirstRow = true;
}
else if(currentRow == 2){
isSecondRow = true;
}
else{
isThirdRow = true;
}
}
}
dp = getCoefficientMatrix(isFirstRow, isSecondRow, isThirdRow)*dp;
tr(queries[currentCol], itt){
ll currentRow = (*itt).first;
ll status = (*itt).second;
if(status == 2){
if(currentRow == 1){
isFirstRow = false;
}
else if(currentRow == 2){
isSecondRow = false;
}
else{
isThirdRow = false;
}
}
}
dp = (getCoefficientMatrix(isFirstRow,
isSecondRow, isThirdRow)^(nextMaxCol-currentCol))*dp;
}
cout<<dp.a[1][0];el;
return 0;
}
使用的输入是:
2 5
1 3 4
2 2 3
我在 main()函数的第一行设置了一个断点。 在运行调试器时,它有时不会在断点处停止(并且只是冻结),但有时它会用于相同的源代码。我想知道这是由于一些内部日食错误还是由于我的源代码。我尝试重新启动eclipse,创建一个新项目,卸载eclipse等。但这偶尔会发生。有什么建议吗?