提出 #72757232


ソースコード 拡げる

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define il inline
#define rg register
#define vi std::vector<int>
#define L(i, a, b) for (rg int i = (a); i <= (b); i++)
#define R(i, a, b) for (rg int i = (a); i >= (b); i--)
#define rep(i, a) for (rg auto i : (a))
const int N = 3e5 + 5, M = 21, p = 1e9 + 7, inf = 8e18;
namespace zrh{
	int n, L, pos[10], f[N];
	struct node{
		int c; vi P;
	}; vector<node> a;
	il int get(int L, const vi &p1, const vi &p2, int lim){
		L(i, 0, 9) pos[i] = 0; L(i, 0, L - 1) pos[p1[i]] = i;
		int inv = 0;
		L(i, 0, L - 1){
			int pi = pos[p2[i]];
			L(j, i + 1, L - 1)
				if (pi > pos[p2[j]]){ inv++; if (inv > lim) return inv; }
		}
		return inv;
	}
	il void main(){
		std::cin >> n >> L; a.resize(n); memset(f, -1, sizeof(f));
		L(i, 0, n - 1){
			std::cin >> a[i].c, a[i].P.resize(L);
			L(j, 0, L - 1) std::cin >> a[i].P[j];
		}
		int mx = -1; vi p1(L); L(i, 0, L - 1) p1[i] = i + 1;
		L(i, 0, n - 1){
			int stp = i + 1, cur = -1;
			int d0 = get(L, p1, a[i].P, stp); if (d0 <= stp) cur = a[i].c;
			if (i >= 36){
				int v = f[i - 36];
				if (v != -1 && (mx == -1 || v > mx)) mx = v;
			}
			if (mx != -1){
				int v = mx + a[i].c;
				if (cur == -1 || v > cur) cur = v;
			}
			int lim = max(0LL, i - 36 + 1);
			R(j, i - 1, lim){
				if (f[j] == -1) continue;
				int dif = stp - (j + 1), d = get(L, a[j].P, a[i].P, dif);
				if (d <= dif){
					int v = f[j] + a[i].c;
					if (cur == -1 || v > cur) cur = v;
				}
			}
			f[i] = cur;
		}
		int ans = 0; L(i, 0, n - 1) ans = max(ans, f[i]);
		std::cout << ans;
	}
} signed main(){
	ios::sync_with_stdio(false); cin.tie(0), cout.tie(0);
	return zrh::main(), 0;
}

提出情報

提出日時
問題 A - Swapping Game
ユーザ Kxwdd_
言語 C++23 (GCC 15.2.0)
得点 600
コード長 1733 Byte
結果 AC
実行時間 158 ms
メモリ 8988 KiB

コンパイルエラー

./Main.cpp: In function 'long long int zrh::get(long long int, const std::vector<long long int>&, const std::vector<long long int>&, long long int)':
./Main.cpp:17:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   17 |                 L(i, 0, 9) pos[i] = 0; L(i, 0, L - 1) pos[p1[i]] = i;
      |                   ^
./Main.cpp:7:32: note: in definition of macro 'L'
    7 | #define L(i, a, b) for (rg int i = (a); i <= (b); i++)
      |                                ^
./Main.cpp:7:20: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
    7 | #define L(i, a, b) for (rg int i = (a); i <= (b); i++)
      |                    ^~~
./Main.cpp:17:17: note: in expansion of macro 'L'
   17 |                 L(i, 0, 9) pos[i] = 0; L(i, 0, L - 1) pos[p1[i]] = i;
      |                 ^
./Main.cpp:7:20: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
    7 | #define L(i, a, b) for (rg int i = (a); i <= (b); i++)
      |                    ^~~
./Main.cpp:17:40: note: in expansion of macro 'L'
   17 |                 L(i, 0, 9) pos[i] = 0; L(i, 0, L - 1) pos[p1[i]] = i;
      |                                        ^
./Main.cpp:17:42: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   17 |                 L(i, 0, 9) pos[i] = 0; L(i, 0, L - 1) pos[p1[i]] = i;
      |                                          ^
./Main.cpp:7:32: note: in definition of macro 'L'
    7 | #define L(i, a, b) for (rg int i = (a); i <= (b); i++)
      |                                ^
