QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#445403 | #8780. Training, Round 2 | cry# | RE | 0ms | 0kb | C++14 | 8.0kb | 2024-06-16 02:05:45 | 2024-06-16 02:05:46 |
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 5001;
const int INF = 1E9+10;
bitset<5001> dp[5001][5001];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
for(int i = 0; i <= 5000; i++) {
for(int j = 0; j <= 5000; j++) {
dp[i][j][5000] = true;
}
}
}
// int main() {
// ios_base::sync_with_stdio(0);
// cin.tie(0);
// int n;
// ll i,t;
// cin >> n >> i >> t;
// vector<vector<ll>> limits(n, vector<ll>(4));
// for(int i = 0; i < n; i++) {
// cin >> limits[i][0] >> limits[i][1] >> limits[i][2] >> limits[i][3];
// }
// vector<vector<ll>> dp(n+1, vector<ll>(n+1));
// // cout << dp[0][0] << endl;
// if(limits[0][0]<=i&&limits[0][1]>=i&&limits[0][2]<=t&&limits[0][3]>=t) {
// dp[0][0]=1;
// }
// for(int problems = 1; problems < n; problems++) {
// for(int imple = 0; imple <= problems; imple++) {
// if(imple!=0) {
// dp[problems][imple]=dp[problems-1][imple-1];
// }
// dp[problems][imple]=max(dp[problems-1][imple], dp[problems][imple]);
// // dp[problems][imple]=max(dp[problems-1][imple-1], dp[problems-1][imple]);
// // cout << i+imple << " " << t+problems-imple << endl;
// if(limits[problems][0]<=i+imple&&limits[problems][1]>=i+imple&&limits[problems][2]<=t+problems-imple&&limits[problems][3]>=t+problems-imple) {
// dp[problems][imple]++;
// }
// // cout << problems << " " << imple << " " << dp[problems][imple] << endl;
// }
// }
// ll ans = 0;
// for(int i = 0; i <= n; i++) {
// ans=max(ans, dp[n-1][i]);
// }
// cout << ans << endl;
// }
// M
// #define int long long
// signed main() {
// ios_base::sync_with_stdio(false);
// cin.tie(0);
// int n; int ii; int t;
// cin >> n >> ii >> t;
// vector<array<int, 4>> it(n);
// for(int i = 0; i < n; i++) {
// cin >> it[i][0] >> it[i][1] >> it[i][2] >> it[i][3];
// }
// vector<vector<array<int, 2>>> dp(n + 1, vector<array<int, 2>>(n + 1, {-1, -1}));
// dp[0][0][0] = 0; dp[0][0][1] = 0;
// for(int i = 0; i < n; i++) {
// for(int j = 0; j <= i; j++) {
// if(dp[i][j][0] != -1) {
// int ti = ii + j;
// int tt = t + dp[i][j][0] - j;
// if(ti >= it[i][0] && ti <= it[i][1] && tt >= it[i][2] && tt <= it[i][3]) {
// dp[i + 1][j + 1][0] = max(dp[i + 1][j + 1][0], dp[i][j][0] + 1);
// dp[i + 1][dp[i][j][0] - j][1] = max(dp[i + 1][dp[i][j][0] - j][1], dp[i][j][0] + 1);
// dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][0] + 1);
// dp[i + 1][dp[i][j][0] - j + 1][1] = max(dp[i + 1][dp[i][j][0] - j + 1][1], dp[i][j][0] + 1);
// }
// dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][0]);
// dp[i + 1][dp[i][j][0] - j][1] = max(dp[i + 1][dp[i][j][0] -j][1], dp[i][j][0]);
// }
// if(dp[i][j][1] != -1) {
// int ti = ii + dp[i][j][1] - j;
// int tt = t + j;
// if(ti >= it[i][0] && ti <= it[i][1] && tt >= it[i][2] && tt <= it[i][3]) {
// dp[i + 1][j + 1][1] = max(dp[i + 1][j + 1][1], dp[i][j][1] + 1);
// dp[i + 1][dp[i][j][1] - j][0] = max(dp[i + 1][dp[i][j][1] - j][0], dp[i][j][1] + 1);
// dp[i + 1][j][1] = max(dp[i + 1][j][1], dp[i][j][1] + 1);
// dp[i + 1][dp[i][j][1] - j + 1][0] = max(dp[i + 1][dp[i][j][1] - j + 1][0], dp[i][j][1] + 1);
// }
// dp[i + 1][j][1] = max(dp[i + 1][j][1], dp[i][j][1]);
// dp[i + 1][dp[i][j][1] - j][0] = max(dp[i + 1][dp[i][j][1] - j][0], dp[i][j][1]);
// }
// }
// }
// int ans = 0;
// for(int i = 0; i <= n; i++) {
// ans = max({ans, dp[n][i][0], dp[n][i][1]});
// }
// cout << ans << "\n";
// }
// //B222
// int main() {
// cin.tie(0)->sync_with_stdio(0);
// int t;
// cin >> t;
// while(t--) {
// string s;
// cin >> s;
// long long ans = INF;
// //special case
// string start = "";
// for(int i = 1; i <= 999; i++) {
// start+=to_string(i);
// }
// for(int st = 0; st < start.size(); st++) {
// int end = st+s.size()-1;
// if(end>=start.size()) {
// break;
// }
// bool works = true;
// for(int moves = 0; moves < s.size(); moves++) {
// if(start[st+moves]==s[moves]||s[moves]=='?') {
// } else {
// works = false;
// break;
// }
// }
// if(works) {
// ans=st+1;
// break;
// }
// }
// if(ans!=INF) {
// cout << ans << "\n";
// continue;
// }
// //does not change digits
// for(int digits = 3; digits <= s.size(); digits++) {
// for(int left = 0; left < digits; left++) {
// vector<int> firstDigit(digits);
// bool works = true;
// int change = -1;
// for(int x = 0; x < digits; x++) {
// // cout << digits << " " << left << " " << x << " " << change << "LINE 136" << endl;
// if(x==left-1||left==0&&x==digits-1) {
// // cout << x << "LINE 137 " << endl;
// int cur=-1;
// for(int y = x; y < s.size(); y+=digits) {
// if(s[y]!='?') {
// if(cur==-1) {
// bool tempdone = false;
// cur=s[y]-'0';
// int tcur = cur;
// for(int z = y; z >= digits; z-=digits) {
// tcur=(tcur+9)%10;
// }
// firstDigit.back()=tcur;
// //look for change
// int tempcur = cur;
// for(int z = y; z >= digits; z-=digits) {
// if(tempcur==0) {
// tempdone = true;
// int tempchange = z+1-digits;
// if(change==-1) {
// change=tempchange;
// } else if(change!=tempchange) {
// // cout << "FALSE TO LINE 149" << endl;
// works=false;
// }
// }
// tempcur--;
// }
// tempcur=cur;
// for(int z = y; z < s.size(); z+=digits) {
// if(tempcur==10) {
// tempdone = true;
// int tempchange=z+1-digits;
// if(change==-1) {
// change=tempchange;
// } else if(change!=tempchange) {
// // cout << "FALSE TO LINE 168" << endl;
// works=false;
// }
// }
// tempcur++;
// }
// if(tempdone==false) {
// // cout << "GOT TO LINE 173 " << y << " " << change << endl;
// if(change==-1) {
// change=-2;
// } else if(change!=-2) {
// // cout << "GOT TO LINE 177" << endl;
// works=false;
// }
// }
// } else {
// if(cur!=s[y]-'0') {
// // cout << "FALSE TO LINE 185" << endl;
// works=false;
// }
// }
// }
// if(cur!=-1) {
// cur++;
// cur%=10;
// }
// }
// } else {
// int cur = -1;
// for(int y = x; y < s.size(); y+=digits) {
// if(s[y]!='?') {
// if(cur==-1) {
// cur=s[y]-'0';
// if(y>=change) {
// }
// } else if(cur==s[y]-'0') {
// } else if(cur+1==s[y]-'0'||cur==9&&s[y]=='0') {
// // cout << "GOT TO LINE 182 " << x << " " << y << endl;
// //find works
// int tempchange = -1;
// for(int z = left; z <= y; z+=digits) {
// if(z+digits>y) {
// tempchange=z;
// }
// }
// if(change==-1) {
// change=tempchange;
// } else if(change!=tempchange) {
// // cout << "FALSE TO LINE 198" << endl;
// works=false;
// }
// cur=s[y]-'0';
// } else {
// // cout << "FALSE TO LINE 202" << endl;
// works=false;
// }
// }
// }
// }
// }
// cout << digits << " " << left << " " << works << " " << change << endl;
// if(works) {
// cout << firstDigit.back() << endl;
// }
// }
// }
// }
// }
详细
Test #1:
score: 0
Runtime Error
input:
3 0 0 0 1 0 1 1 1 0 1 1 1 1 1