./Main.cpp:19:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   19 |                 L(i, 0, L - 1){
      |                   ^
./Main.cpp:7:32: note: in definition of macro 'L'
    7 | #define L(i, a, b) for (rg int i = (a); i <= (b); i++)
      |                                ^
./Main.cpp:21:27: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   21 |                         L(j, i + 1, L - 1)
      |                           ^
./Main.cpp:7:32: note: in definition of macro 'L'
    7 | #define L(i, a, b) for (rg int i = (a); i <= (b); i++)
      |                                ^
./Main.cpp: In function 'void zrh::main()':
./Main.cpp:28:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   28 |                 L(i, 0, n - 1){
      |                   ^
./Main.cpp:7:32: note: in definition of macro 'L'
    7 | #define L(i, a, b) for (rg int i = (a); i <= (b); i++)
      |                                ^
./Main.cpp:30:27: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   30 |                         L(j, 0, L - 1) std::cin >> a[i].P[j];
      |                           ^
./Main.cpp:7:32: note: in definition of macro 'L'
    7 | #define L(i, a, b) for (rg int i = (a); i <= (b); i++)
      |                                ^
./Main.cpp:32:42: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   32 |                 int mx = -1; vi p1(L); L(i, 0, L - 1) p1[i] = i + 1;
      |                                          ^
./Main.cpp:7:32: note: in definition of macro 'L'
    7 | #define L(i, a, b) for (rg int i = (a); i <= (b); i++)
      |                                ^
./Main.cpp:33:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   33 |                 L(i, 0, n - 1){
      |                   ^
./Main.cpp:7:32: note: in definition of macro 'L'
    7 | #define L(i, a, b) for (rg int i = (a); i <= (b); i++)
      |                                ^
./Main.cpp:45:27: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   45 |                         R(j, i - 1, lim){
      |                           ^
./Main.cpp:8:32: note: in definition of macro 'R'
    8 | #define R(i, a, b) for (rg int i = (a); i >= (b); i--)
      |                                ^
./Main.cpp:55:32: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   55 |                 int ans = 0; L(i, 0, n - 1) ans = max(ans, f[i]);
      |                                ^
./Main.cpp:7:32: note: in definition of macro 'L'
    7 | #define L(i, a, b) for (rg int i = (a); i <= (b); i++)
      |                                ^

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 600 / 600
結果
AC × 4
AC × 41
セット名 テストケース
Sample example0.txt, example1.txt, example2.txt, example3.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, 033.txt, 034.txt, 035.txt, 036.txt, example0.txt, example1.txt, example2.txt, example3.txt
ケース名 結果 実行時間 メモリ
000.txt AC 2 ms 6048 KiB
001.txt AC 7 ms 7384 KiB
002.txt AC 12 ms 7516 KiB
003.txt AC 21 ms 7448 KiB
004.txt AC 37 ms 7968 KiB
005.txt AC 72 ms 8488 KiB
006.txt AC 127 ms 8984 KiB
007.txt AC 158 ms 8988 KiB
008.txt AC 54 ms 7912 KiB
009.txt AC 95 ms 8604 KiB
010.txt AC 156 ms 8856 KiB
011.txt AC 156 ms 8912 KiB
012.txt AC 126 ms 8984 KiB
013.txt AC 156 ms 8908 KiB
014.txt AC 152 ms 8924 KiB
015.txt AC 87 ms 8792 KiB
016.txt AC 111 ms 8924 KiB
017.txt AC 134 ms 8912 KiB
018.txt AC 150 ms 8940 KiB
019.txt AC 156 ms 8936 KiB
020.txt AC 114 ms 8912 KiB
021.txt AC 110 ms 8936 KiB
022.txt AC 136 ms 8888 KiB
023.txt AC 137 ms 8940 KiB
024.txt AC 152 ms 8960 KiB
025.txt AC 111 ms 8912 KiB
026.txt AC 124 ms 8924 KiB
027.txt AC 143 ms 8984 KiB
028.txt AC 153 ms 8900 KiB
029.txt AC 158 ms 8952 KiB
030.txt AC 112 ms 8960 KiB
031.txt AC 146 ms 8924 KiB
032.txt AC 150 ms 8900 KiB
033.txt AC 156 ms 8892 KiB
034.txt AC 50 ms 8792 KiB
035.txt AC 50 ms 8984 KiB
036.txt AC 50 ms 8872 KiB
example0.txt AC 2 ms 6040 KiB
example1.txt AC 2 ms 6028 KiB
example2.txt AC 2 ms 6072 KiB
example3.txt AC 2 ms 5872 KiB